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

Side by Side Diff: base/values.cc

Issue 8701002: Value::GetAsDictionary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pacify clang Created 9 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 | Annotate | Revision Log
« no previous file with comments | « base/values.h ('k') | base/values_unittest.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/values.h" 5 #include "base/values.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/float_util.h" 9 #include "base/float_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 136 }
137 137
138 bool Value::GetAsList(ListValue** out_value) { 138 bool Value::GetAsList(ListValue** out_value) {
139 return false; 139 return false;
140 } 140 }
141 141
142 bool Value::GetAsList(const ListValue** out_value) const { 142 bool Value::GetAsList(const ListValue** out_value) const {
143 return false; 143 return false;
144 } 144 }
145 145
146 bool Value::GetAsDictionary(DictionaryValue** out_value) {
147 return false;
148 }
149
150 bool Value::GetAsDictionary(const DictionaryValue** out_value) const {
151 return false;
152 }
153
146 Value* Value::DeepCopy() const { 154 Value* Value::DeepCopy() const {
147 // This method should only be getting called for null Values--all subclasses 155 // This method should only be getting called for null Values--all subclasses
148 // need to provide their own implementation;. 156 // need to provide their own implementation;.
149 DCHECK(IsType(TYPE_NULL)); 157 DCHECK(IsType(TYPE_NULL));
150 return CreateNullValue(); 158 return CreateNullValue();
151 } 159 }
152 160
153 bool Value::Equals(const Value* other) const { 161 bool Value::Equals(const Value* other) const {
154 // This method should only be getting called for null Values--all subclasses 162 // This method should only be getting called for null Values--all subclasses
155 // need to provide their own implementation;. 163 // need to provide their own implementation;.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 ///////////////////// DictionaryValue //////////////////// 346 ///////////////////// DictionaryValue ////////////////////
339 347
340 DictionaryValue::DictionaryValue() 348 DictionaryValue::DictionaryValue()
341 : Value(TYPE_DICTIONARY) { 349 : Value(TYPE_DICTIONARY) {
342 } 350 }
343 351
344 DictionaryValue::~DictionaryValue() { 352 DictionaryValue::~DictionaryValue() {
345 Clear(); 353 Clear();
346 } 354 }
347 355
356 bool DictionaryValue::GetAsDictionary(DictionaryValue** out_value) {
357 if (out_value)
358 *out_value = this;
359 return true;
360 }
361
362 bool DictionaryValue::GetAsDictionary(const DictionaryValue** out_value) const {
363 if (out_value)
364 *out_value = this;
365 return true;
366 }
367
348 bool DictionaryValue::HasKey(const std::string& key) const { 368 bool DictionaryValue::HasKey(const std::string& key) const {
349 DCHECK(IsStringUTF8(key)); 369 DCHECK(IsStringUTF8(key));
350 ValueMap::const_iterator current_entry = dictionary_.find(key); 370 ValueMap::const_iterator current_entry = dictionary_.find(key);
351 DCHECK((current_entry == dictionary_.end()) || current_entry->second); 371 DCHECK((current_entry == dictionary_.end()) || current_entry->second);
352 return current_entry != dictionary_.end(); 372 return current_entry != dictionary_.end();
353 } 373 }
354 374
355 void DictionaryValue::Clear() { 375 void DictionaryValue::Clear() {
356 ValueMap::iterator dict_iterator = dictionary_.begin(); 376 ValueMap::iterator dict_iterator = dictionary_.begin();
357 while (dict_iterator != dictionary_.end()) { 377 while (dict_iterator != dictionary_.end()) {
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 if (lhs_it != end() || rhs_it != other_list->end()) 945 if (lhs_it != end() || rhs_it != other_list->end())
926 return false; 946 return false;
927 947
928 return true; 948 return true;
929 } 949 }
930 950
931 ValueSerializer::~ValueSerializer() { 951 ValueSerializer::~ValueSerializer() {
932 } 952 }
933 953
934 } // namespace base 954 } // namespace base
OLDNEW
« no previous file with comments | « base/values.h ('k') | base/values_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698