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

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

Issue 812553004: Tidy string16.h after https://codereview.chromium.org/809563003/ (Closed) Base URL: https://chromium.googlesource.com/chromium/mini_chromium@master
Patch Set: parallel location for string16 Created 6 years 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
21 typedef std::char_traits<wchar_t> string16_char_traits;
22
23 } // namespace base
24
25 #elif defined(WCHAR_T_IS_UTF32) 19 #elif defined(WCHAR_T_IS_UTF32)
26
27 namespace base {
28
29 typedef uint16_t char16; 20 typedef uint16_t char16;
30
31 } // namespace base
32
33 #endif // WCHAR_T_IS_UTF32 21 #endif // WCHAR_T_IS_UTF32
34 22
35 namespace base {
36
37 int c16memcmp(const char16* s1, const char16* s2, size_t n); 23 int c16memcmp(const char16* s1, const char16* s2, size_t n);
38 size_t c16len(const char16* s); 24 size_t c16len(const char16* s);
39 const char16* c16memchr(const char16* s, char16 c, size_t n); 25 const char16* c16memchr(const char16* s, char16 c, size_t n);
40 char16* c16memmove(char16* s1, const char16* s2, size_t n); 26 char16* c16memmove(char16* s1, const char16* s2, size_t n);
41 char16* c16memcpy(char16* s1, const char16* s2, size_t n); 27 char16* c16memcpy(char16* s1, const char16* s2, size_t n);
42 char16* c16memset(char16* s, char16 c, size_t n); 28 char16* c16memset(char16* s, char16 c, size_t n);
43 29
44 } // namespace base 30 #if defined(WCHAR_T_IS_UTF16)
45 31
46 #if defined(WCHAR_T_IS_UTF32) 32 typedef std::wstring string16;
33 typedef std::char_traits<wchar_t> string16_char_traits;
47 34
48 namespace base { 35 #elif defined(WCHAR_T_IS_UTF32)
49 36
50 struct string16_char_traits { 37 struct string16_char_traits {
51 typedef char16 char_type; 38 typedef char16 char_type;
52 typedef int int_type; 39 typedef int int_type;
53 40
54 static_assert(sizeof(int_type) > sizeof(char_type), "unexpected type width"); 41 static_assert(sizeof(int_type) > sizeof(char_type), "unexpected type width");
55 42
56 typedef std::streamoff off_type; 43 typedef std::streamoff off_type;
57 typedef mbstate_t state_type; 44 typedef mbstate_t state_type;
58 typedef std::fpos<state_type> pos_type; 45 typedef std::fpos<state_type> pos_type;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 98
112 static int_type eof() { 99 static int_type eof() {
113 return static_cast<int_type>(EOF); 100 return static_cast<int_type>(EOF);
114 } 101 }
115 }; 102 };
116 103
117 typedef std::basic_string<char16, base::string16_char_traits> string16; 104 typedef std::basic_string<char16, base::string16_char_traits> string16;
118 105
119 extern std::ostream& operator<<(std::ostream& out, const string16& str); 106 extern std::ostream& operator<<(std::ostream& out, const string16& str);
120 107
108 #endif // WCHAR_T_IS_UTF32
109
121 } // namespace base 110 } // namespace base
122 111
112 #if defined(WCHAR_T_IS_UTF32)
123 extern template class std::basic_string<base::char16, 113 extern template class std::basic_string<base::char16,
124 base::string16_char_traits>; 114 base::string16_char_traits>;
125
126 #endif // WCHAR_T_IS_UTF32 115 #endif // WCHAR_T_IS_UTF32
127 116
128 #endif // MINI_CHROMIUM_BASE_STRINGS_STRING16_H_ 117 #endif // MINI_CHROMIUM_BASE_STRINGS_STRING16_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698