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

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

Issue 1215933004: New new versions of Starts/EndsWith and SplitString in net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@starts_with
Patch Set: Created 5 years, 5 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/strings/string_split.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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 BASE_EXPORT StringPiece TrimString(StringPiece input, 199 BASE_EXPORT StringPiece TrimString(StringPiece input,
200 const base::StringPiece& trim_chars, 200 const base::StringPiece& trim_chars,
201 TrimPositions positions); 201 TrimPositions positions);
202 202
203 // Truncates a string to the nearest UTF-8 character that will leave 203 // Truncates a string to the nearest UTF-8 character that will leave
204 // the string less than or equal to the specified byte size. 204 // the string less than or equal to the specified byte size.
205 BASE_EXPORT void TruncateUTF8ToByteSize(const std::string& input, 205 BASE_EXPORT void TruncateUTF8ToByteSize(const std::string& input,
206 const size_t byte_size, 206 const size_t byte_size,
207 std::string* output); 207 std::string* output);
208 208
209 // Trims any whitespace from either end of the input string. Returns where 209 // Trims any whitespace from either end of the input string.
210 // whitespace was found. 210 //
211 // The non-wide version has two functions: 211 // The StringPiece versions return a substring referencing the input buffer.
212 // * TrimWhitespaceASCII() 212 // The ASCII versions look only for ASCII whitespace.
213 // This function is for ASCII strings and only looks for ASCII whitespace; 213 //
214 // Please choose the best one according to your usage. 214 // The std::string versions return where whitespace was found.
215 // NOTE: Safe to use the same variable for both input and output. 215 // NOTE: Safe to use the same variable for both input and output.
216 BASE_EXPORT TrimPositions TrimWhitespace(const string16& input, 216 BASE_EXPORT TrimPositions TrimWhitespace(const string16& input,
217 TrimPositions positions, 217 TrimPositions positions,
218 base::string16* output); 218 base::string16* output);
219 BASE_EXPORT StringPiece16 TrimWhitespace(StringPiece16 input,
220 TrimPositions positions);
219 BASE_EXPORT TrimPositions TrimWhitespaceASCII(const std::string& input, 221 BASE_EXPORT TrimPositions TrimWhitespaceASCII(const std::string& input,
220 TrimPositions positions, 222 TrimPositions positions,
221 std::string* output); 223 std::string* output);
224 BASE_EXPORT StringPiece TrimWhitespaceASCII(StringPiece input,
225 TrimPositions positions);
222 226
223 // Deprecated. This function is only for backward compatibility and calls 227 // Deprecated. This function is only for backward compatibility and calls
224 // TrimWhitespaceASCII(). 228 // TrimWhitespaceASCII().
225 BASE_EXPORT TrimPositions TrimWhitespace(const std::string& input, 229 BASE_EXPORT TrimPositions TrimWhitespace(const std::string& input,
226 TrimPositions positions, 230 TrimPositions positions,
227 std::string* output); 231 std::string* output);
228 232
229 // Searches for CR or LF characters. Removes all contiguous whitespace 233 // Searches for CR or LF characters. Removes all contiguous whitespace
230 // strings that contain them. This is useful when trying to deal with text 234 // strings that contain them. This is useful when trying to deal with text
231 // copied from terminals. 235 // copied from terminals.
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 // string can contain wildcards like * and ? 546 // string can contain wildcards like * and ?
543 // The backslash character (\) is an escape character for * and ? 547 // The backslash character (\) is an escape character for * and ?
544 // We limit the patterns to having a max of 16 * or ? characters. 548 // We limit the patterns to having a max of 16 * or ? characters.
545 // ? matches 0 or 1 character, while * matches 0 or more characters. 549 // ? matches 0 or 1 character, while * matches 0 or more characters.
546 BASE_EXPORT bool MatchPattern(const base::StringPiece& string, 550 BASE_EXPORT bool MatchPattern(const base::StringPiece& string,
547 const base::StringPiece& pattern); 551 const base::StringPiece& pattern);
548 BASE_EXPORT bool MatchPattern(const base::string16& string, 552 BASE_EXPORT bool MatchPattern(const base::string16& string,
549 const base::string16& pattern); 553 const base::string16& pattern);
550 554
551 #endif // BASE_STRINGS_STRING_UTIL_H_ 555 #endif // BASE_STRINGS_STRING_UTIL_H_
OLDNEW
« no previous file with comments | « base/strings/string_split.cc ('k') | base/strings/string_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698