8 Commits

Author SHA1 Message Date
red0124
304ca6ef0f Merge pull request #23 from red0124/bugfix/single_header_include_update
Update ssp.hpp to handle issue fixed in the previous commit
2023-07-25 11:24:54 +02:00
ado
103ff33f21 Update ssp.hpp to handle issue fixed in the previous commit 2023-07-25 11:13:32 +02:00
red0124
8b928de086 Merge pull request #22 from red0124/bugfix/multiline_on_custom_delimiter
Fix bug where the default delimiter would be used for multiline data
2023-07-25 00:46:43 +02:00
ado
6edce88d79 Fix bug where the default delimiter would be used for multiline data 2023-07-25 00:36:53 +02:00
red0124
6196f7796b Merge pull request #21 from red0124/improvement/markdown_labels
Update README links to sections
2023-07-20 00:21:38 +02:00
ado
5672aa635e Update README links to sections 2023-07-20 00:19:31 +02:00
ado
3eefac93b1 Fix README issues 2023-05-25 01:10:37 +02:00
ado
774f452689 fix typo 2023-03-19 19:48:22 +01:00
5 changed files with 27 additions and 23 deletions

View File

@@ -53,20 +53,20 @@ Brian S. Wolfe 40 1.9
Bill (Heath) Gates 65 3.3 Bill (Heath) Gates 65 3.3
``` ```
# Features # Features
* [Works on any type](#Custom-conversions) * [Works on any type](#custom-conversions)
* Easy to use * Easy to use
* No exceptions * No exceptions
* [Works with headers](#Headers) * [Works with headers](#headers)
* [Works with quotes, escapes and spacings](#Setup) * [Works with quotes, escapes and spacings](#setup)
* [Works with values containing new lines](#Multiline) * [Works with values containing new lines](#multiline)
* [Columns and rows can be ignored](#Special-types) * [Columns and rows can be ignored](#special-types)
* Works with any type of delimiter * Works with any type of delimiter
* Can return whole objects composed of converted values * Can return whole objects composed of converted values
* [Descriptive error handling can be enabled](#Error-handling) * [Descriptive error handling can be enabled](#error-handling)
* [Restrictions can be added for each column](#Restrictions) * [Restrictions can be added for each column](#restrictions)
* [Works with `std::optional` and `std::variant`](#Special-types) * [Works with `std::optional` and `std::variant`](#special-types)
* Works with **`CRLF`** and **`LF`** * Works with **`CRLF`** and **`LF`**
* [Conversions can be chained if invalid](#Substitute-conversions) * [Conversions can be chained if invalid](#substitute-conversions)
* Fast * Fast
# Single header # Single header
@@ -378,7 +378,7 @@ if(std::holds_alternative<float>(grade)) {
``` ```
## Restrictions ## Restrictions
Custom **`restrictions`** can be used to narrow down the conversions of unwanted values. **`ss::ir`** (in range) and **`ss::ne`** (none empty) are one of those: Custom **`restrictions`** can be used to narrow down the conversions of unwanted values. **`ss::ir`** (in range) and **`ss::ne`** (none empty) are some of those:
```cpp ```cpp
// ss::ne makes sure that the name is not empty // ss::ne makes sure that the name is not empty
// ss::ir makes sure that the grade will be in range [0, 10] // ss::ir makes sure that the grade will be in range [0, 10]
@@ -472,7 +472,6 @@ The delimiter is " ", and the number of columns varies depending on which shape
```cpp ```cpp
ss::parser p{"shapes.txt", " "}; ss::parser p{"shapes.txt", " "};
if (!p.valid()) { if (!p.valid()) {
std::cout << p.error_msg() << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

View File

@@ -194,7 +194,7 @@ private:
//////////////// ////////////////
const split_data& resplit(line_ptr_type new_line, ssize_t new_size, const split_data& resplit(line_ptr_type new_line, ssize_t new_size,
const std::string& delim = default_delimiter) { const std::string& delim) {
return splitter_.resplit(new_line, new_size, delim); return splitter_.resplit(new_line, new_size, delim);
} }

View File

@@ -623,7 +623,8 @@ private:
} }
} }
next_line_converter_.resplit(next_line_buffer_, size); next_line_converter_.resplit(next_line_buffer_, size,
delim_);
} }
} }

View File

@@ -109,7 +109,7 @@ struct get_matcher<Matcher, T, Ts...> {
struct is_matcher : is_instance_of_matcher<U, Matcher> {}; struct is_matcher : is_instance_of_matcher<U, Matcher> {};
static_assert(count_v<is_matcher, T, Ts...> <= 1, static_assert(count_v<is_matcher, T, Ts...> <= 1,
"the same matcher is cannot" "the same matcher cannot"
"be defined multiple times"); "be defined multiple times");
using type = std::conditional_t<is_matcher<T>::value, T, using type = std::conditional_t<is_matcher<T>::value, T,
typename get_matcher<Matcher, Ts...>::type>; typename get_matcher<Matcher, Ts...>::type>;

14
ssp.hpp
View File

@@ -17,6 +17,7 @@
#include <vector> #include <vector>
#define SSP_DISABLE_FAST_FLOAT #define SSP_DISABLE_FAST_FLOAT
namespace ss { namespace ss {
//////////////// ////////////////
@@ -394,6 +395,7 @@ T to_object(U&& data) {
} /* trait */ } /* trait */
namespace ss { namespace ss {
//////////////// ////////////////
@@ -775,7 +777,7 @@ struct get_matcher<Matcher, T, Ts...> {
struct is_matcher : is_instance_of_matcher<U, Matcher> {}; struct is_matcher : is_instance_of_matcher<U, Matcher> {};
static_assert(count_v<is_matcher, T, Ts...> <= 1, static_assert(count_v<is_matcher, T, Ts...> <= 1,
"the same matcher is cannot" "the same matcher cannot"
"be defined multiple times"); "be defined multiple times");
using type = std::conditional_t<is_matcher<T>::value, T, using type = std::conditional_t<is_matcher<T>::value, T,
typename get_matcher<Matcher, Ts...>::type>; typename get_matcher<Matcher, Ts...>::type>;
@@ -1380,6 +1382,7 @@ public:
} /* ss */ } /* ss */
#ifndef SSP_DISABLE_FAST_FLOAT #ifndef SSP_DISABLE_FAST_FLOAT
#else #else
#endif #endif
@@ -1909,7 +1912,7 @@ private:
//////////////// ////////////////
const split_data& resplit(line_ptr_type new_line, ssize_t new_size, const split_data& resplit(line_ptr_type new_line, ssize_t new_size,
const std::string& delim = default_delimiter) { const std::string& delim) {
return splitter_.resplit(new_line, new_size, delim); return splitter_.resplit(new_line, new_size, delim);
} }
@@ -2198,6 +2201,7 @@ private:
} /* ss */ } /* ss */
namespace ss { namespace ss {
template <typename... Matchers> template <typename... Matchers>
@@ -2339,8 +2343,7 @@ public:
template <bool get_object, typename T, typename... Ts> template <bool get_object, typename T, typename... Ts>
struct iterable { struct iterable {
struct iterator { struct iterator {
using value = using value = std::conditional_t<get_object, T,
std::conditional_t<get_object, T,
no_void_validator_tup_t<T, Ts...>>; no_void_validator_tup_t<T, Ts...>>;
iterator() : parser_{nullptr} { iterator() : parser_{nullptr} {
@@ -2812,7 +2815,8 @@ private:
} }
} }
next_line_converter_.resplit(next_line_buffer_, size); next_line_converter_.resplit(next_line_buffer_, size,
delim_);
} }
} }