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_STRING16_H_ | 5 #ifndef MINI_CHROMIUM_BASE_STRINGS_STRING16_H_ |
6 #define MINI_CHROMIUM_BASE_STRINGS_STRING16_H_ | 6 #define MINI_CHROMIUM_BASE_STRINGS_STRING16_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 | 14 |
15 #if defined(WCHAR_T_IS_UTF16) | |
16 | |
17 namespace base { | 15 namespace base { |
18 | 16 |
17 #if defined(WCHAR_T_IS_UTF16) | |
19 typedef wchar_t char16; | 18 typedef wchar_t char16; |
20 typedef std::wstring string16; | 19 typedef std::wstring string16; |
Mark Mentovai
2014/12/16 18:34:07
This is better. The one thing I can think of to im
scottmg
2014/12/16 18:56:39
Done.
| |
21 typedef std::char_traits<wchar_t> string16_char_traits; | 20 typedef std::char_traits<wchar_t> string16_char_traits; |
22 | |
23 } // namespace base | |
24 | |
25 #elif defined(WCHAR_T_IS_UTF32) | 21 #elif defined(WCHAR_T_IS_UTF32) |
26 | |
27 namespace base { | |
28 | |
29 typedef uint16_t char16; | 22 typedef uint16_t char16; |
30 | |
31 } // namespace base | |
32 | |
33 #endif // WCHAR_T_IS_UTF32 | 23 #endif // WCHAR_T_IS_UTF32 |
34 | 24 |
35 namespace base { | |
36 | |
37 int c16memcmp(const char16* s1, const char16* s2, size_t n); | 25 int c16memcmp(const char16* s1, const char16* s2, size_t n); |
38 size_t c16len(const char16* s); | 26 size_t c16len(const char16* s); |
39 const char16* c16memchr(const char16* s, char16 c, size_t n); | 27 const char16* c16memchr(const char16* s, char16 c, size_t n); |
40 char16* c16memmove(char16* s1, const char16* s2, size_t n); | 28 char16* c16memmove(char16* s1, const char16* s2, size_t n); |
41 char16* c16memcpy(char16* s1, const char16* s2, size_t n); | 29 char16* c16memcpy(char16* s1, const char16* s2, size_t n); |
42 char16* c16memset(char16* s, char16 c, size_t n); | 30 char16* c16memset(char16* s, char16 c, size_t n); |
43 | 31 |
44 } // namespace base | |
45 | |
46 #if defined(WCHAR_T_IS_UTF32) | 32 #if defined(WCHAR_T_IS_UTF32) |
47 | 33 |
48 namespace base { | |
49 | |
50 struct string16_char_traits { | 34 struct string16_char_traits { |
51 typedef char16 char_type; | 35 typedef char16 char_type; |
52 typedef int int_type; | 36 typedef int int_type; |
53 | 37 |
54 static_assert(sizeof(int_type) > sizeof(char_type), "unexpected type width"); | 38 static_assert(sizeof(int_type) > sizeof(char_type), "unexpected type width"); |
55 | 39 |
56 typedef std::streamoff off_type; | 40 typedef std::streamoff off_type; |
57 typedef mbstate_t state_type; | 41 typedef mbstate_t state_type; |
58 typedef std::fpos<state_type> pos_type; | 42 typedef std::fpos<state_type> pos_type; |
59 | 43 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 | 95 |
112 static int_type eof() { | 96 static int_type eof() { |
113 return static_cast<int_type>(EOF); | 97 return static_cast<int_type>(EOF); |
114 } | 98 } |
115 }; | 99 }; |
116 | 100 |
117 typedef std::basic_string<char16, base::string16_char_traits> string16; | 101 typedef std::basic_string<char16, base::string16_char_traits> string16; |
118 | 102 |
119 extern std::ostream& operator<<(std::ostream& out, const string16& str); | 103 extern std::ostream& operator<<(std::ostream& out, const string16& str); |
120 | 104 |
105 #endif // WCHAR_T_IS_UTF32 | |
106 | |
121 } // namespace base | 107 } // namespace base |
122 | 108 |
109 #if defined(WCHAR_T_IS_UTF32) | |
123 extern template class std::basic_string<base::char16, | 110 extern template class std::basic_string<base::char16, |
124 base::string16_char_traits>; | 111 base::string16_char_traits>; |
125 | |
126 #endif // WCHAR_T_IS_UTF32 | 112 #endif // WCHAR_T_IS_UTF32 |
127 | 113 |
128 #endif // MINI_CHROMIUM_BASE_STRINGS_STRING16_H_ | 114 #endif // MINI_CHROMIUM_BASE_STRINGS_STRING16_H_ |
OLD | NEW |