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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 } | 297 } |
298 | 298 |
299 bool Value::GetAsString(StringPiece* out_value) const { | 299 bool Value::GetAsString(StringPiece* out_value) const { |
300 if (out_value && is_string()) { | 300 if (out_value && is_string()) { |
301 *out_value = *string_value_; | 301 *out_value = *string_value_; |
302 return true; | 302 return true; |
303 } | 303 } |
304 return is_string(); | 304 return is_string(); |
305 } | 305 } |
306 | 306 |
307 bool Value::GetAsBinary(const Value** out_value) const { | |
308 if (out_value && is_blob()) { | |
309 *out_value = this; | |
310 return true; | |
311 } | |
312 return is_blob(); | |
313 } | |
314 | |
315 bool Value::GetAsList(ListValue** out_value) { | 307 bool Value::GetAsList(ListValue** out_value) { |
316 if (out_value && is_list()) { | 308 if (out_value && is_list()) { |
317 *out_value = static_cast<ListValue*>(this); | 309 *out_value = static_cast<ListValue*>(this); |
318 return true; | 310 return true; |
319 } | 311 } |
320 return is_list(); | 312 return is_list(); |
321 } | 313 } |
322 | 314 |
323 bool Value::GetAsList(const ListValue** out_value) const { | 315 bool Value::GetAsList(const ListValue** out_value) const { |
324 if (out_value && is_list()) { | 316 if (out_value && is_list()) { |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 } | 1308 } |
1317 | 1309 |
1318 std::ostream& operator<<(std::ostream& out, const Value::Type& type) { | 1310 std::ostream& operator<<(std::ostream& out, const Value::Type& type) { |
1319 if (static_cast<int>(type) < 0 || | 1311 if (static_cast<int>(type) < 0 || |
1320 static_cast<size_t>(type) >= arraysize(kTypeNames)) | 1312 static_cast<size_t>(type) >= arraysize(kTypeNames)) |
1321 return out << "Invalid Type (index = " << static_cast<int>(type) << ")"; | 1313 return out << "Invalid Type (index = " << static_cast<int>(type) << ")"; |
1322 return out << Value::GetTypeName(type); | 1314 return out << Value::GetTypeName(type); |
1323 } | 1315 } |
1324 | 1316 |
1325 } // namespace base | 1317 } // namespace base |
OLD | NEW |