|
DryChem 1.0.0
A generic, compile-time C++ toolbox with no dependencies for the modern computational chemistry project.
|
#include <tokenizer.hpp>
Public Types | |
| using | value_type = std::basic_string<char, CharTraits> |
| Member types. | |
| using | reference = std::basic_string<char, CharTraits>& |
| using | const_reference = const std::basic_string<char, CharTraits>& |
| using | iterator = typename std::basic_string<char, CharTraits>::iterator |
| using | const_iterator = typename std::basic_string<char, CharTraits>::const_iterator |
Public Member Functions | |
| constexpr | Tokenizer (const_iterator begin_, const_iterator end_, const_reference delimiters_=" \t\n", std::optional< value_type > keepDelimiters_=std::nullopt) |
| constexpr | Tokenizer (const_reference str_, const_reference delimiters_=" \t\n", std::optional< value_type > keepDelimiters_=std::nullopt) |
| template<typename Container = std::vector<value_type>, typename T = typename Container::value_type, typename = std::enable_if_t<std::conjunction_v<Meta::is_allocator_aware_container<Container>, std::negation<details::has_mapped_type<Container>>>>> | |
| constexpr Container | split () |
Private Member Functions | |
| constexpr bool | isDelimiter (const char ch_) const noexcept |
| constexpr value_type | nextToken () |
Private Attributes | |
| const_iterator | str_current |
| const_iterator | str_end |
| value_type | delimiters |
| std::optional< value_type > | keepDelimiters |
A class template which separates a given string into "tokens", which fall between specified delimiters.
| CharTraits | - The character traits used when comparing strings |
| using CppUtils::Strings::Tokenizer< CharTraits >::value_type = std::basic_string<char, CharTraits> |
| using CppUtils::Strings::Tokenizer< CharTraits >::reference = std::basic_string<char, CharTraits>& |
| using CppUtils::Strings::Tokenizer< CharTraits >::const_reference = const std::basic_string<char, CharTraits>& |
| using CppUtils::Strings::Tokenizer< CharTraits >::iterator = typename std::basic_string<char, CharTraits>::iterator |
| using CppUtils::Strings::Tokenizer< CharTraits >::const_iterator = typename std::basic_string<char, CharTraits>::const_iterator |
|
inlineconstexpr |
A constructor allowing for the user to pass a range to iterate through.
| begin_ | - The start of our sequence to iterate over |
| end_ | - The end of our sequence to iterate over |
| delimiters_ | - The delimiters we are using as our splitting criterion |
| keepDelimiters_ | - The delimiters to include as tokens (optional) |
References delimiters, keepDelimiters, str_current, and str_end.
|
inlineexplicitconstexpr |
Delegating constructor taking a full string instead of just a range.
| str_ | - The full string we will be splitting |
| delimiters_ | - The delimiters we are using as our splitting criterion |
| keepDelimiters_ | - The delimiters to include as tokens (optional) |
References delimiters, keepDelimiters, str_current, and str_end.
|
inlineconstexprprivatenoexcept |
A private helper function that is essentially just a wrapper for foundSubstr().
| ch | - The character we are evaluating from the list of delimiters |
References delimiters, and CppUtils::Strings::foundSubstr().
Referenced by nextToken().
|
inlineconstexprprivate |
A private helper function which iterates through the remaining string looking for the next token.
References CppUtils::Strings::foundSubstr(), isDelimiter(), keepDelimiters, str_current, and str_end.
Referenced by split().
|
inlineconstexpr |
The main function we call to split our input string into separate tokens.
| Container | - The container type we wish to return |
| T | - The type of the value we will cast our tokens into |
std::forward_list<> requires special treatment as it can only call insert_front References CppUtils::Strings::lexical_cast(), nextToken(), str_current, and str_end.
Referenced by CppUtils::Files::AsColumns::operator()().
|
private |
Referenced by nextToken(), split(), Tokenizer(), and Tokenizer().
|
private |
Referenced by nextToken(), split(), Tokenizer(), and Tokenizer().
|
private |
Referenced by isDelimiter(), Tokenizer(), and Tokenizer().
|
private |
Referenced by nextToken(), Tokenizer(), and Tokenizer().