OmniSciDB  a5dc49c757
 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, const bool underscore=false)
 
template<typename DatumStringType >
bool is_null_datum (const DatumStringType &datum, const std::string &null_indicator)
 

Function Documentation

template<typename DatumStringType >
bool ImportHelpers::is_null_datum ( const DatumStringType &  datum,
const std::string &  null_indicator 
)
inline

Definition at line 49 of file import_helpers.h.

Referenced by import_export::import_thread_delimited(), and foreign_storage::TextFileBufferParser::isNullDatum().

50  {
51  return datum == null_indicator || datum == "NULL" || datum == "\\N";
52 }

+ Here is the caller graph for this function:

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,
const bool  underscore = false 
)
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 =
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;
41  }
42  if (is_reserved_name(sanitized_name)) {
43  sanitized_name += "_";
44  }
45  return sanitized_name;
46 }
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: