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

Side by Side Diff: base/values.cc

Issue 159156: Add space-saving overloads for DictionaryValue::SetXXX... Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « base/values.h ('k') | 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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "base/logging.h" 5 #include "base/logging.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 8
9 ///////////////////// Value //////////////////// 9 ///////////////////// Value ////////////////////
10 10
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 287 }
288 288
289 std::wstring remaining_path = path.substr(delimiter_position + 1); 289 std::wstring remaining_path = path.substr(delimiter_position + 1);
290 return entry->Set(remaining_path, in_value); 290 return entry->Set(remaining_path, in_value);
291 } 291 }
292 292
293 bool DictionaryValue::SetBoolean(const std::wstring& path, bool in_value) { 293 bool DictionaryValue::SetBoolean(const std::wstring& path, bool in_value) {
294 return Set(path, CreateBooleanValue(in_value)); 294 return Set(path, CreateBooleanValue(in_value));
295 } 295 }
296 296
297 bool DictionaryValue::SetBoolean(const wchar_t* path, bool in_value) {
298 return SetBoolean(std::wstring(path), in_value);
299 }
300
297 bool DictionaryValue::SetInteger(const std::wstring& path, int in_value) { 301 bool DictionaryValue::SetInteger(const std::wstring& path, int in_value) {
298 return Set(path, CreateIntegerValue(in_value)); 302 return Set(path, CreateIntegerValue(in_value));
299 } 303 }
300 304
305 bool DictionaryValue::SetInteger(const wchar_t* path, int in_value) {
306 return SetInteger(std::wstring(path), in_value);
307 }
308
309
301 bool DictionaryValue::SetReal(const std::wstring& path, double in_value) { 310 bool DictionaryValue::SetReal(const std::wstring& path, double in_value) {
302 return Set(path, CreateRealValue(in_value)); 311 return Set(path, CreateRealValue(in_value));
303 } 312 }
304 313
305 bool DictionaryValue::SetString(const std::wstring& path, 314 bool DictionaryValue::SetString(const std::wstring& path,
306 const std::string& in_value) { 315 const std::string& in_value) {
307 return Set(path, CreateStringValue(in_value)); 316 return Set(path, CreateStringValue(in_value));
308 } 317 }
309 318
319 bool DictionaryValue::SetString(const wchar_t* path,
320 const std::string& in_value) {
321 return SetString(std::wstring(path), in_value);
322 }
323
310 bool DictionaryValue::SetString(const std::wstring& path, 324 bool DictionaryValue::SetString(const std::wstring& path,
311 const std::wstring& in_value) { 325 const std::wstring& in_value) {
312 return Set(path, CreateStringValue(in_value)); 326 return Set(path, CreateStringValue(in_value));
313 } 327 }
314 328
329 bool DictionaryValue::SetString(const wchar_t* path,
330 const std::wstring& in_value) {
331 return SetString(std::wstring(path), in_value);
332 }
333
315 bool DictionaryValue::Get(const std::wstring& path, Value** out_value) const { 334 bool DictionaryValue::Get(const std::wstring& path, Value** out_value) const {
316 std::wstring key = path; 335 std::wstring key = path;
317 336
318 size_t delimiter_position = path.find_first_of(L".", 0); 337 size_t delimiter_position = path.find_first_of(L".", 0);
319 if (delimiter_position != std::wstring::npos) { 338 if (delimiter_position != std::wstring::npos) {
320 key = path.substr(0, delimiter_position); 339 key = path.substr(0, delimiter_position);
321 } 340 }
322 341
323 ValueMap::const_iterator entry_iterator = dictionary_.find(key); 342 ValueMap::const_iterator entry_iterator = dictionary_.find(key);
324 if (entry_iterator == dictionary_.end()) 343 if (entry_iterator == dictionary_.end())
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 lhs_it != end() && rhs_it != other_list->end(); 663 lhs_it != end() && rhs_it != other_list->end();
645 ++lhs_it, ++rhs_it) { 664 ++lhs_it, ++rhs_it) {
646 if (!(*lhs_it)->Equals(*rhs_it)) 665 if (!(*lhs_it)->Equals(*rhs_it))
647 return false; 666 return false;
648 } 667 }
649 if (lhs_it != end() || rhs_it != other_list->end()) 668 if (lhs_it != end() || rhs_it != other_list->end())
650 return false; 669 return false;
651 670
652 return true; 671 return true;
653 } 672 }
OLDNEW
« no previous file with comments | « base/values.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698