Make Tokenizers movable
This commit is contained in:
@ -37,6 +37,12 @@ Tokenizer::Tokenizer(const std::string & str, const std::string & seperators) {
|
|||||||
} while(end != std::string::npos);
|
} while(end != std::string::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tokenizer::Tokenizer(const Tokenizer & rhs) : tokens(rhs.tokens) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Tokenizer::Tokenizer(Tokenizer && rhs) : tokens(std::move(rhs.tokens)) {
|
||||||
|
}
|
||||||
|
|
||||||
Tokenizer::iterator Tokenizer::begin() {
|
Tokenizer::iterator Tokenizer::begin() {
|
||||||
return tokens.begin();
|
return tokens.begin();
|
||||||
}
|
}
|
||||||
@ -66,6 +72,14 @@ ValueTokenizer::ValueTokenizer(const std::string & str, const std::string & sepe
|
|||||||
current = tokens.begin();
|
current = tokens.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ValueTokenizer::ValueTokenizer(const ValueTokenizer & rhs) : tokens(rhs.tokens) {
|
||||||
|
current = tokens.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueTokenizer::ValueTokenizer(ValueTokenizer && rhs) : tokens(std::move(rhs.tokens)) {
|
||||||
|
current = tokens.begin();
|
||||||
|
}
|
||||||
|
|
||||||
bool ValueTokenizer::has_next() const {
|
bool ValueTokenizer::has_next() const {
|
||||||
return current != tokens.cend();
|
return current != tokens.cend();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,13 +25,19 @@
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
|
#define TOKENIZER_DEFAULT_SEPERATORS " \t\r\n\f"
|
||||||
|
|
||||||
class Tokenizer {
|
class Tokenizer {
|
||||||
std::vector<std::string> tokens;
|
std::vector<std::string> tokens;
|
||||||
public:
|
public:
|
||||||
typedef std::vector<std::string>::iterator iterator;
|
typedef std::vector<std::string>::iterator iterator;
|
||||||
typedef std::vector<std::string>::const_iterator const_iterator;
|
typedef std::vector<std::string>::const_iterator const_iterator;
|
||||||
|
|
||||||
Tokenizer(const std::string & str, const std::string & seperators = " \t\r\n\f");
|
Tokenizer(const std::string & str, const std::string & seperators = TOKENIZER_DEFAULT_SEPERATORS);
|
||||||
|
Tokenizer(Tokenizer &&);
|
||||||
|
Tokenizer(const Tokenizer &);
|
||||||
|
Tokenizer& operator=(const Tokenizer&) = default;
|
||||||
|
Tokenizer& operator=(Tokenizer&&) = default;
|
||||||
|
|
||||||
iterator begin();
|
iterator begin();
|
||||||
iterator end();
|
iterator end();
|
||||||
@ -72,7 +78,11 @@ class ValueTokenizer {
|
|||||||
Tokenizer tokens;
|
Tokenizer tokens;
|
||||||
Tokenizer::const_iterator current;
|
Tokenizer::const_iterator current;
|
||||||
public:
|
public:
|
||||||
ValueTokenizer(const std::string & str, const std::string & seperators = " \t\r\n\f");
|
ValueTokenizer(const std::string & str, const std::string & seperators = TOKENIZER_DEFAULT_SEPERATORS);
|
||||||
|
ValueTokenizer(const ValueTokenizer &);
|
||||||
|
ValueTokenizer(ValueTokenizer &&);
|
||||||
|
ValueTokenizer& operator=(const ValueTokenizer&) = default;
|
||||||
|
ValueTokenizer& operator=(ValueTokenizer&&) = default;
|
||||||
|
|
||||||
std::string next_string();
|
std::string next_string();
|
||||||
tagint next_tagint();
|
tagint next_tagint();
|
||||||
|
|||||||
Reference in New Issue
Block a user