Lines Matching refs:Value
5 // This file specifies a recursive data storage class called Value intended for
8 // A Value represents something that can be stored in JSON or passed to/from
14 // something like this, either use a double or make a string value containing
42 class Value;
44 typedef std::vector<Value*> ValueVector;
45 typedef std::map<std::string, Value*> ValueMap;
47 // The Value class is the base class for Values. A Value can be instantiated
48 // via the Create*Value() factory methods, or by directly creating instances of
52 class BASE_EXPORT Value {
66 virtual ~Value();
68 static scoped_ptr<Value> CreateNullValue();
70 // Returns the type of the value stored by the current Value object.
71 // Each type will be implemented by only one subclass of Value, so it's
73 // Value* to (Implementing Class)*. Also, a Value object never changes
80 // These methods allow the convenient retrieval of the contents of the Value.
81 // If the current object can be converted into the given type, the value is
96 // This creates a deep copy of the entire Value tree, and returns a pointer
101 virtual Value* DeepCopy() const;
103 scoped_ptr<Value> CreateDeepCopy() const;
105 // Compares if two Value objects have equal contents.
106 virtual bool Equals(const Value* other) const;
108 // Compares if two Value objects have equal contents. Can handle NULLs.
109 // NULLs are considered equal but different from Value::CreateNullValue().
110 static bool Equals(const Value* a, const Value* b);
114 explicit Value(Type type);
115 Value(const Value& that);
116 Value& operator=(const Value& that);
123 class BASE_EXPORT FundamentalValue : public Value {
130 // Overridden from Value:
137 bool Equals(const Value* other) const override;
147 class BASE_EXPORT StringValue : public Value {
158 // Overridden from Value:
162 bool Equals(const Value* other) const override;
168 class BASE_EXPORT BinaryValue : public Value {
190 // Overridden from Value:
193 bool Equals(const Value* other) const override;
202 // DictionaryValue provides a key-value dictionary with (optional) "path"
205 class BASE_EXPORT DictionaryValue : public Value {
207 // Returns |value| if it is a dictionary, nullptr otherwise.
208 static scoped_ptr<DictionaryValue> From(scoped_ptr<Value> value);
213 // Overridden from Value:
217 // Returns true if the current dictionary has a value for the given key.
229 // Sets the Value associated with the given path starting from this object.
236 void Set(const std::string& path, scoped_ptr<Value> in_value);
238 void Set(const std::string& path, Value* in_value);
241 // value at that path, even if it has a different type.
250 scoped_ptr<Value> in_value);
252 void SetWithoutPathExpansion(const std::string& key, Value* in_value);
261 // Gets the Value associated with the given path starting from this object.
264 // successfully, the value for the last key in the path will be returned
267 // Note that the dictionary always owns the value that's returned.
269 bool Get(StringPiece path, const Value** out_value) const;
270 bool Get(StringPiece path, Value** out_value);
272 // These are convenience forms of Get(). The value will be retrieved
273 // and the return value will be true if the path is valid and the value at
294 const Value** out_value) const;
295 bool GetWithoutPathExpansion(const std::string& key, Value** out_value);
314 // Removes the Value with the specified path from this dictionary (or one
316 // If |out_value| is non-NULL, the removed Value will be passed out via
317 // |out_value|. If |out_value| is NULL, the removed value will be deleted.
320 virtual bool Remove(const std::string& path, scoped_ptr<Value>* out_value);
325 scoped_ptr<Value>* out_value);
328 // after removing the value at |path|.
330 scoped_ptr<Value>* out_value);
357 const Value& value() const { return *it_->second; }
364 // Overridden from Value:
368 bool Equals(const Value* other) const override;
376 // This type of Value represents a list of other Value values.
377 class BASE_EXPORT ListValue : public Value {
382 // Returns |value| if it is a list, nullptr otherwise.
383 static scoped_ptr<ListValue> From(scoped_ptr<Value> value);
397 // Sets the list item at the given index to be the Value specified by
398 // the value given. If the index beyond the current end of the list, null
401 // the value is a null pointer.
402 bool Set(size_t index, Value* in_value);
404 Value> in_value);
406 // Gets the Value at the given index. Modifies |out_value| (and returns true)
408 // Note that the list always owns the Value passed out via |out_value|.
410 bool Get(size_t index, const Value** out_value) const;
411 bool Get(size_t index, Value** out_value);
414 // only if the index is valid and the Value at that index can be returned
430 // Removes the Value with the specified index from this list.
431 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be
432 // passed out via |out_value|. If |out_value| is NULL, the removed value will
435 virtual bool Remove(size_t index, scoped_ptr<Value>* out_value);
437 // Removes the first instance of |value| found in the list, if any, and
438 // deletes it. |index| is the location where |value| was found. Returns false
440 bool Remove(const Value& value, size_t* index);
442 // Removes the element at |iter|. If |out_value| is NULL, the value will be
443 // deleted, otherwise ownership of the value is passed back to the caller.
446 iterator Erase(iterator iter, scoped_ptr<Value>* out_value);
448 // Appends a Value to the end of the list.
449 void Append(scoped_ptr<Value> in_value);
451 void Append(Value* in_value);
460 // Appends a Value if it's not already present. Takes ownership of the
461 // |in_value|. Returns true if successful, or false if the value was already
462 // present. If the value was already present the |in_value| is deleted.
463 bool AppendIfNotPresent(Value* in_value);
465 // Insert a Value at index.
467 bool Insert(size_t index, Value* in_value);
469 // Searches for the first instance of |value| in the list using the Equals
470 // method of the Value type.
472 const_iterator Find(const Value& value) const;
484 // Overridden from Value:
488 bool Equals(const Value* other) const override;
503 BASE_EXPORT std::ostream& operator<<(std::ostream& out, const Value& value);
506 const FundamentalValue& value) {
507 return out << static_cast<const Value&>(value);
511 const StringValue& value) {
512 return out << static_cast<const Value&>(value);
516 const DictionaryValue& value) {
517 return out << static_cast<const Value&>(value);
521 const ListValue& value) {
522 return out << static_cast<const Value&>(value);