Vince's CSV Parser
|
Data type representing individual CSV values. More...
#include <csv_row.hpp>
Public Member Functions | |
constexpr | CSVField (csv::string_view _sv) noexcept |
Constructs a CSVField from a string_view. | |
operator std::string () const | |
template<typename T = std::string> | |
T | get () |
Returns the value casted to the requested type, performing type checking before. More... | |
bool | try_parse_hex (int &parsedValue) |
Parse a hexadecimal value, returning false if the value is not hex. | |
bool | try_parse_decimal (long double &dVal, const char decimalSymbol='.') |
Attempts to parse a decimal (or integer) value using the given symbol, returning true if the value is numeric. More... | |
template<typename T > | |
CONSTEXPR_14 bool | operator== (T other) const noexcept |
Compares the contents of this field to a numeric value. More... | |
CONSTEXPR csv::string_view | get_sv () const noexcept |
Return a string view over the field's contents. | |
CONSTEXPR_14 bool | is_null () noexcept |
Returns true if field is an empty string or string of whitespace characters. | |
CONSTEXPR_14 bool | is_str () noexcept |
Returns true if field is a non-numeric, non-empty string. | |
CONSTEXPR_14 bool | is_num () noexcept |
Returns true if field is an integer or float. | |
CONSTEXPR_14 bool | is_int () noexcept |
Returns true if field is an integer. | |
CONSTEXPR_14 bool | is_float () noexcept |
Returns true if field is a floating point value. | |
CONSTEXPR_14 DataType | type () noexcept |
Return the type of the underlying CSV data. | |
template<> | |
CONSTEXPR_14 long double | get () |
Retrieve this field's value as a long double. | |
template<> | |
CONSTEXPR bool | operator== (const char *other) const noexcept |
Compares the contents of this field to a string. | |
template<> | |
CONSTEXPR bool | operator== (csv::string_view other) const noexcept |
Compares the contents of this field to a string. | |
Data type representing individual CSV values.
CSVFields can be obtained by using CSVRow::operator[]
Definition at line 143 of file csv_row.hpp.
|
inline |
Returns the value casted to the requested type, performing type checking before.
std::runtime_error | Thrown if an invalid conversion is performed. |
Definition at line 180 of file csv_row.hpp.
|
inlinenoexcept |
Compares the contents of this field to a numeric value.
If this field does not contain a numeric value, then all comparisons return false.
0.000001
of each other.Definition at line 242 of file csv_row.hpp.
bool csv::CSVField::try_parse_decimal | ( | long double & | dVal, |
const char | decimalSymbol = '.' |
||
) |
Attempts to parse a decimal (or integer) value using the given symbol, returning true
if the value is numeric.
Definition at line 167 of file csv_row.cpp.