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

Side by Side Diff: base/values.cc

Issue 3012001: Move implementation from header to source. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: blank line Created 10 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
OLDNEW
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/values.h" 5 #include "base/values.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return CreateNullValue(); 135 return CreateNullValue();
136 } 136 }
137 137
138 bool Value::Equals(const Value* other) const { 138 bool Value::Equals(const Value* other) const {
139 // This method should only be getting called for null Values--all subclasses 139 // This method should only be getting called for null Values--all subclasses
140 // need to provide their own implementation;. 140 // need to provide their own implementation;.
141 DCHECK(IsType(TYPE_NULL)); 141 DCHECK(IsType(TYPE_NULL));
142 return other->IsType(TYPE_NULL); 142 return other->IsType(TYPE_NULL);
143 } 143 }
144 144
145 Value::Value(ValueType type) : type_(type) {
146 }
147
145 ///////////////////// FundamentalValue //////////////////// 148 ///////////////////// FundamentalValue ////////////////////
146 149
150 FundamentalValue::FundamentalValue(bool in_value)
151 : Value(TYPE_BOOLEAN), boolean_value_(in_value) {
152 }
153
154 FundamentalValue::FundamentalValue(int in_value)
155 : Value(TYPE_INTEGER), integer_value_(in_value) {
156 }
157
158 FundamentalValue::FundamentalValue(double in_value)
159 : Value(TYPE_REAL), real_value_(in_value) {
160 }
161
147 FundamentalValue::~FundamentalValue() { 162 FundamentalValue::~FundamentalValue() {
148 } 163 }
149 164
150 bool FundamentalValue::GetAsBoolean(bool* out_value) const { 165 bool FundamentalValue::GetAsBoolean(bool* out_value) const {
151 if (out_value && IsType(TYPE_BOOLEAN)) 166 if (out_value && IsType(TYPE_BOOLEAN))
152 *out_value = boolean_value_; 167 *out_value = boolean_value_;
153 return (IsType(TYPE_BOOLEAN)); 168 return (IsType(TYPE_BOOLEAN));
154 } 169 }
155 170
156 bool FundamentalValue::GetAsInteger(int* out_value) const { 171 bool FundamentalValue::GetAsInteger(int* out_value) const {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 if (other->GetType() != GetType()) 315 if (other->GetType() != GetType())
301 return false; 316 return false;
302 const BinaryValue* other_binary = static_cast<const BinaryValue*>(other); 317 const BinaryValue* other_binary = static_cast<const BinaryValue*>(other);
303 if (other_binary->size_ != size_) 318 if (other_binary->size_ != size_)
304 return false; 319 return false;
305 return !memcmp(buffer_, other_binary->buffer_, size_); 320 return !memcmp(buffer_, other_binary->buffer_, size_);
306 } 321 }
307 322
308 ///////////////////// DictionaryValue //////////////////// 323 ///////////////////// DictionaryValue ////////////////////
309 324
325 DictionaryValue::DictionaryValue()
326 : Value(TYPE_DICTIONARY) {
327 }
328
310 DictionaryValue::~DictionaryValue() { 329 DictionaryValue::~DictionaryValue() {
311 Clear(); 330 Clear();
312 } 331 }
313 332
314 Value* DictionaryValue::DeepCopy() const { 333 Value* DictionaryValue::DeepCopy() const {
315 DictionaryValue* result = new DictionaryValue; 334 DictionaryValue* result = new DictionaryValue;
316 335
317 for (ValueMap::const_iterator current_entry(dictionary_.begin()); 336 for (ValueMap::const_iterator current_entry(dictionary_.begin());
318 current_entry != dictionary_.end(); ++current_entry) { 337 current_entry != dictionary_.end(); ++current_entry) {
319 result->SetWithoutPathExpansion(current_entry->first, 338 result->SetWithoutPathExpansion(current_entry->first,
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 } 708 }
690 } 709 }
691 // All other cases: Make a copy and hook it up. 710 // All other cases: Make a copy and hook it up.
692 SetWithoutPathExpansion(*key, merge_value->DeepCopy()); 711 SetWithoutPathExpansion(*key, merge_value->DeepCopy());
693 } 712 }
694 } 713 }
695 } 714 }
696 715
697 ///////////////////// ListValue //////////////////// 716 ///////////////////// ListValue ////////////////////
698 717
718 ListValue::ListValue() : Value(TYPE_LIST) {
719 }
720
699 ListValue::~ListValue() { 721 ListValue::~ListValue() {
700 Clear(); 722 Clear();
701 } 723 }
702 724
703 void ListValue::Clear() { 725 void ListValue::Clear() {
704 for (ValueVector::iterator i(list_.begin()); i != list_.end(); ++i) 726 for (ValueVector::iterator i(list_.begin()); i != list_.end(); ++i)
705 delete *i; 727 delete *i;
706 list_.clear(); 728 list_.clear();
707 } 729 }
708 730
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 lhs_it != end() && rhs_it != other_list->end(); 913 lhs_it != end() && rhs_it != other_list->end();
892 ++lhs_it, ++rhs_it) { 914 ++lhs_it, ++rhs_it) {
893 if (!(*lhs_it)->Equals(*rhs_it)) 915 if (!(*lhs_it)->Equals(*rhs_it))
894 return false; 916 return false;
895 } 917 }
896 if (lhs_it != end() || rhs_it != other_list->end()) 918 if (lhs_it != end() || rhs_it != other_list->end())
897 return false; 919 return false;
898 920
899 return true; 921 return true;
900 } 922 }
923
924 ValueSerializer::~ValueSerializer() {
925 }
OLDNEW
« base/tracked.h ('K') | « base/values.h ('k') | base/weak_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698