Vince's CSV Parser
Loading...
Searching...
No Matches
data_type.hpp File Reference

Implements data type parsing functionality. More...

#include <cmath>
#include <cctype>
#include <string>
#include <cassert>
#include "common.hpp"

Go to the source code of this file.

Namespaces

namespace  csv
 The all encompassing namespace.
 

Enumerations

enum class  csv::DataType {
  UNKNOWN = -1 , csv::CSV_NULL , csv::CSV_STRING , csv::CSV_INT8 ,
  csv::CSV_INT16 , csv::CSV_INT32 , csv::CSV_INT64 , csv::CSV_BIGINT ,
  csv::CSV_DOUBLE
}
 Enumerates the different CSV field types that are recognized by this library. More...
 

Functions

template<typename T >
CSV_CONST CONSTEXPR_14 long double csv::internals::pow10 (const T &n) noexcept
 Compute 10 to the power of n.
 
template<>
CSV_CONST CONSTEXPR_14 long double csv::internals::pow10 (const unsigned &n) noexcept
 Compute 10 to the power of n.
 
template<size_t Bytes>
CONSTEXPR_14 long double csv::internals::get_int_max ()
 Given a byte size, return the largest number than can be stored in an integer of that size.
 
template<size_t Bytes>
CONSTEXPR_14 long double csv::internals::get_uint_max ()
 Given a byte size, return the largest number than can be stored in an unsigned integer of that size.
 
CSV_PRIVATE CONSTEXPR_14 DataType csv::internals::_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) in scientific notation parse the exponent.
 
CSV_PRIVATE CSV_PURE CONSTEXPR_14 DataType csv::internals::_determine_integral_type (const long double &number) noexcept
 Given the absolute value of an integer, determine what numeric type it fits in.
 
CONSTEXPR_14 DataType csv::internals::data_type (csv::string_view in, long double *const out, const char decimalSymbol)
 Distinguishes numeric from other text values.
 

Variables

CONSTEXPR_VALUE_14 long double csv::internals::CSV_INT8_MAX = get_int_max<1>()
 Largest number that can be stored in a 8-bit integer.
 
CONSTEXPR_VALUE_14 long double csv::internals::CSV_INT16_MAX = get_int_max<2>()
 Largest number that can be stored in a 16-bit integer.
 
CONSTEXPR_VALUE_14 long double csv::internals::CSV_INT32_MAX = get_int_max<4>()
 Largest number that can be stored in a 32-bit integer.
 
CONSTEXPR_VALUE_14 long double csv::internals::CSV_INT64_MAX = get_int_max<8>()
 Largest number that can be stored in a 64-bit integer.
 
CONSTEXPR_VALUE_14 long double csv::internals::CSV_UINT8_MAX = get_uint_max<1>()
 Largest number that can be stored in a 8-bit ungisned integer.
 
CONSTEXPR_VALUE_14 long double csv::internals::CSV_UINT16_MAX = get_uint_max<2>()
 Largest number that can be stored in a 16-bit unsigned integer.
 
CONSTEXPR_VALUE_14 long double csv::internals::CSV_UINT32_MAX = get_uint_max<4>()
 Largest number that can be stored in a 32-bit unsigned integer.
 
CONSTEXPR_VALUE_14 long double csv::internals::CSV_UINT64_MAX = get_uint_max<8>()
 Largest number that can be stored in a 64-bit unsigned integer.
 

Detailed Description

Implements data type parsing functionality.

Definition in file data_type.hpp.

Function Documentation

◆ _determine_integral_type()

CSV_PRIVATE CSV_PURE CONSTEXPR_14 DataType csv::internals::_determine_integral_type ( const long double number)
noexcept

Given the absolute value of an integer, determine what numeric type it fits in.

Definition at line 211 of file data_type.hpp.

◆ _process_potential_exponential()

CSV_PRIVATE CONSTEXPR_14 DataType csv::internals::_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) in scientific notation parse the exponent.

Definition at line 191 of file data_type.hpp.

◆ data_type()

CONSTEXPR_14 DataType csv::internals::data_type ( csv::string_view  in,
long double *const  out,
const char  decimalSymbol 
)

Distinguishes numeric from other text values.

Used by various type casting functions, like csv_parser::CSVReader::read_row()

Rules

  • Leading and trailing whitespace ("padding") ignored
  • A string of just whitespace is NULL
Parameters
[in]inString value to be examined
[out]outPointer to long double where results of numeric parsing get stored
[in]decimalSymbolthe character separating integral and decimal part, defaults to '.' if omitted

Definition at line 241 of file data_type.hpp.

◆ get_int_max()

template<size_t Bytes>
CONSTEXPR_14 long double csv::internals::get_int_max ( )

Given a byte size, return the largest number than can be stored in an integer of that size.

Note: Provides a platform-agnostic way of mapping names like "long int" to byte sizes

Definition at line 112 of file data_type.hpp.

◆ get_uint_max()

template<size_t Bytes>
CONSTEXPR_14 long double csv::internals::get_uint_max ( )

Given a byte size, return the largest number than can be stored in an unsigned integer of that size.

Definition at line 139 of file data_type.hpp.

◆ pow10() [1/2]

template<typename T >
CSV_CONST CONSTEXPR_14 long double csv::internals::pow10 ( const T n)
noexcept

Compute 10 to the power of n.

Only integral exponents are supported; fractional exponents are never needed since CSV scientific notation exponents are always integers (enforced by the CSV_INT8..CSV_INT64 guard in _process_potential_exponential before calling this).

Definition at line 45 of file data_type.hpp.

◆ pow10() [2/2]

template<>
CSV_CONST CONSTEXPR_14 long double csv::internals::pow10 ( const unsigned n)
noexcept

Compute 10 to the power of n.

Definition at line 64 of file data_type.hpp.

Variable Documentation

◆ CSV_INT16_MAX

CONSTEXPR_VALUE_14 long double csv::internals::CSV_INT16_MAX = get_int_max<2>()

Largest number that can be stored in a 16-bit integer.

Definition at line 166 of file data_type.hpp.

◆ CSV_INT32_MAX

CONSTEXPR_VALUE_14 long double csv::internals::CSV_INT32_MAX = get_int_max<4>()

Largest number that can be stored in a 32-bit integer.

Definition at line 169 of file data_type.hpp.

◆ CSV_INT64_MAX

CONSTEXPR_VALUE_14 long double csv::internals::CSV_INT64_MAX = get_int_max<8>()

Largest number that can be stored in a 64-bit integer.

Definition at line 172 of file data_type.hpp.

◆ CSV_INT8_MAX

CONSTEXPR_VALUE_14 long double csv::internals::CSV_INT8_MAX = get_int_max<1>()

Largest number that can be stored in a 8-bit integer.

Definition at line 163 of file data_type.hpp.

◆ CSV_UINT16_MAX

CONSTEXPR_VALUE_14 long double csv::internals::CSV_UINT16_MAX = get_uint_max<2>()

Largest number that can be stored in a 16-bit unsigned integer.

Definition at line 178 of file data_type.hpp.

◆ CSV_UINT32_MAX

CONSTEXPR_VALUE_14 long double csv::internals::CSV_UINT32_MAX = get_uint_max<4>()

Largest number that can be stored in a 32-bit unsigned integer.

Definition at line 181 of file data_type.hpp.

◆ CSV_UINT64_MAX

CONSTEXPR_VALUE_14 long double csv::internals::CSV_UINT64_MAX = get_uint_max<8>()

Largest number that can be stored in a 64-bit unsigned integer.

Definition at line 184 of file data_type.hpp.

◆ CSV_UINT8_MAX

CONSTEXPR_VALUE_14 long double csv::internals::CSV_UINT8_MAX = get_uint_max<1>()

Largest number that can be stored in a 8-bit ungisned integer.

Definition at line 175 of file data_type.hpp.