OmniSciDB  cde582ebc3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImportHelpers Namespace Reference

Functions

bool is_reserved_name (const std::string &name)
 
std::string sanitize_name (const std::string &name)
 

Function Documentation

bool ImportHelpers::is_reserved_name ( const std::string &  name)
inline

Definition at line 28 of file import_helpers.h.

References reserved_keywords.

Referenced by DBHandler::create_table(), DBHandler::detect_column_types(), DBHandler::populateThriftColumnType(), and sanitize_name().

28  {
29  return reserved_keywords.find(boost::to_upper_copy<std::string>(name)) !=
30  reserved_keywords.end();
31 }
static std::set< std::string > reserved_keywords
string name
Definition: setup.in.py:72

+ Here is the caller graph for this function:

std::string ImportHelpers::sanitize_name ( const std::string &  name)
inline

Definition at line 33 of file import_helpers.h.

References is_reserved_name().

Referenced by DBHandler::create_table(), DBHandler::detect_column_types(), import_export::RasterImporter::getBandName(), QueryRunner::ImportDriver::importGeoTable(), and DBHandler::importGeoTableSingle().

33  {
34  boost::regex invalid_chars{R"([^0-9a-z_])",
35  boost::regex::extended | boost::regex::icase};
36  std::string sanitized_name = boost::regex_replace(name, invalid_chars, "");
37  boost::regex starts_with_digit{R"(^[0-9].*)"};
38  if (boost::regex_match(sanitized_name, starts_with_digit)) {
39  sanitized_name = "_" + sanitized_name;
40  }
41  if (is_reserved_name(sanitized_name)) {
42  sanitized_name += "_";
43  }
44  return sanitized_name;
45 }
bool is_reserved_name(const std::string &name)
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function: