@@ -146,65 +146,66 @@ int get_pid();
146
146
* It can accept different delimiters in splitting strings
147
147
*/
148
148
class StringToken {
149
- public: /* Constructors*/
150
- StringToken (const std::string& data);
151
-
152
- StringToken (std::string_view data);
153
-
154
- StringToken (const char * data);
155
-
156
- public: /* Public Accessors */
157
- std::string data () const ;
158
- /* *
159
- * @brief Splits the string 'text' along the specified delimiter characters in 'delims'
160
- *
161
- * The split strings (excluding the delimiters) are returned
162
- */
163
- std::vector<std::string> split (const std::string& delims) const ;
164
- std::vector<std::string> split (const char & delim) const ;
165
- std::vector<std::string> split (const char * delim) const ;
166
- std::vector<std::string> split (const std::vector<char >& delim) const ;
167
- std::vector<std::string> split ();
168
- /* *
169
- * @brief Find the position (i-th charactor) in a string for a given
170
- * delimiter, it will return a list of positions For example, to find the
171
- * position of all quotes (") in a string: "we" are good The following code is
172
- * suggested: StringToken tokenizer("\"we\" are good"); std::vector<size_t>
173
- * anchors = tokenizer.find_positions('\"') The following vector will be
174
- * returned: [0, 3]
175
- */
176
- std::vector<size_t > find_positions (const char & delim) const ;
177
-
178
- /* *
179
- * @brief split the string for each chunk. This is useful where there are
180
- * chunks of substring should not be splitted by the given delimiter For
181
- * example, to split the string with quotes (") in a string: source "cmdA
182
- * --opt1 val1;cmdB --opt2 val2" --verbose where the string between the two
183
- * quotes should not be splitted The following code is suggested: StringToken
184
- * tokenizer("source \"cmdA --opt1 val1;cmdB --opt2 val2\" --verbose");
185
- * std::vector<std::string> tokenizer.split_by_chunks('\"', true);
186
- * The following vector will be returned:
187
- * ["source" "cmdA --opt1 val1;cmdB --opt2 val2" "--verbose"]
188
- *
189
- * .. note:: The option ``split_odd_chunk`` is useful when the chunk delimiter
190
- * appears at the beginning of the string.
191
- */
192
- std::vector<std::string> split_by_chunks (
193
- const char & chunk_delim, const bool & split_odd_chunk = false ) const ;
194
-
195
- public: /* Public Mutators */
196
- void set_data (const std::string& data);
197
- void add_delim (const char & delim);
198
- void ltrim (const std::string& sensitive_word);
199
- void rtrim (const std::string& sensitive_word);
200
- void trim ();
201
-
202
- private: /* Private Mutators */
203
- void add_default_delim ();
204
-
205
- private: /* Internal data */
206
- std::string data_; /* Lines to be splited */
207
- std::vector<char > delims_;
149
+ public: /* Constructors*/
150
+ StringToken (const std::string& data);
151
+
152
+ StringToken (std::string_view data);
153
+
154
+ StringToken (const char * data);
155
+
156
+ public: /* Public Accessors */
157
+ std::string data () const ;
158
+ /* *
159
+ * @brief Splits the string 'text' along the specified delimiter characters in 'delims'
160
+ *
161
+ * The split strings (excluding the delimiters) are returned
162
+ */
163
+ std::vector<std::string> split (const std::string& delims) const ;
164
+ std::vector<std::string> split (const char & delim) const ;
165
+ std::vector<std::string> split (const char * delim) const ;
166
+ std::vector<std::string> split (const std::vector<char >& delim) const ;
167
+ std::vector<std::string> split ();
168
+ /* *
169
+ * @brief Find the position (i-th charactor) in a string for a given
170
+ * delimiter, it will return a list of positions For example, to find the
171
+ * position of all quotes (") in a string: "we" are good The following code is
172
+ * suggested: StringToken tokenizer("\"we\" are good"); std::vector<size_t>
173
+ * anchors = tokenizer.find_positions('\"') The following vector will be
174
+ * returned: [0, 3]
175
+ */
176
+ std::vector<size_t > find_positions (const char & delim) const ;
177
+
178
+ /* *
179
+ * @brief split the string for each chunk. This is useful where there are
180
+ * chunks of substring should not be splitted by the given delimiter For
181
+ * example, to split the string with quotes (") in a string: source "cmdA
182
+ * --opt1 val1;cmdB --opt2 val2" --verbose where the string between the two
183
+ * quotes should not be splitted The following code is suggested: StringToken
184
+ * tokenizer("source \"cmdA --opt1 val1;cmdB --opt2 val2\" --verbose");
185
+ * std::vector<std::string> tokenizer.split_by_chunks('\"', true);
186
+ * The following vector will be returned:
187
+ * ["source" "cmdA --opt1 val1;cmdB --opt2 val2" "--verbose"]
188
+ *
189
+ * .. note:: The option ``split_odd_chunk`` is useful when the chunk delimiter
190
+ * appears at the beginning of the string.
191
+ */
192
+ std::vector<std::string> split_by_chunks (
193
+ const char & chunk_delim,
194
+ const bool & split_odd_chunk = false ) const ;
195
+
196
+ public: /* Public Mutators */
197
+ void set_data (const std::string& data);
198
+ void add_delim (const char & delim);
199
+ void ltrim (const std::string& sensitive_word);
200
+ void rtrim (const std::string& sensitive_word);
201
+ void trim ();
202
+
203
+ private: /* Private Mutators */
204
+ void add_default_delim ();
205
+
206
+ private: /* Internal data */
207
+ std::string data_; /* Lines to be splited */
208
+ std::vector<char > delims_;
208
209
};
209
210
210
211
} // namespace vtr
0 commit comments