25 #include <boost/lexical_cast.hpp> 40 CSVRow(
const CSV* parent,
const std::vector<std::string>& values);
47 template <
typename T = std::
string>
51 template <
typename T = std::
string>
52 T
GetValue(
const std::string& label)
const;
73 template <typename T, std::enable_if_t<std::is_arithmetic<T>::value,
int> = 0>
76 if (std::is_floating_point<T>::value) {
77 return boost::numeric_cast<T>(boost::lexical_cast<
double>(val));
79 return boost::numeric_cast<T>(boost::lexical_cast<
long long>(val));
89 template <typename T, std::enable_if_t<!std::is_arithmetic<T>::value,
int> = 0>
90 inline T
safe_cast(
const std::string& val)
92 return boost::lexical_cast<T>(val);
97 std::string CSVRow::GetValue<std::string>(
size_t index)
const;
101 std::string CSVRow::GetValue<std::string>(
const std::string& label)
const;
104 template <
typename T>
107 return safe_cast<T>(GetValue<std::string>(index));
111 template <
typename T>
114 return safe_cast<T>(GetValue<std::string>(label));
bool operator==(const CSVRow &other) const
Compare operator.
std::vector< std::string > m_values
T GetValue(size_t index) const
Get value at index. When T is specified, StringUtils are used to try to convert the value to type T...
friend std::ostream & operator<<(std::ostream &os, const CSVRow &row)
Print to stream.
T safe_cast(const std::string &val)
Converts a string to an arithmetic type, in a safe manner.
CSVRow(const CSV *parent, const std::vector< std::string > &values)
CSVRow initialized with values. Should no be called by user code. CSV has convenience functions...
CSVRow & operator=(const CSVRow &)=default
Miscellaneous string utilities.
A collection of CSVRow elements.
Namespace for the simulator and related classes.