OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 Value::ListStorage& Value::GetList() { | 237 Value::ListStorage& Value::GetList() { |
238 CHECK(is_list()); | 238 CHECK(is_list()); |
239 return *list_; | 239 return *list_; |
240 } | 240 } |
241 | 241 |
242 const Value::ListStorage& Value::GetList() const { | 242 const Value::ListStorage& Value::GetList() const { |
243 CHECK(is_list()); | 243 CHECK(is_list()); |
244 return *list_; | 244 return *list_; |
245 } | 245 } |
246 | 246 |
247 size_t Value::GetSize() const { | |
248 return GetBlob().size(); | |
249 } | |
250 | |
251 const char* Value::GetBuffer() const { | |
252 return GetBlob().data(); | |
253 } | |
254 | |
255 bool Value::GetAsBoolean(bool* out_value) const { | 247 bool Value::GetAsBoolean(bool* out_value) const { |
256 if (out_value && is_bool()) { | 248 if (out_value && is_bool()) { |
257 *out_value = bool_value_; | 249 *out_value = bool_value_; |
258 return true; | 250 return true; |
259 } | 251 } |
260 return is_bool(); | 252 return is_bool(); |
261 } | 253 } |
262 | 254 |
263 bool Value::GetAsInteger(int* out_value) const { | 255 bool Value::GetAsInteger(int* out_value) const { |
264 if (out_value && is_int()) { | 256 if (out_value && is_int()) { |
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 } | 1316 } |
1325 | 1317 |
1326 std::ostream& operator<<(std::ostream& out, const Value::Type& type) { | 1318 std::ostream& operator<<(std::ostream& out, const Value::Type& type) { |
1327 if (static_cast<int>(type) < 0 || | 1319 if (static_cast<int>(type) < 0 || |
1328 static_cast<size_t>(type) >= arraysize(kTypeNames)) | 1320 static_cast<size_t>(type) >= arraysize(kTypeNames)) |
1329 return out << "Invalid Type (index = " << static_cast<int>(type) << ")"; | 1321 return out << "Invalid Type (index = " << static_cast<int>(type) << ")"; |
1330 return out << Value::GetTypeName(type); | 1322 return out << Value::GetTypeName(type); |
1331 } | 1323 } |
1332 | 1324 |
1333 } // namespace base | 1325 } // namespace base |
OLD | NEW |