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

Side by Side Diff: base/values.cc

Issue 6248026: Rename Real* to Double* in values.* and dependent files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More renames Created 9 years, 10 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
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 FundamentalValue* Value::CreateBooleanValue(bool in_value) { 73 FundamentalValue* Value::CreateBooleanValue(bool in_value) {
74 return new FundamentalValue(in_value); 74 return new FundamentalValue(in_value);
75 } 75 }
76 76
77 // static 77 // static
78 FundamentalValue* Value::CreateIntegerValue(int in_value) { 78 FundamentalValue* Value::CreateIntegerValue(int in_value) {
79 return new FundamentalValue(in_value); 79 return new FundamentalValue(in_value);
80 } 80 }
81 81
82 // static 82 // static
83 FundamentalValue* Value::CreateRealValue(double in_value) { 83 FundamentalValue* Value::CreateDoubleValue(double in_value) {
84 return new FundamentalValue(in_value); 84 return new FundamentalValue(in_value);
85 } 85 }
86 86
87 // static 87 // static
88 StringValue* Value::CreateStringValue(const std::string& in_value) { 88 StringValue* Value::CreateStringValue(const std::string& in_value) {
89 return new StringValue(in_value); 89 return new StringValue(in_value);
90 } 90 }
91 91
92 // static 92 // static
93 StringValue* Value::CreateStringValue(const string16& in_value) { 93 StringValue* Value::CreateStringValue(const string16& in_value) {
94 return new StringValue(in_value); 94 return new StringValue(in_value);
95 } 95 }
96 96
97 // static 97 // static
98 BinaryValue* Value::CreateBinaryValue(char* buffer, size_t size) { 98 BinaryValue* Value::CreateBinaryValue(char* buffer, size_t size) {
99 return BinaryValue::Create(buffer, size); 99 return BinaryValue::Create(buffer, size);
100 } 100 }
101 101
102 bool Value::GetAsBoolean(bool* out_value) const { 102 bool Value::GetAsBoolean(bool* out_value) const {
103 return false; 103 return false;
104 } 104 }
105 105
106 bool Value::GetAsInteger(int* out_value) const { 106 bool Value::GetAsInteger(int* out_value) const {
107 return false; 107 return false;
108 } 108 }
109 109
110 bool Value::GetAsReal(double* out_value) const { 110 bool Value::GetAsDouble(double* out_value) const {
111 return false; 111 return false;
112 } 112 }
113 113
114 bool Value::GetAsString(std::string* out_value) const { 114 bool Value::GetAsString(std::string* out_value) const {
115 return false; 115 return false;
116 } 116 }
117 117
118 bool Value::GetAsString(string16* out_value) const { 118 bool Value::GetAsString(string16* out_value) const {
119 return false; 119 return false;
120 } 120 }
(...skipping 30 matching lines...) Expand all
151 151
152 FundamentalValue::FundamentalValue(bool in_value) 152 FundamentalValue::FundamentalValue(bool in_value)
153 : Value(TYPE_BOOLEAN), boolean_value_(in_value) { 153 : Value(TYPE_BOOLEAN), boolean_value_(in_value) {
154 } 154 }
155 155
156 FundamentalValue::FundamentalValue(int in_value) 156 FundamentalValue::FundamentalValue(int in_value)
157 : Value(TYPE_INTEGER), integer_value_(in_value) { 157 : Value(TYPE_INTEGER), integer_value_(in_value) {
158 } 158 }
159 159
160 FundamentalValue::FundamentalValue(double in_value) 160 FundamentalValue::FundamentalValue(double in_value)
161 : Value(TYPE_REAL), real_value_(in_value) { 161 : Value(TYPE_DOUBLE), double_value_(in_value) {
162 } 162 }
163 163
164 FundamentalValue::~FundamentalValue() { 164 FundamentalValue::~FundamentalValue() {
165 } 165 }
166 166
167 bool FundamentalValue::GetAsBoolean(bool* out_value) const { 167 bool FundamentalValue::GetAsBoolean(bool* out_value) const {
168 if (out_value && IsType(TYPE_BOOLEAN)) 168 if (out_value && IsType(TYPE_BOOLEAN))
169 *out_value = boolean_value_; 169 *out_value = boolean_value_;
170 return (IsType(TYPE_BOOLEAN)); 170 return (IsType(TYPE_BOOLEAN));
171 } 171 }
172 172
173 bool FundamentalValue::GetAsInteger(int* out_value) const { 173 bool FundamentalValue::GetAsInteger(int* out_value) const {
174 if (out_value && IsType(TYPE_INTEGER)) 174 if (out_value && IsType(TYPE_INTEGER))
175 *out_value = integer_value_; 175 *out_value = integer_value_;
176 return (IsType(TYPE_INTEGER)); 176 return (IsType(TYPE_INTEGER));
177 } 177 }
178 178
179 bool FundamentalValue::GetAsReal(double* out_value) const { 179 bool FundamentalValue::GetAsDouble(double* out_value) const {
180 if (out_value && IsType(TYPE_REAL)) 180 if (out_value && IsType(TYPE_DOUBLE))
181 *out_value = real_value_; 181 *out_value = double_value_;
182 return (IsType(TYPE_REAL)); 182 return (IsType(TYPE_DOUBLE));
183 } 183 }
184 184
185 FundamentalValue* FundamentalValue::DeepCopy() const { 185 FundamentalValue* FundamentalValue::DeepCopy() const {
186 switch (GetType()) { 186 switch (GetType()) {
187 case TYPE_BOOLEAN: 187 case TYPE_BOOLEAN:
188 return CreateBooleanValue(boolean_value_); 188 return CreateBooleanValue(boolean_value_);
189 189
190 case TYPE_INTEGER: 190 case TYPE_INTEGER:
191 return CreateIntegerValue(integer_value_); 191 return CreateIntegerValue(integer_value_);
192 192
193 case TYPE_REAL: 193 case TYPE_DOUBLE:
194 return CreateRealValue(real_value_); 194 return CreateDoubleValue(double_value_);
195 195
196 default: 196 default:
197 NOTREACHED(); 197 NOTREACHED();
198 return NULL; 198 return NULL;
199 } 199 }
200 } 200 }
201 201
202 bool FundamentalValue::Equals(const Value* other) const { 202 bool FundamentalValue::Equals(const Value* other) const {
203 if (other->GetType() != GetType()) 203 if (other->GetType() != GetType())
204 return false; 204 return false;
205 205
206 switch (GetType()) { 206 switch (GetType()) {
207 case TYPE_BOOLEAN: { 207 case TYPE_BOOLEAN: {
208 bool lhs, rhs; 208 bool lhs, rhs;
209 return GetAsBoolean(&lhs) && other->GetAsBoolean(&rhs) && lhs == rhs; 209 return GetAsBoolean(&lhs) && other->GetAsBoolean(&rhs) && lhs == rhs;
210 } 210 }
211 case TYPE_INTEGER: { 211 case TYPE_INTEGER: {
212 int lhs, rhs; 212 int lhs, rhs;
213 return GetAsInteger(&lhs) && other->GetAsInteger(&rhs) && lhs == rhs; 213 return GetAsInteger(&lhs) && other->GetAsInteger(&rhs) && lhs == rhs;
214 } 214 }
215 case TYPE_REAL: { 215 case TYPE_DOUBLE: {
216 double lhs, rhs; 216 double lhs, rhs;
217 return GetAsReal(&lhs) && other->GetAsReal(&rhs) && lhs == rhs; 217 return GetAsDouble(&lhs) && other->GetAsDouble(&rhs) && lhs == rhs;
218 } 218 }
219 default: 219 default:
220 NOTREACHED(); 220 NOTREACHED();
221 return false; 221 return false;
222 } 222 }
223 } 223 }
224 224
225 ///////////////////// StringValue //////////////////// 225 ///////////////////// StringValue ////////////////////
226 226
227 StringValue::StringValue(const std::string& in_value) 227 StringValue::StringValue(const std::string& in_value)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } 360 }
361 361
362 void DictionaryValue::SetBoolean(const std::string& path, bool in_value) { 362 void DictionaryValue::SetBoolean(const std::string& path, bool in_value) {
363 Set(path, CreateBooleanValue(in_value)); 363 Set(path, CreateBooleanValue(in_value));
364 } 364 }
365 365
366 void DictionaryValue::SetInteger(const std::string& path, int in_value) { 366 void DictionaryValue::SetInteger(const std::string& path, int in_value) {
367 Set(path, CreateIntegerValue(in_value)); 367 Set(path, CreateIntegerValue(in_value));
368 } 368 }
369 369
370 void DictionaryValue::SetReal(const std::string& path, double in_value) { 370 void DictionaryValue::SetDouble(const std::string& path, double in_value) {
371 Set(path, CreateRealValue(in_value)); 371 Set(path, CreateDoubleValue(in_value));
372 } 372 }
373 373
374 void DictionaryValue::SetString(const std::string& path, 374 void DictionaryValue::SetString(const std::string& path,
375 const std::string& in_value) { 375 const std::string& in_value) {
376 Set(path, CreateStringValue(in_value)); 376 Set(path, CreateStringValue(in_value));
377 } 377 }
378 378
379 void DictionaryValue::SetString(const std::string& path, 379 void DictionaryValue::SetString(const std::string& path,
380 const string16& in_value) { 380 const string16& in_value) {
381 Set(path, CreateStringValue(in_value)); 381 Set(path, CreateStringValue(in_value));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 423
424 bool DictionaryValue::GetInteger(const std::string& path, 424 bool DictionaryValue::GetInteger(const std::string& path,
425 int* out_value) const { 425 int* out_value) const {
426 Value* value; 426 Value* value;
427 if (!Get(path, &value)) 427 if (!Get(path, &value))
428 return false; 428 return false;
429 429
430 return value->GetAsInteger(out_value); 430 return value->GetAsInteger(out_value);
431 } 431 }
432 432
433 bool DictionaryValue::GetReal(const std::string& path, 433 bool DictionaryValue::GetDouble(const std::string& path,
434 double* out_value) const { 434 double* out_value) const {
435 Value* value; 435 Value* value;
436 if (!Get(path, &value)) 436 if (!Get(path, &value))
437 return false; 437 return false;
438 438
439 return value->GetAsReal(out_value); 439 return value->GetAsDouble(out_value);
440 } 440 }
441 441
442 bool DictionaryValue::GetString(const std::string& path, 442 bool DictionaryValue::GetString(const std::string& path,
443 std::string* out_value) const { 443 std::string* out_value) const {
444 Value* value; 444 Value* value;
445 if (!Get(path, &value)) 445 if (!Get(path, &value))
446 return false; 446 return false;
447 447
448 return value->GetAsString(out_value); 448 return value->GetAsString(out_value);
449 } 449 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 526
527 bool DictionaryValue::GetIntegerWithoutPathExpansion(const std::string& key, 527 bool DictionaryValue::GetIntegerWithoutPathExpansion(const std::string& key,
528 int* out_value) const { 528 int* out_value) const {
529 Value* value; 529 Value* value;
530 if (!GetWithoutPathExpansion(key, &value)) 530 if (!GetWithoutPathExpansion(key, &value))
531 return false; 531 return false;
532 532
533 return value->GetAsInteger(out_value); 533 return value->GetAsInteger(out_value);
534 } 534 }
535 535
536 bool DictionaryValue::GetRealWithoutPathExpansion(const std::string& key, 536 bool DictionaryValue::GetDoubleWithoutPathExpansion(const std::string& key,
537 double* out_value) const { 537 double* out_value) const {
538 Value* value; 538 Value* value;
539 if (!GetWithoutPathExpansion(key, &value)) 539 if (!GetWithoutPathExpansion(key, &value))
540 return false; 540 return false;
541 541
542 return value->GetAsReal(out_value); 542 return value->GetAsDouble(out_value);
543 } 543 }
544 544
545 bool DictionaryValue::GetStringWithoutPathExpansion( 545 bool DictionaryValue::GetStringWithoutPathExpansion(
546 const std::string& key, 546 const std::string& key,
547 std::string* out_value) const { 547 std::string* out_value) const {
548 Value* value; 548 Value* value;
549 if (!GetWithoutPathExpansion(key, &value)) 549 if (!GetWithoutPathExpansion(key, &value))
550 return false; 550 return false;
551 551
552 return value->GetAsString(out_value); 552 return value->GetAsString(out_value);
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 } 735 }
736 736
737 bool ListValue::GetInteger(size_t index, int* out_value) const { 737 bool ListValue::GetInteger(size_t index, int* out_value) const {
738 Value* value; 738 Value* value;
739 if (!Get(index, &value)) 739 if (!Get(index, &value))
740 return false; 740 return false;
741 741
742 return value->GetAsInteger(out_value); 742 return value->GetAsInteger(out_value);
743 } 743 }
744 744
745 bool ListValue::GetReal(size_t index, double* out_value) const { 745 bool ListValue::GetDouble(size_t index, double* out_value) const {
746 Value* value; 746 Value* value;
747 if (!Get(index, &value)) 747 if (!Get(index, &value))
748 return false; 748 return false;
749 749
750 return value->GetAsReal(out_value); 750 return value->GetAsDouble(out_value);
751 } 751 }
752 752
753 bool ListValue::GetString(size_t index, std::string* out_value) const { 753 bool ListValue::GetString(size_t index, std::string* out_value) const {
754 Value* value; 754 Value* value;
755 if (!Get(index, &value)) 755 if (!Get(index, &value))
756 return false; 756 return false;
757 757
758 return value->GetAsString(out_value); 758 return value->GetAsString(out_value);
759 } 759 }
760 760
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 return false; 885 return false;
886 } 886 }
887 if (lhs_it != end() || rhs_it != other_list->end()) 887 if (lhs_it != end() || rhs_it != other_list->end())
888 return false; 888 return false;
889 889
890 return true; 890 return true;
891 } 891 }
892 892
893 ValueSerializer::~ValueSerializer() { 893 ValueSerializer::~ValueSerializer() {
894 } 894 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698