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

Side by Side Diff: base/string_util.h

Issue 28180: Reverting 10456. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 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 <string> 10 #include <string>
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // Removes characters in trim_chars from the beginning and end of input. 121 // Removes characters in trim_chars from the beginning and end of input.
122 // NOTE: Safe to use the same variable for both input and output. 122 // NOTE: Safe to use the same variable for both input and output.
123 bool TrimString(const std::wstring& input, 123 bool TrimString(const std::wstring& input,
124 const wchar_t trim_chars[], 124 const wchar_t trim_chars[],
125 std::wstring* output); 125 std::wstring* output);
126 bool TrimString(const std::string& input, 126 bool TrimString(const std::string& input,
127 const char trim_chars[], 127 const char trim_chars[],
128 std::string* output); 128 std::string* output);
129 129
130 // Trims any whitespace from either end of the input string. Returns where 130 // Trims any whitespace from either end of the input string. Returns where
131 // whitespace was found. 131 // whitespace was found. The non-wide version of this function only looks for
132 // The non-wide version has two functions: 132 // ASCII whitespace; UTF-8 code-points are not searched for (use the wide
133 // * TrimWhitespaceASCII() 133 // version instead).
134 // This function is for ASCII strings and only looks for ASCII whitespace;
135 // * TrimWhitespaceUTF8()
136 // This function is for UTF-8 strings and looks for Unicode whitespace.
137 // Please choose the best one according to your usage.
138 // NOTE: Safe to use the same variable for both input and output. 134 // NOTE: Safe to use the same variable for both input and output.
139 enum TrimPositions { 135 enum TrimPositions {
140 TRIM_NONE = 0, 136 TRIM_NONE = 0,
141 TRIM_LEADING = 1 << 0, 137 TRIM_LEADING = 1 << 0,
142 TRIM_TRAILING = 1 << 1, 138 TRIM_TRAILING = 1 << 1,
143 TRIM_ALL = TRIM_LEADING | TRIM_TRAILING, 139 TRIM_ALL = TRIM_LEADING | TRIM_TRAILING,
144 }; 140 };
145 TrimPositions TrimWhitespace(const std::wstring& input, 141 TrimPositions TrimWhitespace(const std::wstring& input,
146 TrimPositions positions, 142 TrimPositions positions,
147 std::wstring* output); 143 std::wstring* output);
148 TrimPositions TrimWhitespaceASCII(const std::string& input,
149 TrimPositions positions,
150 std::string* output);
151 TrimPositions TrimWhitespaceUTF8(const std::string& input,
152 TrimPositions positions,
153 std::string* output);
154
155 // Deprecated. This function is only for backward compatibility and calls
156 // TrimWhitespaceASCII().
157 TrimPositions TrimWhitespace(const std::string& input, 144 TrimPositions TrimWhitespace(const std::string& input,
158 TrimPositions positions, 145 TrimPositions positions,
159 std::string* output); 146 std::string* output);
160 147
161 // Searches for CR or LF characters. Removes all contiguous whitespace 148 // Searches for CR or LF characters. Removes all contiguous whitespace
162 // strings that contain them. This is useful when trying to deal with text 149 // strings that contain them. This is useful when trying to deal with text
163 // copied from terminals. 150 // copied from terminals.
164 // Returns |text, with the following three transformations: 151 // Returns |text, with the following three transformations:
165 // (1) Leading and trailing whitespace is trimmed. 152 // (1) Leading and trailing whitespace is trimmed.
166 // (2) If |trim_sequences_with_line_breaks| is true, any other whitespace 153 // (2) If |trim_sequences_with_line_breaks| is true, any other whitespace
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 // Returns a hex string representation of a binary buffer. 566 // Returns a hex string representation of a binary buffer.
580 // The returned hex string will be in upper case. 567 // The returned hex string will be in upper case.
581 // This function does not check if |size| is within reasonable limits since 568 // This function does not check if |size| is within reasonable limits since
582 // it's written with trusted data in mind. 569 // it's written with trusted data in mind.
583 // If you suspect that the data you want to format might be large, 570 // If you suspect that the data you want to format might be large,
584 // the absolute max size for |size| should be is 571 // the absolute max size for |size| should be is
585 // std::numeric_limits<size_t>::max() / 2 572 // std::numeric_limits<size_t>::max() / 2
586 std::string HexEncode(const void* bytes, size_t size); 573 std::string HexEncode(const void* bytes, size_t size);
587 574
588 #endif // BASE_STRING_UTIL_H_ 575 #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