18#ifndef __SDDSPARSER_H__
19#define __SDDSPARSER_H__
47 std::string retval(for_string);
63 void setInput(
const std::string &input);
83 void getValue(
int t, std::string column_name, T& nval) {
92 if(t <= 0 ||
static_cast<size_t>(t) > num_rows)
93 row_idx = num_rows - 1;
95 row_idx =
static_cast<size_t>(t) - 1;
98 nval = getBoostVariantValue<T>(val, (
int)
getColumnType(column_name));
111 template <
typename T>
113 std::string col_name, T& nval) {
116 double value_before_ref = 0;
117 double value_after_ref = 0;
126 size_t num_rows = ref_values.size();
128 for(this_row = 0; this_row < num_rows; this_row++) {
129 value_after_ref = boost::get<double>(ref_values[this_row]);
131 if(ref_val < value_after_ref) {
134 if(this_row > 0) prev_row = this_row - 1;
136 value_before = getBoostVariantValue<T>(col_values[prev_row], datatype);
137 value_after = getBoostVariantValue<T>(col_values[this_row], datatype);
139 value_before_ref = boost::get<double>(ref_values[prev_row]);
140 value_after_ref = boost::get<double>(ref_values[this_row]);
146 if(this_row == num_rows)
148 "all values < specified reference value");
151 if(ref_val - value_before_ref < 1e-8)
154 nval = value_before + (ref_val - value_before_ref)
155 * (value_after - value_before)
156 / (value_after_ref - value_before_ref);
158 if (!std::isfinite(nval))
160 "Interpolated value either NaN or Inf.");
171 template <
typename T>
183 template <
typename T>
190 nval = boost::get<T>(value);
193 "unknown parameter name: '" + parameter_name +
"'!");
200 template <
typename T>
206 value = boost::get<float>(val);
209 value = boost::get<double>(val);
212 value = boost::get<short>(val);
215 value = boost::get<long>(val);
219 "can't convert value to type T");
224 "can't convert value");
std::vector< variant_t > columnData_t
boost::variant< float, double, short, long, char, std::string > variant_t
std::map< std::string, int > columnNameToID_m
mapping from column name to ID in columns_m
void getParameterValue(std::string parameter_name, T &nval)
ast::columnData_t getColumnData(const std::string &columnName)
ast::datatype getColumnType(const std::string &col_name)
std::string sddsFileName_m
T getBoostVariantValue(const ast::variant_t &val, int datatype) const
Convert value from boost variant (only numeric types) to a value of type T.
void getInterpolatedValue(std::string ref_name, double ref_val, std::string col_name, T &nval)
static void fixCaseSensitivity(std::string &for_string)
void setInput(const std::string &input)
void getValue(int t, std::string column_name, T &nval)
static std::string fixCaseSensitivity(const std::string &for_string)
void getInterpolatedValue(double spos, std::string col_name, T &nval)
int getColumnIndex(std::string col_name) const
std::map< std::string, int > paramNameToID_m
mapping from parameter name to offset in params_m
parameterList sddsParameters_m