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

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

Issue 254983006: Fix: Adding list of supported codecs for MP4 containers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | base/strings/string_util.cc » ('j') | net/base/mime_util.cc » ('J')
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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // Note that IsStringUTF8 checks not only if the input is structurally 252 // Note that IsStringUTF8 checks not only if the input is structurally
253 // valid but also if it doesn't contain any non-character codepoint 253 // valid but also if it doesn't contain any non-character codepoint
254 // (e.g. U+FFFE). It's done on purpose because all the existing callers want 254 // (e.g. U+FFFE). It's done on purpose because all the existing callers want
255 // to have the maximum 'discriminating' power from other encodings. If 255 // to have the maximum 'discriminating' power from other encodings. If
256 // there's a use case for just checking the structural validity, we have to 256 // there's a use case for just checking the structural validity, we have to
257 // add a new function for that. 257 // add a new function for that.
258 BASE_EXPORT bool IsStringUTF8(const std::string& str); 258 BASE_EXPORT bool IsStringUTF8(const std::string& str);
259 BASE_EXPORT bool IsStringASCII(const base::StringPiece& str); 259 BASE_EXPORT bool IsStringASCII(const base::StringPiece& str);
260 BASE_EXPORT bool IsStringASCII(const base::string16& str); 260 BASE_EXPORT bool IsStringASCII(const base::string16& str);
261 261
262 BASE_EXPORT bool IsHigherCaseHexNumber(const std::string& number);
263
262 // Converts the elements of the given string. This version uses a pointer to 264 // Converts the elements of the given string. This version uses a pointer to
263 // clearly differentiate it from the non-pointer variant. 265 // clearly differentiate it from the non-pointer variant.
264 template <class str> inline void StringToLowerASCII(str* s) { 266 template <class str> inline void StringToLowerASCII(str* s) {
265 for (typename str::iterator i = s->begin(); i != s->end(); ++i) 267 for (typename str::iterator i = s->begin(); i != s->end(); ++i)
266 *i = base::ToLowerASCII(*i); 268 *i = base::ToLowerASCII(*i);
267 } 269 }
268 270
269 template <class str> inline str StringToLowerASCII(const str& s) { 271 template <class str> inline str StringToLowerASCII(const str& s) {
270 // for std::string and std::wstring 272 // for std::string and std::wstring
271 str output(s); 273 str output(s);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 347 }
346 348
347 template <typename Char> 349 template <typename Char>
348 inline bool IsHexDigit(Char c) { 350 inline bool IsHexDigit(Char c) {
349 return (c >= '0' && c <= '9') || 351 return (c >= '0' && c <= '9') ||
350 (c >= 'A' && c <= 'F') || 352 (c >= 'A' && c <= 'F') ||
351 (c >= 'a' && c <= 'f'); 353 (c >= 'a' && c <= 'f');
352 } 354 }
353 355
354 template <typename Char> 356 template <typename Char>
357 inline bool IsHigherCaseHexDigit(Char c) {
358 return (c >= '0' && c <= '9') ||
359 (c >= 'A' && c <= 'F');
360 }
361
362 template <typename Char>
355 inline Char HexDigitToInt(Char c) { 363 inline Char HexDigitToInt(Char c) {
356 DCHECK(IsHexDigit(c)); 364 DCHECK(IsHexDigit(c));
357 if (c >= '0' && c <= '9') 365 if (c >= '0' && c <= '9')
358 return c - '0'; 366 return c - '0';
359 if (c >= 'A' && c <= 'F') 367 if (c >= 'A' && c <= 'F')
360 return c - 'A' + 10; 368 return c - 'A' + 10;
361 if (c >= 'a' && c <= 'f') 369 if (c >= 'a' && c <= 'f')
362 return c - 'a' + 10; 370 return c - 'a' + 10;
363 return 0; 371 return 0;
364 } 372 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 #elif defined(WCHAR_T_IS_UTF32) 523 #elif defined(WCHAR_T_IS_UTF32)
516 typedef uint32 Unsigned; 524 typedef uint32 Unsigned;
517 #endif 525 #endif
518 }; 526 };
519 template<> 527 template<>
520 struct ToUnsigned<short> { 528 struct ToUnsigned<short> {
521 typedef unsigned short Unsigned; 529 typedef unsigned short Unsigned;
522 }; 530 };
523 531
524 #endif // BASE_STRINGS_STRING_UTIL_H_ 532 #endif // BASE_STRINGS_STRING_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/strings/string_util.cc » ('j') | net/base/mime_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698