|
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. | |
| template<typename T = std::string> | |
| bool | try_get (T &out) noexcept |
| Attempts to retrieve the value as the requested type without throwing exceptions. | |
| template<typename T = long long> | |
| bool | try_parse_hex (T &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. | |
| template<typename T > | |
| CONSTEXPR_14 bool | operator== (T other) const noexcept |
| Compares the contents of this field to a numeric value. | |
| 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_14 bool | try_get (long double &out) noexcept |
| Non-throwing retrieval of field as 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 39 of file csv_row.hpp.
|
inlineexplicitconstexprnoexcept |
Constructs a CSVField from a string_view.
Definition at line 42 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 76 of file csv_row.hpp.
| CONSTEXPR_14 long double csv::CSVField::get | ( | ) |
Retrieve this field's value as a long double.
Definition at line 471 of file csv_row.hpp.
|
inlinenoexcept |
Return a string view over the field's contents.
Definition at line 240 of file csv_row.hpp.
|
inlinenoexcept |
Returns true if field is a floating point value.
Definition at line 257 of file csv_row.hpp.
|
inlinenoexcept |
Returns true if field is an integer.
Definition at line 252 of file csv_row.hpp.
|
inlinenoexcept |
Returns true if field is an empty string or string of whitespace characters.
Definition at line 243 of file csv_row.hpp.
|
inlinenoexcept |
Returns true if field is an integer or float.
Definition at line 249 of file csv_row.hpp.
|
inlinenoexcept |
Returns true if field is a non-numeric, non-empty string.
Definition at line 246 of file csv_row.hpp.
|
inline |
Definition at line 44 of file csv_row.hpp.
|
noexcept |
Compares the contents of this field to a string.
Definition at line 507 of file csv_row.hpp.
|
noexcept |
Compares the contents of this field to a string.
Definition at line 514 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 218 of file csv_row.hpp.
|
noexcept |
Non-throwing retrieval of field as long double.
Definition at line 494 of file csv_row.hpp.
|
inlinenoexcept |
Attempts to retrieve the value as the requested type without throwing exceptions.
| [out] | out | Output parameter that receives the converted value if successful |
Example:
Definition at line 149 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 91 of file csv_row.cpp.
|
inline |
Parse a hexadecimal value, returning false if the value is not hex.
| T | An integral type (int, long, long long, etc.) |
Definition at line 190 of file csv_row.hpp.
|
inlinenoexcept |
Return the type of the underlying CSV data.
Definition at line 260 of file csv_row.hpp.