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 // This file specifies a recursive data storage class called Value intended for | 5 // This file specifies a recursive data storage class called Value intended for |
6 // storing settings and other persistable data. | 6 // storing settings and other persistable data. |
7 // | 7 // |
8 // A Value represents something that can be stored in JSON or passed to/from | 8 // A Value represents something that can be stored in JSON or passed to/from |
9 // JavaScript. As such, it is NOT a generalized variant type, since only the | 9 // JavaScript. As such, it is NOT a generalized variant type, since only the |
10 // types supported by JavaScript/JSON are supported. | 10 // types supported by JavaScript/JSON are supported. |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 // Sets the Value associated with the given path starting from this object. | 237 // Sets the Value associated with the given path starting from this object. |
238 // A path has the form "<key>" or "<key>.<key>.[...]", where "." indexes | 238 // A path has the form "<key>" or "<key>.<key>.[...]", where "." indexes |
239 // into the next DictionaryValue down. Obviously, "." can't be used | 239 // into the next DictionaryValue down. Obviously, "." can't be used |
240 // within a key, but there are no other restrictions on keys. | 240 // within a key, but there are no other restrictions on keys. |
241 // If the key at any step of the way doesn't exist, or exists but isn't | 241 // If the key at any step of the way doesn't exist, or exists but isn't |
242 // a DictionaryValue, a new DictionaryValue will be created and attached | 242 // a DictionaryValue, a new DictionaryValue will be created and attached |
243 // to the path in that location. |in_value| must be non-null. | 243 // to the path in that location. |in_value| must be non-null. |
244 // Returns a pointer to the inserted value. | 244 // Returns a pointer to the inserted value. |
245 Value* Set(StringPiece path, std::unique_ptr<Value> in_value); | 245 Value* Set(StringPiece path, std::unique_ptr<Value> in_value); |
246 // Deprecated version of the above. TODO(estade): remove. | |
247 Value* Set(StringPiece path, Value* in_value); | |
248 | 246 |
249 // Convenience forms of Set(). These methods will replace any existing | 247 // Convenience forms of Set(). These methods will replace any existing |
250 // value at that path, even if it has a different type. | 248 // value at that path, even if it has a different type. |
251 Value* SetBoolean(StringPiece path, bool in_value); | 249 Value* SetBoolean(StringPiece path, bool in_value); |
252 Value* SetInteger(StringPiece path, int in_value); | 250 Value* SetInteger(StringPiece path, int in_value); |
253 Value* SetDouble(StringPiece path, double in_value); | 251 Value* SetDouble(StringPiece path, double in_value); |
254 Value* SetString(StringPiece path, StringPiece in_value); | 252 Value* SetString(StringPiece path, StringPiece in_value); |
255 Value* SetString(StringPiece path, const string16& in_value); | 253 Value* SetString(StringPiece path, const string16& in_value); |
256 DictionaryValue* SetDictionary(StringPiece path, | 254 DictionaryValue* SetDictionary(StringPiece path, |
257 std::unique_ptr<DictionaryValue> in_value); | 255 std::unique_ptr<DictionaryValue> in_value); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 return out << static_cast<const Value&>(value); | 551 return out << static_cast<const Value&>(value); |
554 } | 552 } |
555 | 553 |
556 // Stream operator so that enum class Types can be used in log statements. | 554 // Stream operator so that enum class Types can be used in log statements. |
557 BASE_EXPORT std::ostream& operator<<(std::ostream& out, | 555 BASE_EXPORT std::ostream& operator<<(std::ostream& out, |
558 const Value::Type& type); | 556 const Value::Type& type); |
559 | 557 |
560 } // namespace base | 558 } // namespace base |
561 | 559 |
562 #endif // BASE_VALUES_H_ | 560 #endif // BASE_VALUES_H_ |
OLD | NEW |