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

Side by Side Diff: base/string_util.h

Issue 267100: Reverting 28993. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 2 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
« no previous file with comments | « no previous file | base/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 (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 <stdarg.h> // va_list 10 #include <stdarg.h> // va_list
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 // Returns a reference to a globally unique empty string that functions can 114 // Returns a reference to a globally unique empty string that functions can
115 // return. Use this to avoid static construction of strings, not to replace 115 // return. Use this to avoid static construction of strings, not to replace
116 // any and all uses of "std::string()" as nicer-looking sugar. 116 // any and all uses of "std::string()" as nicer-looking sugar.
117 // These functions are threadsafe. 117 // These functions are threadsafe.
118 const std::string& EmptyString(); 118 const std::string& EmptyString();
119 const std::wstring& EmptyWString(); 119 const std::wstring& EmptyWString();
120 const string16& EmptyString16(); 120 const string16& EmptyString16();
121 121
122 extern const wchar_t kWhitespaceWide[]; 122 extern const wchar_t kWhitespaceWide[];
123 extern const char16 kWhitespaceUTF16[];
124 extern const char kWhitespaceASCII[]; 123 extern const char kWhitespaceASCII[];
125 124
126 // Removes characters in trim_chars from the beginning and end of input. 125 // Removes characters in trim_chars from the beginning and end of input.
127 // NOTE: Safe to use the same variable for both input and output. 126 // NOTE: Safe to use the same variable for both input and output.
128 bool TrimString(const std::wstring& input, 127 bool TrimString(const std::wstring& input,
129 const wchar_t trim_chars[], 128 const wchar_t trim_chars[],
130 std::wstring* output); 129 std::wstring* output);
131 bool TrimString(const string16& input,
132 const char16 trim_chars[],
133 string16* output);
134 bool TrimString(const std::string& input, 130 bool TrimString(const std::string& input,
135 const char trim_chars[], 131 const char trim_chars[],
136 std::string* output); 132 std::string* output);
137 133
138 // Trims any whitespace from either end of the input string. Returns where 134 // Trims any whitespace from either end of the input string. Returns where
139 // whitespace was found. 135 // whitespace was found.
140 // The non-wide version has two functions: 136 // The non-wide version has two functions:
141 // * TrimWhitespaceASCII() 137 // * TrimWhitespaceASCII()
142 // This function is for ASCII strings and only looks for ASCII whitespace; 138 // This function is for ASCII strings and only looks for ASCII whitespace;
143 // Please choose the best one according to your usage. 139 // Please choose the best one according to your usage.
144 // NOTE: Safe to use the same variable for both input and output. 140 // NOTE: Safe to use the same variable for both input and output.
145 enum TrimPositions { 141 enum TrimPositions {
146 TRIM_NONE = 0, 142 TRIM_NONE = 0,
147 TRIM_LEADING = 1 << 0, 143 TRIM_LEADING = 1 << 0,
148 TRIM_TRAILING = 1 << 1, 144 TRIM_TRAILING = 1 << 1,
149 TRIM_ALL = TRIM_LEADING | TRIM_TRAILING, 145 TRIM_ALL = TRIM_LEADING | TRIM_TRAILING,
150 }; 146 };
151 TrimPositions TrimWhitespace(const std::wstring& input, 147 TrimPositions TrimWhitespace(const std::wstring& input,
152 TrimPositions positions, 148 TrimPositions positions,
153 std::wstring* output); 149 std::wstring* output);
154 TrimPositions TrimWhitespace(const string16& input,
155 TrimPositions positions,
156 string16* output);
157 TrimPositions TrimWhitespaceASCII(const std::string& input, 150 TrimPositions TrimWhitespaceASCII(const std::string& input,
158 TrimPositions positions, 151 TrimPositions positions,
159 std::string* output); 152 std::string* output);
160 153
161 // Deprecated. This function is only for backward compatibility and calls 154 // Deprecated. This function is only for backward compatibility and calls
162 // TrimWhitespaceASCII(). 155 // TrimWhitespaceASCII().
163 TrimPositions TrimWhitespace(const std::string& input, 156 TrimPositions TrimWhitespace(const std::string& input,
164 TrimPositions positions, 157 TrimPositions positions,
165 std::string* output); 158 std::string* output);
166 159
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 #elif defined(WCHAR_T_IS_UTF32) 574 #elif defined(WCHAR_T_IS_UTF32)
582 typedef uint32 Unsigned; 575 typedef uint32 Unsigned;
583 #endif 576 #endif
584 }; 577 };
585 template<> 578 template<>
586 struct ToUnsigned<short> { 579 struct ToUnsigned<short> {
587 typedef unsigned short Unsigned; 580 typedef unsigned short Unsigned;
588 }; 581 };
589 582
590 #endif // BASE_STRING_UTIL_H_ 583 #endif // BASE_STRING_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/string_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698