| OLD | NEW |
| 1 // Copyright 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef MINI_CHROMIUM_BASE_STRINGS_STRING_UTIL_H_ | 5 #ifndef MINI_CHROMIUM_BASE_STRINGS_STRING_UTIL_H_ |
| 6 #define MINI_CHROMIUM_BASE_STRINGS_STRING_UTIL_H_ | 6 #define MINI_CHROMIUM_BASE_STRINGS_STRING_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_piece.h" |
| 10 | 11 |
| 11 namespace base { | 12 namespace base { |
| 12 | 13 |
| 13 int vsnprintf(char* buffer, size_t size, const char* format, va_list arguments) | 14 int vsnprintf(char* buffer, size_t size, const char* format, va_list arguments) |
| 14 PRINTF_FORMAT(3, 0); | 15 PRINTF_FORMAT(3, 0); |
| 15 | 16 |
| 17 bool IsStringASCII(const StringPiece& str); |
| 18 bool IsStringASCII(const StringPiece16& str); |
| 19 |
| 16 } // namespace base | 20 } // namespace base |
| 17 | 21 |
| 18 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 19 #include "base/strings/string_util_win.h" | 23 #include "base/strings/string_util_win.h" |
| 20 #elif defined(OS_POSIX) | 24 #elif defined(OS_POSIX) |
| 21 #include "base/strings/string_util_posix.h" | 25 #include "base/strings/string_util_posix.h" |
| 22 #endif | 26 #endif |
| 23 | 27 |
| 24 template <class string_type> | 28 template <class string_type> |
| 25 inline typename string_type::value_type* WriteInto(string_type* str, | 29 inline typename string_type::value_type* WriteInto(string_type* str, |
| 26 size_t length_with_null) { | 30 size_t length_with_null) { |
| 27 DCHECK_NE(0u, length_with_null); | 31 DCHECK_NE(0u, length_with_null); |
| 28 str->reserve(length_with_null); | 32 str->reserve(length_with_null); |
| 29 str->resize(length_with_null - 1); | 33 str->resize(length_with_null - 1); |
| 30 | 34 |
| 31 if (length_with_null <= 1) | 35 if (length_with_null <= 1) |
| 32 return NULL; | 36 return NULL; |
| 33 | 37 |
| 34 return &((*str)[0]); | 38 return &((*str)[0]); |
| 35 } | 39 } |
| 36 | 40 |
| 37 #endif // MINI_CHROMIUM_BASE_STRINGS_STRING_UTIL_H_ | 41 #endif // MINI_CHROMIUM_BASE_STRINGS_STRING_UTIL_H_ |
| OLD | NEW |