39         HEDLEY_CONST CONSTEXPR_14
 
   40         long double pow10(
const T& n) noexcept {
 
   41             long double multiplicand = n > 0 ? 10 : 0.1,
 
   45             T iterations = n > 0 ? n : -n;
 
   47             for (T i = 0; i < iterations; i++) {
 
   56         HEDLEY_CONST CONSTEXPR_14
 
   57         long double pow10(
const unsigned& n) noexcept {
 
   58             long double multiplicand = n > 0 ? 10 : 0.1,
 
   61             for (
unsigned i = 0; i < n; i++) {
 
   68 #ifndef DOXYGEN_SHOULD_SKIP_THIS 
   70         constexpr 
DataType int_type_arr[8] = {
 
   83             static_assert(std::is_integral<T>::value, 
"T should be an integral type.");
 
   84             static_assert(
sizeof(T) <= 8, 
"Byte size must be no greater than 8.");
 
   85             return int_type_arr[
sizeof(T) - 1];
 
   95             const char decimalsymbol = 
'.');
 
  104         template<
size_t Bytes>
 
  106             static_assert(Bytes == 1 || Bytes == 2 || Bytes == 4 || Bytes == 8,
 
  107                 "Bytes must be a power of 2 below 8.");
 
  110                 return (
long double)std::numeric_limits<signed char>::max();
 
  114                 return (
long double)std::numeric_limits<short>::max();
 
  118                 return (
long double)std::numeric_limits<int>::max();
 
  122                 return (
long double)std::numeric_limits<long int>::max();
 
  126                 return (
long double)std::numeric_limits<long long int>::max();
 
  129             HEDLEY_UNREACHABLE();
 
  135         template<
size_t Bytes>
 
  137             static_assert(Bytes == 1 || Bytes == 2 || Bytes == 4 || Bytes == 8,
 
  138                 "Bytes must be a power of 2 below 8.");
 
  141                 return (
long double)std::numeric_limits<unsigned char>::max();
 
  145                 return (
long double)std::numeric_limits<unsigned short>::max();
 
  149                 return (
long double)std::numeric_limits<unsigned int>::max();
 
  153                 return (
long double)std::numeric_limits<unsigned long int>::max();
 
  157                 return (
long double)std::numeric_limits<unsigned long long int>::max();
 
  160             HEDLEY_UNREACHABLE();
 
  191         HEDLEY_PRIVATE CONSTEXPR_14
 
  194             const long double& coeff,
 
  195             long double * 
const out) {
 
  196             long double exponent = 0;
 
  197             auto result = 
data_type(exponential_part, &exponent);
 
  201                 if (out) *out = coeff * 
pow10(exponent);
 
  211         HEDLEY_PRIVATE HEDLEY_PURE CONSTEXPR_14
 
  247             bool ws_allowed = 
true,
 
  249                 digit_allowed = 
true,
 
  254             unsigned places_after_decimal = 0;
 
  255             long double integral_part = 0,
 
  258             for (
size_t i = 0, ilen = in.size(); i < ilen; i++) {
 
  259                 const char& current = in[i];
 
  264                         if (isdigit(in[i - 1])) {
 
  265                             digit_allowed = 
false;
 
  293                     if (prob_float || (i && i + 1 < ilen && isdigit(in[i - 1]))) {
 
  294                         size_t exponent_start_idx = i + 1;
 
  298                         if (in[i + 1] == 
'+') {
 
  299                             exponent_start_idx++;
 
  303                             in.substr(exponent_start_idx),
 
  304                             is_negative ? -(integral_part + decimal_part) : integral_part + decimal_part,
 
  312                     short digit = 
static_cast<short>(current - 
'0');
 
  313                     if (digit >= 0 && digit <= 9) {
 
  324                             decimal_part += digit / 
pow10(++places_after_decimal);
 
  326                             integral_part = (integral_part * 10) + digit;
 
  329                     else if (dot_allowed && current == decimalSymbol) {
 
  341                 long double number = integral_part + decimal_part;
 
  343                     *out = is_negative ? -number : number;
 
A standalone header file containing shared code.
#define IF_CONSTEXPR
Expands to if constexpr in C++17 and if otherwise.
CONSTEXPR_VALUE_14 long double CSV_INT16_MAX
Largest number that can be stored in a 16-bit integer.
CONSTEXPR_VALUE_14 long double CSV_INT32_MAX
Largest number that can be stored in a 32-bit integer.
CONSTEXPR_VALUE_14 long double CSV_UINT16_MAX
Largest number that can be stored in a 16-bit unsigned integer.
CONSTEXPR_14 DataType data_type(csv::string_view in, long double *const out, const char decimalSymbol)
Distinguishes numeric from other text values.
CONSTEXPR_VALUE_14 long double CSV_UINT32_MAX
Largest number that can be stored in a 32-bit unsigned integer.
HEDLEY_PRIVATE CONSTEXPR_14 DataType _process_potential_exponential(csv::string_view exponential_part, const long double &coeff, long double *const out)
Given a pointer to the start of what is start of the exponential part of a number written (possibly) ...
CONSTEXPR_VALUE_14 long double CSV_INT64_MAX
Largest number that can be stored in a 64-bit integer.
CONSTEXPR_VALUE_14 long double CSV_INT8_MAX
Largest number that can be stored in a 8-bit integer.
CONSTEXPR_VALUE_14 long double CSV_UINT64_MAX
Largest number that can be stored in a 64-bit unsigned integer.
CONSTEXPR_VALUE_14 long double CSV_UINT8_MAX
Largest number that can be stored in a 8-bit ungisned integer.
HEDLEY_CONST CONSTEXPR_14 long double pow10(const T &n) noexcept
Compute 10 to the power of n.
HEDLEY_PRIVATE HEDLEY_PURE CONSTEXPR_14 DataType _determine_integral_type(const long double &number) noexcept
Given the absolute value of an integer, determine what numeric type it fits in.
CONSTEXPR_14 long double get_uint_max()
Given a byte size, return the largest number than can be stored in an unsigned integer of that size.
CONSTEXPR_14 long double get_int_max()
Given a byte size, return the largest number than can be stored in an integer of that size.
The all encompassing namespace.
DataType
Enumerates the different CSV field types that are recognized by this library.
@ CSV_INT64
64-bit integer (long long on MSVC/GCC)
@ CSV_DOUBLE
Floating point value.
@ CSV_BIGINT
Value too big to fit in a 64-bit in.
@ CSV_INT16
16-bit integer (short on MSVC/GCC)
@ CSV_INT32
32-bit integer (int on MSVC/GCC)
@ CSV_STRING
Non-numeric string.
nonstd::string_view string_view
The string_view class used by this library.