13 #include <boost/tokenizer.hpp>
25 return os <<
"'" << p._property_name <<
"' '" << p._property_id <<
"' '"
26 << p._property_data_type <<
"' '" << p._property_data_fname
31 std::string
const& path)
33 boost::char_separator<char> sep(
"\t ");
34 boost::tokenizer<boost::char_separator<char>> tokens(line, sep);
35 auto tok_it(tokens.begin());
38 if (*tok_it !=
"PROPERTY")
40 ERR(
"Expected PROPERTY keyword but '{:s}' found.", tok_it->c_str());
41 throw std::runtime_error(
42 "In parseGocadPropertyMetaData() expected PROPERTY keyword not "
52 while (tok_it != tokens.end())
59 auto checkPropertyID =
60 [](boost::tokenizer<boost::char_separator<char>>::iterator
const&
66 throw std::runtime_error(
67 "parseGocadPropertyMetaData(): id mismatch.");
71 while (std::getline(in, line))
77 if (line.back() ==
'\r')
83 tok_it = tokens.begin();
85 if (*tok_it ==
"PROP_FILE")
87 checkPropertyID(++tok_it, prop);
89 std::string tmp(*tok_it);
91 while (tok_it != tokens.end())
97 if (tmp.front() ==
' ')
99 tmp.erase(tmp.begin());
105 if (*tok_it ==
"PROPERTY_CLASS")
107 checkPropertyID(++tok_it, prop);
112 if (*tok_it ==
"PROPERTY_SUBCLASS")
114 checkPropertyID(++tok_it, prop);
116 if (*tok_it !=
"QUANTITY" && *tok_it !=
"ENUM")
118 ERR(
"Expected keywords QUANTITY or ENUM, but found '{:s}'.",
120 throw std::runtime_error(
121 "parseGocadPropertyMetaData(): Expected keywords QUANTITY "
122 "or ENUM, but found '" +
125 if (*tok_it ==
"QUANTITY")
132 if (*tok_it ==
"PROP_UNIT" || *tok_it ==
"PROP_ORIGINAL_UNIT")
134 checkPropertyID(++tok_it, prop);
139 if (*tok_it ==
"PROP_NO_DATA_VALUE")
141 checkPropertyID(++tok_it, prop);
void ERR(char const *fmt, Args const &... args)
void trim(std::string &str, char ch)
Property parseGocadPropertyMetaData(std::string &line, std::istream &in, std::string const &path)
std::ostream & operator<<(std::ostream &os, CoordinateSystem const &c)
double _property_no_data_value
std::string _property_data_fname
std::string _property_class_name
bool checkID(std::string const &id_string) const
std::string _property_unit
std::string _property_name
std::string _property_data_type