| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 // Clears any current contents of this dictionary. | 222 // Clears any current contents of this dictionary. |
| 223 void Clear(); | 223 void Clear(); |
| 224 | 224 |
| 225 // Sets the Value associated with the given path starting from this object. | 225 // Sets the Value associated with the given path starting from this object. |
| 226 // A path has the form "<key>" or "<key>.<key>.[...]", where "." indexes | 226 // A path has the form "<key>" or "<key>.<key>.[...]", where "." indexes |
| 227 // into the next DictionaryValue down. Obviously, "." can't be used | 227 // into the next DictionaryValue down. Obviously, "." can't be used |
| 228 // within a key, but there are no other restrictions on keys. | 228 // within a key, but there are no other restrictions on keys. |
| 229 // If the key at any step of the way doesn't exist, or exists but isn't | 229 // If the key at any step of the way doesn't exist, or exists but isn't |
| 230 // a DictionaryValue, a new DictionaryValue will be created and attached | 230 // a DictionaryValue, a new DictionaryValue will be created and attached |
| 231 // to the path in that location. | 231 // to the path in that location. |in_value| must be non-null. |
| 232 // Note that the dictionary takes ownership of the value referenced by | 232 void Set(const std::string& path, scoped_ptr<Value> in_value); |
| 233 // |in_value|, and therefore |in_value| must be non-NULL. | 233 // Deprecated version of the above. TODO(estade): remove. |
| 234 void Set(const std::string& path, Value* in_value); | 234 void Set(const std::string& path, Value* in_value); |
| 235 | 235 |
| 236 // Convenience forms of Set(). These methods will replace any existing | 236 // Convenience forms of Set(). These methods will replace any existing |
| 237 // value at that path, even if it has a different type. | 237 // value at that path, even if it has a different type. |
| 238 void SetBoolean(const std::string& path, bool in_value); | 238 void SetBoolean(const std::string& path, bool in_value); |
| 239 void SetInteger(const std::string& path, int in_value); | 239 void SetInteger(const std::string& path, int in_value); |
| 240 void SetDouble(const std::string& path, double in_value); | 240 void SetDouble(const std::string& path, double in_value); |
| 241 void SetString(const std::string& path, const std::string& in_value); | 241 void SetString(const std::string& path, const std::string& in_value); |
| 242 void SetString(const std::string& path, const string16& in_value); | 242 void SetString(const std::string& path, const string16& in_value); |
| 243 | 243 |
| 244 // Like Set(), but without special treatment of '.'. This allows e.g. URLs to | 244 // Like Set(), but without special treatment of '.'. This allows e.g. URLs to |
| 245 // be used as paths. | 245 // be used as paths. |
| 246 void SetWithoutPathExpansion(const std::string& key, |
| 247 scoped_ptr<Value> in_value); |
| 248 // Deprecated version of the above. TODO(estade): remove. |
| 246 void SetWithoutPathExpansion(const std::string& key, Value* in_value); | 249 void SetWithoutPathExpansion(const std::string& key, Value* in_value); |
| 247 | 250 |
| 248 // Convenience forms of SetWithoutPathExpansion(). | 251 // Convenience forms of SetWithoutPathExpansion(). |
| 249 void SetBooleanWithoutPathExpansion(const std::string& path, bool in_value); | 252 void SetBooleanWithoutPathExpansion(const std::string& path, bool in_value); |
| 250 void SetIntegerWithoutPathExpansion(const std::string& path, int in_value); | 253 void SetIntegerWithoutPathExpansion(const std::string& path, int in_value); |
| 251 void SetDoubleWithoutPathExpansion(const std::string& path, double in_value); | 254 void SetDoubleWithoutPathExpansion(const std::string& path, double in_value); |
| 252 void SetStringWithoutPathExpansion(const std::string& path, | 255 void SetStringWithoutPathExpansion(const std::string& path, |
| 253 const std::string& in_value); | 256 const std::string& in_value); |
| 254 void SetStringWithoutPathExpansion(const std::string& path, | 257 void SetStringWithoutPathExpansion(const std::string& path, |
| 255 const string16& in_value); | 258 const string16& in_value); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 } | 528 } |
| 526 | 529 |
| 527 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, | 530 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, |
| 528 const ListValue& value) { | 531 const ListValue& value) { |
| 529 return out << static_cast<const Value&>(value); | 532 return out << static_cast<const Value&>(value); |
| 530 } | 533 } |
| 531 | 534 |
| 532 } // namespace base | 535 } // namespace base |
| 533 | 536 |
| 534 #endif // BASE_VALUES_H_ | 537 #endif // BASE_VALUES_H_ |
| OLD | NEW |