| 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 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 ListValue::ListValue() : Value(Type::LIST) {} | 1076 ListValue::ListValue() : Value(Type::LIST) {} |
| 1077 | 1077 |
| 1078 void ListValue::Clear() { | 1078 void ListValue::Clear() { |
| 1079 list_->clear(); | 1079 list_->clear(); |
| 1080 } | 1080 } |
| 1081 | 1081 |
| 1082 void ListValue::Reserve(size_t n) { | 1082 void ListValue::Reserve(size_t n) { |
| 1083 list_->reserve(n); | 1083 list_->reserve(n); |
| 1084 } | 1084 } |
| 1085 | 1085 |
| 1086 bool ListValue::Set(size_t index, Value* in_value) { | |
| 1087 return Set(index, WrapUnique(in_value)); | |
| 1088 } | |
| 1089 | |
| 1090 bool ListValue::Set(size_t index, std::unique_ptr<Value> in_value) { | 1086 bool ListValue::Set(size_t index, std::unique_ptr<Value> in_value) { |
| 1091 if (!in_value) | 1087 if (!in_value) |
| 1092 return false; | 1088 return false; |
| 1093 | 1089 |
| 1094 if (index >= list_->size()) | 1090 if (index >= list_->size()) |
| 1095 list_->resize(index + 1); | 1091 list_->resize(index + 1); |
| 1096 | 1092 |
| 1097 (*list_)[index] = std::move(*in_value); | 1093 (*list_)[index] = std::move(*in_value); |
| 1098 return true; | 1094 return true; |
| 1099 } | 1095 } |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 } | 1320 } |
| 1325 | 1321 |
| 1326 std::ostream& operator<<(std::ostream& out, const Value::Type& type) { | 1322 std::ostream& operator<<(std::ostream& out, const Value::Type& type) { |
| 1327 if (static_cast<int>(type) < 0 || | 1323 if (static_cast<int>(type) < 0 || |
| 1328 static_cast<size_t>(type) >= arraysize(kTypeNames)) | 1324 static_cast<size_t>(type) >= arraysize(kTypeNames)) |
| 1329 return out << "Invalid Type (index = " << static_cast<int>(type) << ")"; | 1325 return out << "Invalid Type (index = " << static_cast<int>(type) << ")"; |
| 1330 return out << Value::GetTypeName(type); | 1326 return out << Value::GetTypeName(type); |
| 1331 } | 1327 } |
| 1332 | 1328 |
| 1333 } // namespace base | 1329 } // namespace base |
| OLD | NEW |