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
```
# Features
* [Works on any type](#Custom-conversions)
* [Works on any type](#custom-conversions)
* Easy to use
* No exceptions
* [Works with headers](#Headers)
* [Works with quotes, escapes and spacings](#Setup)
* [Works with values containing new lines](#Multiline)
* [Columns and rows can be ignored](#Special-types)
* [Works with headers](#headers)
* [Works with quotes, escapes and spacings](#setup)
* [Works with values containing new lines](#multiline)
* [Columns and rows can be ignored](#special-types)
* Works with any type of delimiter
* Can return whole objects composed of converted values
* [Descriptive error handling can be enabled](#Error-handling)
* [Restrictions can be added for each column](#Restrictions)
* [Works with `std::optional` and `std::variant`](#Special-types)
* [Descriptive error handling can be enabled](#error-handling)
* [Restrictions can be added for each column](#restrictions)
* [Works with `std::optional` and `std::variant`](#special-types)
* Works with **`CRLF`** and **`LF`**
* [Conversions can be chained if invalid](#Substitute-conversions)
* [Conversions can be chained if invalid](#substitute-conversions)
* Fast
# Single header
@@ -378,7 +378,7 @@ if(std::holds_alternative<float>(grade)) {
```
## 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
// ss::ne makes sure that the name is not empty
// 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
ss::parser p{"shapes.txt", " "};
if (!p.valid()) {
std::cout << p.error_msg() << std::endl;
exit(EXIT_FAILURE);
}

View File

@@ -194,7 +194,7 @@ private:
////////////////
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);
}

View File

@@ -152,7 +152,7 @@ public:
struct iterable {
struct iterator {
using value = std::conditional_t<get_object, T,
no_void_validator_tup_t<T, Ts...>>;
no_void_validator_tup_t<T, Ts...>>;
iterator() : parser_{nullptr} {
}
@@ -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,10 +109,10 @@ struct get_matcher<Matcher, T, Ts...> {
struct is_matcher : is_instance_of_matcher<U, Matcher> {};
static_assert(count_v<is_matcher, T, Ts...> <= 1,
"the same matcher is cannot"
"the same matcher cannot"
"be defined multiple times");
using type = std::conditional_t<is_matcher<T>::value, T,
typename get_matcher<Matcher, Ts...>::type>;
typename get_matcher<Matcher, Ts...>::type>;
};
template <template <char...> class Matcher>
@@ -150,7 +150,7 @@ struct get_multiline;
template <typename T, typename... Ts>
struct get_multiline<T, Ts...> {
using type = std::conditional_t<is_instance_of_multiline<T>::value, T,
typename get_multiline<Ts...>::type>;
typename get_multiline<Ts...>::type>;
};
template <>

16
ssp.hpp
View File

@@ -17,6 +17,7 @@
#include <vector>
#define SSP_DISABLE_FAST_FLOAT
namespace ss {
////////////////
@@ -394,6 +395,7 @@ T to_object(U&& data) {
} /* trait */
namespace ss {
////////////////
@@ -775,7 +777,7 @@ struct get_matcher<Matcher, T, Ts...> {
struct is_matcher : is_instance_of_matcher<U, Matcher> {};
static_assert(count_v<is_matcher, T, Ts...> <= 1,
"the same matcher is cannot"
"the same matcher cannot"
"be defined multiple times");
using type = std::conditional_t<is_matcher<T>::value, T,
typename get_matcher<Matcher, Ts...>::type>;
@@ -1380,6 +1382,7 @@ public:
} /* ss */
#ifndef SSP_DISABLE_FAST_FLOAT
#else
#endif
@@ -1909,7 +1912,7 @@ private:
////////////////
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);
}
@@ -2198,6 +2201,7 @@ private:
} /* ss */
namespace ss {
template <typename... Matchers>
@@ -2339,9 +2343,8 @@ public:
template <bool get_object, typename T, typename... Ts>
struct iterable {
struct iterator {
using value =
std::conditional_t<get_object, T,
no_void_validator_tup_t<T, Ts...>>;
using value = std::conditional_t<get_object, T,
no_void_validator_tup_t<T, Ts...>>;
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_);
}
}