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

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

Issue 596103002: Fix more disabled MSVC warnings, base/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't assume char (un)signedness Created 6 years, 3 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
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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 345 }
346 346
347 template <typename Char> 347 template <typename Char>
348 inline bool IsHexDigit(Char c) { 348 inline bool IsHexDigit(Char c) {
349 return (c >= '0' && c <= '9') || 349 return (c >= '0' && c <= '9') ||
350 (c >= 'A' && c <= 'F') || 350 (c >= 'A' && c <= 'F') ||
351 (c >= 'a' && c <= 'f'); 351 (c >= 'a' && c <= 'f');
352 } 352 }
353 353
354 template <typename Char> 354 template <typename Char>
355 inline Char HexDigitToInt(Char c) { 355 inline char HexDigitToInt(Char c) {
356 DCHECK(IsHexDigit(c)); 356 DCHECK(IsHexDigit(c));
357 if (c >= '0' && c <= '9') 357 if (c >= '0' && c <= '9')
358 return c - '0'; 358 return static_cast<char>(c - '0');
359 if (c >= 'A' && c <= 'F') 359 if (c >= 'A' && c <= 'F')
360 return c - 'A' + 10; 360 return static_cast<char>(c - 'A' + 10);
361 if (c >= 'a' && c <= 'f') 361 if (c >= 'a' && c <= 'f')
362 return c - 'a' + 10; 362 return static_cast<char>(c - 'a' + 10);
363 return 0; 363 return 0;
364 } 364 }
365 365
366 // Returns true if it's a whitespace character. 366 // Returns true if it's a whitespace character.
367 inline bool IsWhitespace(wchar_t c) { 367 inline bool IsWhitespace(wchar_t c) {
368 return wcschr(base::kWhitespaceWide, c) != NULL; 368 return wcschr(base::kWhitespaceWide, c) != NULL;
369 } 369 }
370 370
371 // Return a byte string in human-readable format with a unit suffix. Not 371 // Return a byte string in human-readable format with a unit suffix. Not
372 // appropriate for use in any UI; use of FormatBytes and friends in ui/base is 372 // appropriate for use in any UI; use of FormatBytes and friends in ui/base is
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 #elif defined(WCHAR_T_IS_UTF32) 514 #elif defined(WCHAR_T_IS_UTF32)
515 typedef uint32 Unsigned; 515 typedef uint32 Unsigned;
516 #endif 516 #endif
517 }; 517 };
518 template<> 518 template<>
519 struct ToUnsigned<short> { 519 struct ToUnsigned<short> {
520 typedef unsigned short Unsigned; 520 typedef unsigned short Unsigned;
521 }; 521 };
522 522
523 #endif // BASE_STRINGS_STRING_UTIL_H_ 523 #endif // BASE_STRINGS_STRING_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698