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

Side by Side Diff: url/url_canon_internal.h

Issue 250233002: Remove url::ReadUTFChar's dependency on icu. Use base instead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix include order Created 6 years, 7 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 | « url/url_canon_icu.cc ('k') | url/url_canon_internal.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 #ifndef URL_URL_CANON_INTERNAL_H_ 5 #ifndef URL_URL_CANON_INTERNAL_H_
6 #define URL_URL_CANON_INTERNAL_H_ 6 #define URL_URL_CANON_INTERNAL_H_
7 7
8 // This file is intended to be included in another C++ file where the character 8 // This file is intended to be included in another C++ file where the character
9 // types are defined. This allows us to write mostly generic code, but not have 9 // types are defined. This allows us to write mostly generic code, but not have
10 // templace bloat because everything is inlined when anybody calls any of our 10 // templace bloat because everything is inlined when anybody calls any of our
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // UTF-8 functions ------------------------------------------------------------ 141 // UTF-8 functions ------------------------------------------------------------
142 142
143 // Reads one character in UTF-8 starting at |*begin| in |str| and places 143 // Reads one character in UTF-8 starting at |*begin| in |str| and places
144 // the decoded value into |*code_point|. If the character is valid, we will 144 // the decoded value into |*code_point|. If the character is valid, we will
145 // return true. If invalid, we'll return false and put the 145 // return true. If invalid, we'll return false and put the
146 // kUnicodeReplacementCharacter into |*code_point|. 146 // kUnicodeReplacementCharacter into |*code_point|.
147 // 147 //
148 // |*begin| will be updated to point to the last character consumed so it 148 // |*begin| will be updated to point to the last character consumed so it
149 // can be incremented in a loop and will be ready for the next character. 149 // can be incremented in a loop and will be ready for the next character.
150 // (for a single-byte ASCII character, it will not be changed). 150 // (for a single-byte ASCII character, it will not be changed).
151 //
152 // Implementation is in url_canon_icu.cc.
153 URL_EXPORT bool ReadUTFChar(const char* str, int* begin, int length, 151 URL_EXPORT bool ReadUTFChar(const char* str, int* begin, int length,
154 unsigned* code_point_out); 152 unsigned* code_point_out);
155 153
156 // Generic To-UTF-8 converter. This will call the given append method for each 154 // Generic To-UTF-8 converter. This will call the given append method for each
157 // character that should be appended, with the given output method. Wrappers 155 // character that should be appended, with the given output method. Wrappers
158 // are provided below for escaped and non-escaped versions of this. 156 // are provided below for escaped and non-escaped versions of this.
159 // 157 //
160 // The char_value must have already been checked that it's a valid Unicode 158 // The char_value must have already been checked that it's a valid Unicode
161 // character. 159 // character.
162 template<class Output, void Appender(unsigned char, Output*)> 160 template<class Output, void Appender(unsigned char, Output*)>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // UTF-16 functions ----------------------------------------------------------- 216 // UTF-16 functions -----------------------------------------------------------
219 217
220 // Reads one character in UTF-16 starting at |*begin| in |str| and places 218 // Reads one character in UTF-16 starting at |*begin| in |str| and places
221 // the decoded value into |*code_point|. If the character is valid, we will 219 // the decoded value into |*code_point|. If the character is valid, we will
222 // return true. If invalid, we'll return false and put the 220 // return true. If invalid, we'll return false and put the
223 // kUnicodeReplacementCharacter into |*code_point|. 221 // kUnicodeReplacementCharacter into |*code_point|.
224 // 222 //
225 // |*begin| will be updated to point to the last character consumed so it 223 // |*begin| will be updated to point to the last character consumed so it
226 // can be incremented in a loop and will be ready for the next character. 224 // can be incremented in a loop and will be ready for the next character.
227 // (for a single-16-bit-word character, it will not be changed). 225 // (for a single-16-bit-word character, it will not be changed).
228 //
229 // Implementation is in url_canon_icu.cc.
230 URL_EXPORT bool ReadUTFChar(const base::char16* str, int* begin, int length, 226 URL_EXPORT bool ReadUTFChar(const base::char16* str, int* begin, int length,
231 unsigned* code_point); 227 unsigned* code_point_out);
232 228
233 // Equivalent to U16_APPEND_UNSAFE in ICU but uses our output method. 229 // Equivalent to U16_APPEND_UNSAFE in ICU but uses our output method.
234 inline void AppendUTF16Value(unsigned code_point, 230 inline void AppendUTF16Value(unsigned code_point,
235 CanonOutputT<base::char16>* output) { 231 CanonOutputT<base::char16>* output) {
236 if (code_point > 0xffff) { 232 if (code_point > 0xffff) {
237 output->push_back(static_cast<base::char16>((code_point >> 10) + 0xd7c0)); 233 output->push_back(static_cast<base::char16>((code_point >> 10) + 0xd7c0));
238 output->push_back(static_cast<base::char16>((code_point & 0x3ff) | 0xdc00)); 234 output->push_back(static_cast<base::char16>((code_point & 0x3ff) | 0xdc00));
239 } else { 235 } else {
240 output->push_back(static_cast<base::char16>(code_point)); 236 output->push_back(static_cast<base::char16>(code_point));
241 } 237 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 inline unsigned long long _strtoui64(const char* nptr, 424 inline unsigned long long _strtoui64(const char* nptr,
429 char** endptr, int base) { 425 char** endptr, int base) {
430 return strtoull(nptr, endptr, base); 426 return strtoull(nptr, endptr, base);
431 } 427 }
432 428
433 #endif // WIN32 429 #endif // WIN32
434 430
435 } // namespace url 431 } // namespace url
436 432
437 #endif // URL_URL_CANON_INTERNAL_H_ 433 #endif // URL_URL_CANON_INTERNAL_H_
OLDNEW
« no previous file with comments | « url/url_canon_icu.cc ('k') | url/url_canon_internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698