|
Vince's CSV Parser
|
A standalone header file containing shared code. More...
#include <algorithm>#include <array>#include <cmath>#include <cstdlib>#include <deque>#include <type_traits>#include "../external/string_view.hpp"Go to the source code of this file.
Namespaces | |
| namespace | csv |
| The all encompassing namespace. | |
Macros | |
| #define | CSV_INLINE |
| Helper macro which should be #defined as "inline" in the single header version. | |
| #define | CSV_ENABLE_THREADS 1 |
| #define | CSV_CONST |
| #define | CSV_PURE |
| #define | CSV_PRIVATE |
| #define | CSV_NON_NULL(...) |
| #define | CSV_MSVC_PUSH_DISABLE(w) |
| #define | CSV_MSVC_POP |
| #define | CSV_EXCEPTIONS_ENABLED 0 |
| #define | CSV_CPLUSPLUS __cplusplus |
| #define | STATIC_ASSERT(x) static_assert(x, "Assertion failed") |
| #define | IF_CONSTEXPR if |
Expands to if constexpr in C++17 and if otherwise. | |
| #define | CONSTEXPR_VALUE const |
Expands to constexpr in C++17 and const otherwise. | |
| #define | CONSTEXPR_17 inline |
| #define | CONSTEXPR_14 inline |
| #define | CONSTEXPR_VALUE_14 const |
| #define | CONSTEXPR inline |
Expands to constexpr in decent compilers and inline otherwise. | |
Typedefs | |
| using | csv::string_view = nonstd::string_view |
| The string_view class used by this library. | |
| template<bool B, class T = void> | |
| using | csv::enable_if_t = typename std::enable_if< B, T >::type |
| template<typename F , typename... Args> | |
| using | csv::invoke_result_t = typename std::result_of< F(Args...)>::type |
| using | csv::internals::ParseFlagMap = std::array< ParseFlags, 256 > |
| An array which maps ASCII chars to a parsing flag. | |
| using | csv::internals::WhitespaceMap = std::array< bool, 256 > |
| An array which maps ASCII chars to a flag indicating if it is whitespace. | |
Enumerations | |
| enum class | csv::internals::ParseFlags { QUOTE_ESCAPE_QUOTE = 0 , QUOTE = 2 | 1 , NOT_SPECIAL = 4 , DELIMITER = 4 | 1 , CARRIAGE_RETURN = 4 | 2 , NEWLINE = 4 | 2 | 1 } |
| An enum used for describing the significance of each character with respect to CSV parsing. More... | |
Variables | |
| const int | csv::internals::PAGE_SIZE = 4096 |
| Size of a memory page in bytes. | |
| constexpr size_t | csv::internals::CSV_CHUNK_SIZE_DEFAULT = 10000000 |
| Default chunk size for lazy-loading large CSV files. | |
| constexpr size_t | csv::internals::CSV_CHUNK_SIZE_FLOOR = 500 * 1024 |
| Minimum supported custom chunk size for CSVFormat::chunk_size(). | |
| constexpr int | csv::CSV_NOT_FOUND = -1 |
| Integer indicating a requested column wasn't found. | |
| constexpr unsigned | csv::CHAR_OFFSET = std::numeric_limits<char>::is_signed ? 128 : 0 |
| Offset to convert char into array index. | |
A standalone header file containing shared code.
Definition in file common.hpp.
| #define CONSTEXPR inline |
Expands to constexpr in decent compilers and inline otherwise.
Intended for functions and methods.
Definition at line 187 of file common.hpp.
| #define CONSTEXPR_14 inline |
Definition at line 160 of file common.hpp.
| #define CONSTEXPR_17 inline |
Definition at line 147 of file common.hpp.
| #define CONSTEXPR_VALUE const |
Expands to constexpr in C++17 and const otherwise.
Mainly used for global variables.
Definition at line 145 of file common.hpp.
| #define CONSTEXPR_VALUE_14 const |
Definition at line 161 of file common.hpp.
| #define CSV_CONST |
Definition at line 52 of file common.hpp.
| #define CSV_CPLUSPLUS __cplusplus |
Definition at line 84 of file common.hpp.
| #define CSV_ENABLE_THREADS 1 |
Definition at line 33 of file common.hpp.
| #define CSV_EXCEPTIONS_ENABLED 0 |
Definition at line 72 of file common.hpp.
| #define CSV_INLINE |
Helper macro which should be #defined as "inline" in the single header version.
Definition at line 26 of file common.hpp.
| #define CSV_MSVC_POP |
Definition at line 65 of file common.hpp.
| #define CSV_MSVC_PUSH_DISABLE | ( | w | ) |
Definition at line 64 of file common.hpp.
| #define CSV_NON_NULL | ( | ... | ) |
Definition at line 55 of file common.hpp.
| #define CSV_PRIVATE |
Definition at line 54 of file common.hpp.
| #define CSV_PURE |
Definition at line 53 of file common.hpp.
| #define IF_CONSTEXPR if |
Expands to if constexpr in C++17 and if otherwise.
Definition at line 144 of file common.hpp.
| #define STATIC_ASSERT | ( | x | ) | static_assert(x, "Assertion failed") |
Definition at line 124 of file common.hpp.
| using csv::internals::ParseFlagMap = typedef std::array<ParseFlags, 256> |
An array which maps ASCII chars to a parsing flag.
Definition at line 289 of file common.hpp.
| using csv::internals::WhitespaceMap = typedef std::array<bool, 256> |
An array which maps ASCII chars to a flag indicating if it is whitespace.
Definition at line 292 of file common.hpp.
|
strong |
An enum used for describing the significance of each character with respect to CSV parsing.
Definition at line 250 of file common.hpp.
Returns true if two floating point values are about the same
Definition at line 238 of file common.hpp.
|
constexprnoexcept |
Transform the ParseFlags given the context of whether or not the current field is quote escaped.
Definition at line 261 of file common.hpp.
| csv::internals::STATIC_ASSERT | ( | quote_escape_flag(ParseFlags::NOT_SPECIAL, false) | = =ParseFlags::NOT_SPECIAL | ) |
Optimizations for reducing branching in parsing loop.
Idea: The meaning of all non-quote characters changes depending on whether or not the parser is in a quote-escaped mode (0 or 1)
|
constexpr |
Default chunk size for lazy-loading large CSV files.
The worker thread reads this many bytes at a time by default (10MB).
CRITICAL INVARIANT: Field boundaries at chunk transitions must be preserved. Bug #280 was caused by fields spanning chunk boundaries being corrupted.
Definition at line 228 of file common.hpp.
|
constexpr |
Minimum supported custom chunk size for CSVFormat::chunk_size().
This lower bound allows memory-constrained environments to reduce parser buffer size while avoiding pathological tiny-buffer overhead.
Definition at line 235 of file common.hpp.
| const int csv::internals::PAGE_SIZE = 4096 |
Size of a memory page in bytes.
Used by csv::internals::CSVFieldArray when allocating blocks.
Definition at line 215 of file common.hpp.