| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_STRING_UTIL_H_ | 7 #ifndef BASE_STRING_UTIL_H_ |
| 8 #define BASE_STRING_UTIL_H_ | 8 #define BASE_STRING_UTIL_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 #include <stdarg.h> // va_list | 12 #include <stdarg.h> // va_list |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/string16.h" | 15 #include "base/string16.h" |
| 16 | 16 |
| 17 // Safe standard library wrappers for all platforms. | 17 // Safe standard library wrappers for all platforms. |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 | 20 |
| 21 // C standard-library functions like "strncasecmp" and "snprintf" that aren't | 21 // C standard-library functions like "strncasecmp" and "snprintf" that aren't |
| 22 // cross-platform are provided as "base::strncasecmp", and their prototypes | 22 // cross-platform are provided as "base::strncasecmp", and their prototypes |
| 23 // are listed below. These functions are then implemented as inline calls | 23 // are listed below. These functions are then implemented as inline calls |
| 24 // to the platform-specific equivalents in the platform-specific headers. | 24 // to the platform-specific equivalents in the platform-specific headers. |
| 25 | 25 |
| 26 // Compare the two strings s1 and s2 without regard to case using |
| 27 // the current locale; returns 0 if they are equal, 1 if s1 > s2, and -1 if |
| 28 // s2 > s1 according to a lexicographic comparison. |
| 29 int strcasecmp(const char* s1, const char* s2); |
| 30 |
| 26 // Compare up to count characters of s1 and s2 without regard to case using | 31 // Compare up to count characters of s1 and s2 without regard to case using |
| 27 // the current locale; returns 0 if they are equal, 1 if s1 > s2, and -1 if | 32 // the current locale; returns 0 if they are equal, 1 if s1 > s2, and -1 if |
| 28 // s2 > s1 according to a lexicographic comparison. | 33 // s2 > s1 according to a lexicographic comparison. |
| 29 int strncasecmp(const char* s1, const char* s2, size_t count); | 34 int strncasecmp(const char* s1, const char* s2, size_t count); |
| 30 | 35 |
| 31 // Wrapper for vsnprintf that always null-terminates and always returns the | 36 // Wrapper for vsnprintf that always null-terminates and always returns the |
| 32 // number of characters that would be in an untruncated formatted | 37 // number of characters that would be in an untruncated formatted |
| 33 // string, even when truncation occurs. | 38 // string, even when truncation occurs. |
| 34 int vsnprintf(char* buffer, size_t size, const char* format, va_list arguments); | 39 int vsnprintf(char* buffer, size_t size, const char* format, va_list arguments); |
| 35 | 40 |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 // Returns true if the string passed in matches the pattern. The pattern | 511 // Returns true if the string passed in matches the pattern. The pattern |
| 507 // string can contain wildcards like * and ? | 512 // string can contain wildcards like * and ? |
| 508 // TODO(iyengar) This function may not work correctly for CJK strings as | 513 // TODO(iyengar) This function may not work correctly for CJK strings as |
| 509 // it does individual character matches. | 514 // it does individual character matches. |
| 510 // The backslash character (\) is an escape character for * and ? | 515 // The backslash character (\) is an escape character for * and ? |
| 511 bool MatchPattern(const std::wstring& string, const std::wstring& pattern); | 516 bool MatchPattern(const std::wstring& string, const std::wstring& pattern); |
| 512 bool MatchPattern(const std::string& string, const std::string& pattern); | 517 bool MatchPattern(const std::string& string, const std::string& pattern); |
| 513 | 518 |
| 514 #endif // BASE_STRING_UTIL_H_ | 519 #endif // BASE_STRING_UTIL_H_ |
| 515 | 520 |
| OLD | NEW |