OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "base/string_util.h" | 5 #include "base/string_util.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include <ctype.h> | 9 #include <ctype.h> |
10 #include <errno.h> | 10 #include <errno.h> |
(...skipping 20 matching lines...) Expand all Loading... |
31 namespace { | 31 namespace { |
32 | 32 |
33 // Force the singleton used by Empty[W]String[16] to be a unique type. This | 33 // Force the singleton used by Empty[W]String[16] to be a unique type. This |
34 // prevents other code that might accidentally use Singleton<string> from | 34 // prevents other code that might accidentally use Singleton<string> from |
35 // getting our internal one. | 35 // getting our internal one. |
36 struct EmptyStrings { | 36 struct EmptyStrings { |
37 EmptyStrings() {} | 37 EmptyStrings() {} |
38 const std::string s; | 38 const std::string s; |
39 const std::wstring ws; | 39 const std::wstring ws; |
40 const string16 s16; | 40 const string16 s16; |
| 41 |
| 42 static EmptyStrings* GetInstance() { |
| 43 return Singleton<EmptyStrings>::get(); |
| 44 } |
41 }; | 45 }; |
42 | 46 |
43 // Used by ReplaceStringPlaceholders to track the position in the string of | 47 // Used by ReplaceStringPlaceholders to track the position in the string of |
44 // replaced parameters. | 48 // replaced parameters. |
45 struct ReplacementOffset { | 49 struct ReplacementOffset { |
46 ReplacementOffset(uintptr_t parameter, size_t offset) | 50 ReplacementOffset(uintptr_t parameter, size_t offset) |
47 : parameter(parameter), | 51 : parameter(parameter), |
48 offset(offset) {} | 52 offset(offset) {} |
49 | 53 |
50 // Index of the parameter. | 54 // Index of the parameter. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 99 } |
96 } | 100 } |
97 | 101 |
98 return true; | 102 return true; |
99 } | 103 } |
100 | 104 |
101 } // namespace base | 105 } // namespace base |
102 | 106 |
103 | 107 |
104 const std::string& EmptyString() { | 108 const std::string& EmptyString() { |
105 return Singleton<EmptyStrings>::get()->s; | 109 return EmptyStrings::GetInstance()->s; |
106 } | 110 } |
107 | 111 |
108 const std::wstring& EmptyWString() { | 112 const std::wstring& EmptyWString() { |
109 return Singleton<EmptyStrings>::get()->ws; | 113 return EmptyStrings::GetInstance()->ws; |
110 } | 114 } |
111 | 115 |
112 const string16& EmptyString16() { | 116 const string16& EmptyString16() { |
113 return Singleton<EmptyStrings>::get()->s16; | 117 return EmptyStrings::GetInstance()->s16; |
114 } | 118 } |
115 | 119 |
116 #define WHITESPACE_UNICODE \ | 120 #define WHITESPACE_UNICODE \ |
117 0x0009, /* <control-0009> to <control-000D> */ \ | 121 0x0009, /* <control-0009> to <control-000D> */ \ |
118 0x000A, \ | 122 0x000A, \ |
119 0x000B, \ | 123 0x000B, \ |
120 0x000C, \ | 124 0x000C, \ |
121 0x000D, \ | 125 0x000D, \ |
122 0x0020, /* Space */ \ | 126 0x0020, /* Space */ \ |
123 0x0085, /* <control-0085> */ \ | 127 0x0085, /* <control-0085> */ \ |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 int rstr_len = (max_len - 3) / 2; | 1124 int rstr_len = (max_len - 3) / 2; |
1121 int lstr_len = rstr_len + ((max_len - 3) % 2); | 1125 int lstr_len = rstr_len + ((max_len - 3) % 2); |
1122 output->assign(input.substr(0, lstr_len) + L"..." + | 1126 output->assign(input.substr(0, lstr_len) + L"..." + |
1123 input.substr(input.length() - rstr_len)); | 1127 input.substr(input.length() - rstr_len)); |
1124 break; | 1128 break; |
1125 } | 1129 } |
1126 } | 1130 } |
1127 | 1131 |
1128 return true; | 1132 return true; |
1129 } | 1133 } |
OLD | NEW |