13# ifndef WIN32_LEAN_AND_MEAN
14# define WIN32_LEAN_AND_MEAN
19#elif defined(__linux__)
32#if defined(__clang__) || defined(__GNUC__)
33 #define CSV_CONST __attribute__((__const__))
34 #define CSV_PURE __attribute__((__pure__))
35 #define CSV_PRIVATE __attribute__((__visibility__("hidden")))
36 #define CSV_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
37#elif defined(_MSC_VER)
41 #define CSV_NON_NULL(...)
46 #define CSV_NON_NULL(...)
49#if defined(__GNUC__) || defined(__clang__)
50 #define CSV_UNREACHABLE() __builtin_unreachable()
51#elif defined(_MSC_VER)
52 #define CSV_UNREACHABLE() __assume(0)
54 #define CSV_UNREACHABLE() abort()
58#if defined(__cpp_exceptions) || defined(_CPPUNWIND) || defined(__EXCEPTIONS)
59 #define CSV_EXCEPTIONS_ENABLED 1
61 #define CSV_EXCEPTIONS_ENABLED 0
64#if !CSV_EXCEPTIONS_ENABLED
65 #error "csv-parser requires C++ exceptions. Enable exception handling (for example, remove -fno-exceptions or use /EHsc)."
70#if defined(_MSVC_LANG) && _MSVC_LANG > __cplusplus
71# define CSV_CPLUSPLUS _MSVC_LANG
73# define CSV_CPLUSPLUS __cplusplus
76#if (defined(CMAKE_CXX_STANDARD) && CMAKE_CXX_STANDARD == 20) || CSV_CPLUSPLUS >= 202002L
80#if (defined(CMAKE_CXX_STANDARD) && CMAKE_CXX_STANDARD == 17) || CSV_CPLUSPLUS >= 201703L
84#if (defined(CMAKE_CXX_STANDARD) && CMAKE_CXX_STANDARD >= 14) || CSV_CPLUSPLUS >= 201402L
92#include "../external/string_view.hpp"
97#pragma region Compatibility Macros
112#define STATIC_ASSERT(x) static_assert(x, "Assertion failed")
127 #define IF_CONSTEXPR if constexpr
128 #define CONSTEXPR_VALUE constexpr
130 #define CONSTEXPR_17 constexpr
132 #define IF_CONSTEXPR if
133 #define CONSTEXPR_VALUE const
135 #define CONSTEXPR_17 inline
139 template<
bool B,
class T =
void>
140 using enable_if_t = std::enable_if_t<B, T>;
142 #define CONSTEXPR_14 constexpr
143 #define CONSTEXPR_VALUE_14 constexpr
145 template<
bool B,
class T =
void>
146 using enable_if_t =
typename std::enable_if<B, T>::type;
148 #define CONSTEXPR_14 inline
149 #define CONSTEXPR_VALUE_14 const
153 template<
typename F,
typename... Args>
154 using invoke_result_t =
typename std::invoke_result<F, Args...>::type;
156 template<
typename F,
typename... Args>
157 using invoke_result_t =
typename std::result_of<F(Args...)>::type;
162#if defined __GNUC__ && !defined __clang__
163 #if (__GNUC__ >= 7 &&__GNUC_MINOR__ >= 2) || (__GNUC__ >= 8)
164 #define CONSTEXPR constexpr
168 #define CONSTEXPR constexpr
173#define CONSTEXPR inline
180 namespace internals {
182#if defined(PAGE_SIZE)
195#elif defined(__linux__)
219 static_assert(std::is_floating_point<T>::value,
"T must be a floating point type.");
273 constexpr unsigned CHAR_OFFSET = std::numeric_limits<char>::is_signed ? 128 : 0;
std::array< ParseFlags, 256 > ParseFlagMap
An array which maps ASCII chars to a parsing flag.
std::array< bool, 256 > WhitespaceMap
An array which maps ASCII chars to a flag indicating if it is whitespace.
constexpr size_t ITERATION_CHUNK_SIZE
Chunk size for lazy-loading large CSV files.
bool is_equal(T a, T b, T epsilon=0.001)
const int PAGE_SIZE
Size of a memory page in bytes.
ParseFlags
An enum used for describing the significance of each character with respect to CSV parsing.
@ QUOTE_ESCAPE_QUOTE
A quote inside or terminating a quote_escaped field.
@ NOT_SPECIAL
Characters with no special meaning or escaped delimiters and newlines.
@ NEWLINE
Characters which signify a new row.
@ QUOTE
Characters which may signify a quote escape.
@ DELIMITER
Characters which signify a new field.
constexpr ParseFlags quote_escape_flag(ParseFlags flag, bool quote_escape) noexcept
Transform the ParseFlags given the context of whether or not the current field is quote escaped.
CSV_CONST CONSTEXPR_17 OutArray arrayToDefault(T &&value)
Helper constexpr function to initialize an array with all the elements set to value.
The all encompassing namespace.
constexpr int CSV_NOT_FOUND
Integer indicating a requested column wasn't found.
constexpr unsigned CHAR_OFFSET
Offset to convert char into array index.
nonstd::string_view string_view
The string_view class used by this library.