UtilsLite
Utilities for C++ programming
Loading...
Searching...
No Matches
Token.hxx
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*\
2 | |
3 | Copyright (C) 2017 |
4 | |
5 | , __ , __ |
6 | /|/ \ /|/ \ |
7 | | __/ _ ,_ | __/ _ ,_ |
8 | | \|/ / | | | | \|/ / | | | |
9 | |(__/|__/ |_/ \_/|/|(__/|__/ |_/ \_/|/ |
10 | /| /| |
11 | \| \| |
12 | |
13 | Enrico Bertolazzi |
14 | Dipartimento di Ingegneria Industriale |
15 | Università degli Studi di Trento |
16 | email: enrico.bertolazzi@unitn.it |
17 | |
18\*--------------------------------------------------------------------------*/
19
20//
21// file: Token.hxx
22//
23
24//
25// https://stackoverflow.com/questions/53849/how-do-i-tokenize-a-string-in-c
26//
27
28namespace Utils {
29
30 using std::size_t;
31 using std::string;
32 using std::vector;
33
38
55 class Tokenizer {
56 protected:
57 size_t m_offset;
58 string const m_string;
59 string m_token;
60 string const m_delimiters;
61 public:
69 string str,
70 string delimiters
71 )
72 : m_offset(0)
73 , m_string(std::move(str))
74 , m_delimiters(std::move(delimiters))
75 { }
76
82 string const & get_token() const { return m_token; }
83
94 bool next_token();
95 };
96
110 void
112 string const & str,
113 string const & sep,
114 vector<string> & arr
115 );
116
118
119}
120
121//
122// eof: Token.hxx
123//
string const m_delimiters
Characters used to separate tokens.
Definition Token.hxx:60
Tokenizer(string str, string delimiters)
Definition Token.hxx:68
size_t m_offset
Current position in the string.
Definition Token.hxx:57
string const m_string
The original string to tokenize.
Definition Token.hxx:58
string const & get_token() const
Definition Token.hxx:82
string m_token
The current token extracted.
Definition Token.hxx:59
void split_string(string const &str, string const &sep, vector< string > &arr)
Definition SystemUtils.cc:39