| 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 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 ListValue::ListValue() : Value(Type::LIST) {} | 1060 ListValue::ListValue() : Value(Type::LIST) {} |
| 1061 | 1061 |
| 1062 void ListValue::Clear() { | 1062 void ListValue::Clear() { |
| 1063 list_->clear(); | 1063 list_->clear(); |
| 1064 } | 1064 } |
| 1065 | 1065 |
| 1066 void ListValue::Reserve(size_t n) { | 1066 void ListValue::Reserve(size_t n) { |
| 1067 list_->reserve(n); | 1067 list_->reserve(n); |
| 1068 } | 1068 } |
| 1069 | 1069 |
| 1070 bool ListValue::Set(size_t index, Value* in_value) { | |
| 1071 return Set(index, WrapUnique(in_value)); | |
| 1072 } | |
| 1073 | |
| 1074 bool ListValue::Set(size_t index, std::unique_ptr<Value> in_value) { | 1070 bool ListValue::Set(size_t index, std::unique_ptr<Value> in_value) { |
| 1075 if (!in_value) | 1071 if (!in_value) |
| 1076 return false; | 1072 return false; |
| 1077 | 1073 |
| 1078 if (index >= list_->size()) | 1074 if (index >= list_->size()) |
| 1079 list_->resize(index + 1); | 1075 list_->resize(index + 1); |
| 1080 | 1076 |
| 1081 (*list_)[index] = std::move(*in_value); | 1077 (*list_)[index] = std::move(*in_value); |
| 1082 return true; | 1078 return true; |
| 1083 } | 1079 } |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 } | 1304 } |
| 1309 | 1305 |
| 1310 std::ostream& operator<<(std::ostream& out, const Value::Type& type) { | 1306 std::ostream& operator<<(std::ostream& out, const Value::Type& type) { |
| 1311 if (static_cast<int>(type) < 0 || | 1307 if (static_cast<int>(type) < 0 || |
| 1312 static_cast<size_t>(type) >= arraysize(kTypeNames)) | 1308 static_cast<size_t>(type) >= arraysize(kTypeNames)) |
| 1313 return out << "Invalid Type (index = " << static_cast<int>(type) << ")"; | 1309 return out << "Invalid Type (index = " << static_cast<int>(type) << ")"; |
| 1314 return out << Value::GetTypeName(type); | 1310 return out << Value::GetTypeName(type); |
| 1315 } | 1311 } |
| 1316 | 1312 |
| 1317 } // namespace base | 1313 } // namespace base |
| OLD | NEW |