17 #ifndef IMPORT_HELPERS_H_
18 #define IMPORT_HELPERS_H_
23 #include <boost/algorithm/string.hpp>
24 #include <boost/algorithm/string/replace.hpp>
26 namespace ImportHelpers {
34 boost::regex invalid_chars{R
"([^0-9a-z_])",
35 boost::regex::extended | boost::regex::icase};
36 std::string sanitized_name =
37 boost::regex_replace(name, invalid_chars, underscore ? "_" :
"");
38 boost::regex starts_with_digit{R
"(^[0-9].*)"};
39 if (boost::regex_match(sanitized_name, starts_with_digit)) {
40 sanitized_name =
"_" + sanitized_name;
43 sanitized_name +=
"_";
45 return sanitized_name;
48 template <
typename DatumStringType>
50 const std::string& null_indicator) {
51 return datum == null_indicator || datum ==
"NULL" || datum ==
"\\N";
56 #endif // IMPORT_HELPERS_H_
static std::set< std::string > reserved_keywords
bool is_null_datum(const DatumStringType &datum, const std::string &null_indicator)
bool is_reserved_name(const std::string &name)
std::string sanitize_name(const std::string &name, const bool underscore=false)