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

Side by Side Diff: chrome/browser/sync/util/character_set_converters.h

Issue 279004: Made sync code build and pass unit tests on OS X. (Closed)
Patch Set: Fixed uninitialized var error. Created 11 years, 2 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 CHROME_BROWSER_SYNC_UTIL_CHARACTER_SET_CONVERTERS_H_ 5 #ifndef CHROME_BROWSER_SYNC_UTIL_CHARACTER_SET_CONVERTERS_H_
6 #define CHROME_BROWSER_SYNC_UTIL_CHARACTER_SET_CONVERTERS_H_ 6 #define CHROME_BROWSER_SYNC_UTIL_CHARACTER_SET_CONVERTERS_H_
7 7
8 // A pair of classes to convert UTF8 <-> UCS2 character strings. 8 // A pair of classes to convert UTF8 <-> UCS2 character strings.
9 // 9 //
10 // Note that the current implementation is limited to UCS2, whereas the 10 // Note that the current implementation is limited to UCS2, whereas the
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return AppendUTF8ToPathString(utf8.data(), utf8.length(), output_string); 129 return AppendUTF8ToPathString(utf8.data(), utf8.length(), output_string);
130 } 130 }
131 131
132 // Converts UCS2 string wide to UTF8 encoding and appends the result to 132 // Converts UCS2 string wide to UTF8 encoding and appends the result to
133 // output_string. 133 // output_string.
134 inline void AppendPathStringToUTF8(const PathString& wide, 134 inline void AppendPathStringToUTF8(const PathString& wide,
135 std::string* output_string) { 135 std::string* output_string) {
136 return AppendPathStringToUTF8(wide.data(), wide.length(), output_string); 136 return AppendPathStringToUTF8(wide.data(), wide.length(), output_string);
137 } 137 }
138 138
139 // Versions of UTF8ToPathString/PathStringToUTF8 that return the converted
140 // string directly. Any errors encountered will CHECK(). These functions are
141 // intended to be used only for testing.
142
143 inline PathString UTF8ToPathStringQuick(const std::string &utf8) {
144 PathString wide;
145 CHECK(UTF8ToPathString(utf8.data(), utf8.size(), &wide));
146 return wide;
147 }
148
149 inline std::string PathStringToUTF8Quick(const PathString& wide) {
150 std::string utf8;
151 PathStringToUTF8(wide.data(), wide.size(), &utf8);
152 return utf8;
153 }
139 154
140 inline bool Append(const PathChar* wide, int size, 155 inline bool Append(const PathChar* wide, int size,
141 std::string* output_string) { 156 std::string* output_string) {
142 AppendPathStringToUTF8(wide, size, output_string); 157 AppendPathStringToUTF8(wide, size, output_string);
143 return true; 158 return true;
144 } 159 }
145 160
146 inline bool Append(const PathChar* wide, std::string* output_string) { 161 inline bool Append(const PathChar* wide, std::string* output_string) {
147 AppendPathStringToUTF8(wide, PathLen(wide), output_string); 162 AppendPathStringToUTF8(wide, PathLen(wide), output_string);
148 return true; 163 return true;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 inline PathString::size_type ToPathString::length() const { 238 inline PathString::size_type ToPathString::length() const {
224 DCHECK(good_ && good_checked_); 239 DCHECK(good_ && good_checked_);
225 return result_.length(); 240 return result_.length();
226 } 241 }
227 242
228 void TrimPathStringToValidCharacter(PathString* string); 243 void TrimPathStringToValidCharacter(PathString* string);
229 244
230 } // namespace browser_sync 245 } // namespace browser_sync
231 246
232 #endif // CHROME_BROWSER_SYNC_UTIL_CHARACTER_SET_CONVERTERS_H_ 247 #endif // CHROME_BROWSER_SYNC_UTIL_CHARACTER_SET_CONVERTERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698