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

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

Issue 1172753003: Move LowerCaseEqualsASCII to base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util
Patch Set: Created 5 years, 6 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
« no previous file with comments | « base/files/file_util_unittest.cc ('k') | base/strings/string_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // This file defines utility functions for working with strings. 5 // This file defines utility functions for working with strings.
6 6
7 #ifndef BASE_STRINGS_STRING_UTIL_H_ 7 #ifndef BASE_STRINGS_STRING_UTIL_H_
8 #define BASE_STRINGS_STRING_UTIL_H_ 8 #define BASE_STRINGS_STRING_UTIL_H_
9 9
10 #include <ctype.h> 10 #include <ctype.h>
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 for (typename str::iterator i = s->begin(); i != s->end(); ++i) 278 for (typename str::iterator i = s->begin(); i != s->end(); ++i)
279 *i = ToUpperASCII(*i); 279 *i = ToUpperASCII(*i);
280 } 280 }
281 281
282 template <class str> inline str StringToUpperASCII(const str& s) { 282 template <class str> inline str StringToUpperASCII(const str& s) {
283 // for std::string and std::wstring 283 // for std::string and std::wstring
284 str output(s); 284 str output(s);
285 StringToUpperASCII(&output); 285 StringToUpperASCII(&output);
286 return output; 286 return output;
287 } 287 }
288 //
289 // Compare the lower-case form of the given string against the given ASCII
290 // string. This is useful for doing checking if an input string matches some
291 // token, and it is optimized to avoid intermediate string copies. This API is
292 // borrowed from the equivalent APIs in Mozilla.
293 BASE_EXPORT bool LowerCaseEqualsASCII(const std::string& a, const char* b);
294 BASE_EXPORT bool LowerCaseEqualsASCII(const string16& a, const char* b);
295
296 // Same thing, but with string iterators instead.
297 BASE_EXPORT bool LowerCaseEqualsASCII(std::string::const_iterator a_begin,
298 std::string::const_iterator a_end,
299 const char* b);
300 BASE_EXPORT bool LowerCaseEqualsASCII(string16::const_iterator a_begin,
301 string16::const_iterator a_end,
302 const char* b);
303 BASE_EXPORT bool LowerCaseEqualsASCII(const char* a_begin,
304 const char* a_end,
305 const char* b);
306 BASE_EXPORT bool LowerCaseEqualsASCII(const char* a_begin,
307 const char* a_end,
308 const char* b_begin,
309 const char* b_end);
310 BASE_EXPORT bool LowerCaseEqualsASCII(const char16* a_begin,
311 const char16* a_end,
312 const char* b);
288 313
289 } // namespace base 314 } // namespace base
290 315
291 #if defined(OS_WIN) 316 #if defined(OS_WIN)
292 #include "base/strings/string_util_win.h" 317 #include "base/strings/string_util_win.h"
293 #elif defined(OS_POSIX) 318 #elif defined(OS_POSIX)
294 #include "base/strings/string_util_posix.h" 319 #include "base/strings/string_util_posix.h"
295 #else 320 #else
296 #error Define string operations appropriately for your platform 321 #error Define string operations appropriately for your platform
297 #endif 322 #endif
298 323
299 // Compare the lower-case form of the given string against the given ASCII
300 // string. This is useful for doing checking if an input string matches some
301 // token, and it is optimized to avoid intermediate string copies. This API is
302 // borrowed from the equivalent APIs in Mozilla.
303 BASE_EXPORT bool LowerCaseEqualsASCII(const std::string& a, const char* b);
304 BASE_EXPORT bool LowerCaseEqualsASCII(const base::string16& a, const char* b);
305
306 // Same thing, but with string iterators instead.
307 BASE_EXPORT bool LowerCaseEqualsASCII(std::string::const_iterator a_begin,
308 std::string::const_iterator a_end,
309 const char* b);
310 BASE_EXPORT bool LowerCaseEqualsASCII(base::string16::const_iterator a_begin,
311 base::string16::const_iterator a_end,
312 const char* b);
313 BASE_EXPORT bool LowerCaseEqualsASCII(const char* a_begin,
314 const char* a_end,
315 const char* b);
316 BASE_EXPORT bool LowerCaseEqualsASCII(const base::char16* a_begin,
317 const base::char16* a_end,
318 const char* b);
319
320 // Performs a case-sensitive string compare. The behavior is undefined if both 324 // Performs a case-sensitive string compare. The behavior is undefined if both
321 // strings are not ASCII. 325 // strings are not ASCII.
322 BASE_EXPORT bool EqualsASCII(const base::string16& a, const base::StringPiece& b ); 326 BASE_EXPORT bool EqualsASCII(const base::string16& a, const base::StringPiece& b );
323 327
324 // Returns true if str starts with search, or false otherwise. 328 // Returns true if str starts with search, or false otherwise.
325 BASE_EXPORT bool StartsWithASCII(const std::string& str, 329 BASE_EXPORT bool StartsWithASCII(const std::string& str,
326 const std::string& search, 330 const std::string& search,
327 bool case_sensitive); 331 bool case_sensitive);
328 BASE_EXPORT bool StartsWith(const base::string16& str, 332 BASE_EXPORT bool StartsWith(const base::string16& str,
329 const base::string16& search, 333 const base::string16& search,
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 #elif defined(WCHAR_T_IS_UTF32) 527 #elif defined(WCHAR_T_IS_UTF32)
524 typedef uint32 Unsigned; 528 typedef uint32 Unsigned;
525 #endif 529 #endif
526 }; 530 };
527 template<> 531 template<>
528 struct ToUnsigned<short> { 532 struct ToUnsigned<short> {
529 typedef unsigned short Unsigned; 533 typedef unsigned short Unsigned;
530 }; 534 };
531 535
532 #endif // BASE_STRINGS_STRING_UTIL_H_ 536 #endif // BASE_STRINGS_STRING_UTIL_H_
OLDNEW
« no previous file with comments | « base/files/file_util_unittest.cc ('k') | base/strings/string_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698