This class abstracts the input line in tokens. More...
#include <TokenizedLine.h>
Classes | |
| struct | presentAndFound |
Public Types | |
| using | line = std::vector<std::string> |
| using | mapType = std::map<std::string,line,std::less<void>> |
Public Member Functions | |
| TokenizedLine (const std::vector< std::string > &) | |
| Initializer from a vector of strings (ideally the output of getWords) | |
| TokenizedLine (const_vectorIt begin, const_vectorIt end) | |
| Initializer from vector iterators. | |
| TokenizedLine (vectorIt begin, vectorIt end) | |
| Initializer from vector iterators. | |
| std::string | convertToString (bool alsoClear) |
| return a plain string with the all the current KEY=value combinations, it is possible to clear the tokens after that | |
| bool | empty () const |
| Returns true if the underlying container is empty. | |
| std::string | getKeyword (std::string_view key) const |
| return a keyword and its argument | |
| std::string | getValue (std::string_view key, int rep=-1) const |
| return the value of the asked key, "" otherwise; | |
| std::string | keyList (std::string_view sep=", ") |
| returns the list of the keys: | |
| template<typename T> | |
| presentAndFound | readAndRemove (std::string_view key, T &value, int rep=-1) |
| Read a value from the tokens and remove it from the list. | |
| bool | readAndRemoveFlag (std::string_view key) |
| return true if the flag is present and removes it from the tokens | |
| template<typename T> | |
| presentAndFound | readAndRemoveVector (std::string_view key, std::vector< T > &value, int rep=-1) |
| Read a list of values from the tokens and remove it from the list. | |
| std::size_t | size () const |
| Return the size of the underlying container;. | |
Static Public Member Functions | |
| static std::string_view | replica (const line &, int rep=-1) |
Private Types | |
| using | const_vectorIt = typename std::vector<std::string>::const_iterator |
| using | vectorIt = typename std::vector<std::string>::iterator |
Private Attributes | |
| mapType | tokens |
This class abstracts the input line in tokens.
The underlying container accelerates the lookup for the keywords ISSUE: In case of a vector keyword and the use of the '@replicas:' idiom: If the user wants to chante only the FIRS element of the vector with @replica the parse will interpret the whole string as a replica string There are no problem with @replicas: applied on other components:
|
private |
| using PLMD::TokenizedLine::line = std::vector<std::string> |
| using PLMD::TokenizedLine::mapType = std::map<std::string,line,std::less<void>> |
|
private |
Initializer from vector iterators.
| PLMD::TokenizedLine::TokenizedLine | ( | const_vectorIt | begin, |
| const_vectorIt | end ) |
Initializer from vector iterators.
| PLMD::TokenizedLine::TokenizedLine | ( | const std::vector< std::string > & | dataline | ) |
Initializer from a vector of strings (ideally the output of getWords)
| std::string PLMD::TokenizedLine::convertToString | ( | bool | alsoClear | ) |
return a plain string with the all the current KEY=value combinations, it is possible to clear the tokens after that
| bool PLMD::TokenizedLine::empty | ( | ) | const |
Returns true if the underlying container is empty.
| std::string PLMD::TokenizedLine::getKeyword | ( | std::string_view | key | ) | const |
return a keyword and its argument
| std::string PLMD::TokenizedLine::getValue | ( | std::string_view | key, |
| int | rep = -1 ) const |
return the value of the asked key, "" otherwise;
| std::string PLMD::TokenizedLine::keyList | ( | std::string_view | sep = ", " | ) |
returns the list of the keys:
| TokenizedLine::presentAndFound PLMD::TokenizedLine::readAndRemove | ( | std::string_view | key, |
| T & | value, | ||
| int | rep = -1 ) |
Read a value from the tokens and remove it from the list.
| bool PLMD::TokenizedLine::readAndRemoveFlag | ( | std::string_view | key | ) |
return true if the flag is present and removes it from the tokens
| TokenizedLine::presentAndFound PLMD::TokenizedLine::readAndRemoveVector | ( | std::string_view | key, |
| std::vector< T > & | value, | ||
| int | rep = -1 ) |
Read a list of values from the tokens and remove it from the list.
|
static |
| std::size_t PLMD::TokenizedLine::size | ( | ) | const |
Return the size of the underlying container;.
|
private |
Hosted by GitHub
|
1.13.2
|