OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
foreign_storage::Csv::anonymous_namespace{CsvShared.cpp} Namespace Reference

Functions

std::string validate_and_get_delimiter (const ForeignTable *foreign_table, const std::string &option_name)
 
std::string validate_and_get_string_with_length (const ForeignTable *foreign_table, const std::string &option_name, const size_t expected_num_chars)
 
std::optional< bool > validate_and_get_bool_value (const ForeignTable *foreign_table, const std::string &option_name)
 

Function Documentation

std::optional<bool> foreign_storage::Csv::anonymous_namespace{CsvShared.cpp}::validate_and_get_bool_value ( const ForeignTable *  foreign_table,
const std::string &  option_name 
)

Definition at line 95 of file CsvShared.cpp.

References foreign_storage::OptionsContainer::options.

96  {
97  if (auto it = foreign_table->options.find(option_name);
98  it != foreign_table->options.end()) {
99  if (boost::iequals(it->second, "TRUE")) {
100  return true;
101  } else if (boost::iequals(it->second, "FALSE")) {
102  return false;
103  } else {
104  throw std::runtime_error{"Invalid boolean value specified for \"" + option_name +
105  "\" foreign table option. "
106  "Value must be either 'true' or 'false'."};
107  }
108  }
109  return std::nullopt;
110 }
std::string foreign_storage::Csv::anonymous_namespace{CsvShared.cpp}::validate_and_get_delimiter ( const ForeignTable *  foreign_table,
const std::string &  option_name 
)

Definition at line 59 of file CsvShared.cpp.

References foreign_storage::OptionsContainer::options.

60  {
61  if (auto it = foreign_table->options.find(option_name);
62  it != foreign_table->options.end()) {
63  if (it->second.length() == 1) {
64  return it->second;
65  } else {
66  if (it->second == std::string("\\n")) {
67  return "\n";
68  } else if (it->second == std::string("\\t")) {
69  return "\t";
70  } else {
71  throw std::runtime_error{"Invalid value specified for option \"" + option_name +
72  "\". Expected a single character, \"\\n\" or \"\\t\"."};
73  }
74  }
75  }
76  return "";
77 }
std::string foreign_storage::Csv::anonymous_namespace{CsvShared.cpp}::validate_and_get_string_with_length ( const ForeignTable *  foreign_table,
const std::string &  option_name,
const size_t  expected_num_chars 
)

Definition at line 79 of file CsvShared.cpp.

References foreign_storage::OptionsContainer::options, and to_string().

81  {
82  if (auto it = foreign_table->options.find(option_name);
83  it != foreign_table->options.end()) {
84  if (it->second.length() != expected_num_chars) {
85  throw std::runtime_error{"Value of \"" + option_name +
86  "\" foreign table option has the wrong number of "
87  "characters. Expected " +
88  std::to_string(expected_num_chars) + " character(s)."};
89  }
90  return it->second;
91  }
92  return "";
93 }
std::string to_string(char const *&&v)

+ Here is the call graph for this function: