Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Side by Side Diff: base/strings/string_tokenizer.h

Issue 12087091: Move string tokenizer to base/strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_STRING_TOKENIZER_H_ 5 #ifndef BASE_STRINGS_STRING_TOKENIZER_H_
6 #define BASE_STRING_TOKENIZER_H_ 6 #define BASE_STRINGS_STRING_TOKENIZER_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 10
11 #include "base/string_piece.h" 11 #include "base/string_piece.h"
12 12
13 namespace base {
14
13 // StringTokenizerT is a simple string tokenizer class. It works like an 15 // StringTokenizerT is a simple string tokenizer class. It works like an
14 // iterator that with each step (see the Advance method) updates members that 16 // iterator that with each step (see the Advance method) updates members that
15 // refer to the next token in the input string. The user may optionally 17 // refer to the next token in the input string. The user may optionally
16 // configure the tokenizer to return delimiters. 18 // configure the tokenizer to return delimiters.
17 // 19 //
18 // Warning: be careful not to pass a C string into the 2-arg constructor: 20 // Warning: be careful not to pass a C string into the 2-arg constructor:
19 // StringTokenizer t("this is a test", " "); // WRONG 21 // StringTokenizer t("this is a test", " "); // WRONG
20 // This will create a temporary std::string, save the begin() and end() 22 // This will create a temporary std::string, save the begin() and end()
21 // iterators, and then the string will be freed before we actually start 23 // iterators, and then the string will be freed before we actually start
22 // tokenizing it. 24 // tokenizing it.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 int options_; 248 int options_;
247 bool token_is_delim_; 249 bool token_is_delim_;
248 }; 250 };
249 251
250 typedef StringTokenizerT<std::string, std::string::const_iterator> 252 typedef StringTokenizerT<std::string, std::string::const_iterator>
251 StringTokenizer; 253 StringTokenizer;
252 typedef StringTokenizerT<std::wstring, std::wstring::const_iterator> 254 typedef StringTokenizerT<std::wstring, std::wstring::const_iterator>
253 WStringTokenizer; 255 WStringTokenizer;
254 typedef StringTokenizerT<std::string, const char*> CStringTokenizer; 256 typedef StringTokenizerT<std::string, const char*> CStringTokenizer;
255 257
256 #endif // BASE_STRING_TOKENIZER_H_ 258 } // namespace base
259
260 #endif // BASE_STRINGS_STRING_TOKENIZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698