| Index: base/values.h
|
| diff --git a/base/values.h b/base/values.h
|
| index 2719d272b35c38eccdc9562e1fde1905ee2041df..d69a68542751fda334ebc76c260ee53f658abe6a 100644
|
| --- a/base/values.h
|
| +++ b/base/values.h
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| @@ -46,6 +46,17 @@ typedef std::map<std::string, Value*> ValueMap;
|
| // creating instances of the subclasses.
|
| class Value {
|
| public:
|
| + enum ValueType {
|
| + TYPE_NULL = 0,
|
| + TYPE_BOOLEAN,
|
| + TYPE_INTEGER,
|
| + TYPE_REAL,
|
| + TYPE_STRING,
|
| + TYPE_BINARY,
|
| + TYPE_DICTIONARY,
|
| + TYPE_LIST
|
| + };
|
| +
|
| virtual ~Value();
|
|
|
| // Convenience methods for creating Value objects for various
|
| @@ -62,17 +73,6 @@ class Value {
|
| // is non-null, the new object has taken ownership of the buffer pointer.
|
| static BinaryValue* CreateBinaryValue(char* buffer, size_t size);
|
|
|
| - typedef enum {
|
| - TYPE_NULL = 0,
|
| - TYPE_BOOLEAN,
|
| - TYPE_INTEGER,
|
| - TYPE_REAL,
|
| - TYPE_STRING,
|
| - TYPE_BINARY,
|
| - TYPE_DICTIONARY,
|
| - TYPE_LIST
|
| - } ValueType;
|
| -
|
| // Returns the type of the value stored by the current Value object.
|
| // Each type will be implemented by only one subclass of Value, so it's
|
| // safe to use the ValueType to determine whether you can cast from
|
| @@ -167,6 +167,8 @@ class StringValue : public Value {
|
|
|
| class BinaryValue: public Value {
|
| public:
|
| + virtual ~BinaryValue();
|
| +
|
| // Creates a Value to represent a binary buffer. The new object takes
|
| // ownership of the pointer passed in, if successful.
|
| // Returns NULL if buffer is NULL.
|
| @@ -178,16 +180,14 @@ class BinaryValue: public Value {
|
| // Returns NULL if buffer is NULL.
|
| static BinaryValue* CreateWithCopiedBuffer(const char* buffer, size_t size);
|
|
|
| - virtual ~BinaryValue();
|
| -
|
| - // Subclassed methods
|
| - virtual Value* DeepCopy() const;
|
| - virtual bool Equals(const Value* other) const;
|
| -
|
| size_t GetSize() const { return size_; }
|
| char* GetBuffer() { return buffer_; }
|
| const char* GetBuffer() const { return buffer_; }
|
|
|
| + // Overridden from Value:
|
| + virtual Value* DeepCopy() const;
|
| + virtual bool Equals(const Value* other) const;
|
| +
|
| private:
|
| // Constructor is private so that only objects with valid buffer pointers
|
| // and size values can be created.
|
| @@ -207,10 +207,6 @@ class DictionaryValue : public Value {
|
| DictionaryValue();
|
| virtual ~DictionaryValue();
|
|
|
| - // Subclassed methods
|
| - virtual Value* DeepCopy() const;
|
| - virtual bool Equals(const Value* other) const;
|
| -
|
| // Returns true if the current dictionary has a value for the given key.
|
| bool HasKey(const std::string& key) const;
|
|
|
| @@ -333,6 +329,10 @@ class DictionaryValue : public Value {
|
| key_iterator begin_keys() const { return key_iterator(dictionary_.begin()); }
|
| key_iterator end_keys() const { return key_iterator(dictionary_.end()); }
|
|
|
| + // Overridden from Value:
|
| + virtual Value* DeepCopy() const;
|
| + virtual bool Equals(const Value* other) const;
|
| +
|
| private:
|
| ValueMap dictionary_;
|
|
|
| @@ -342,14 +342,12 @@ class DictionaryValue : public Value {
|
| // This type of Value represents a list of other Value values.
|
| class ListValue : public Value {
|
| public:
|
| + typedef ValueVector::iterator iterator;
|
| + typedef ValueVector::const_iterator const_iterator;
|
| +
|
| ListValue();
|
| ~ListValue();
|
|
|
| - // Subclassed methods
|
| - virtual bool GetAsList(ListValue** out_value);
|
| - virtual Value* DeepCopy() const;
|
| - virtual bool Equals(const Value* other) const;
|
| -
|
| // Clears the contents of this ListValue
|
| void Clear();
|
|
|
| @@ -411,15 +409,17 @@ class ListValue : public Value {
|
| }
|
|
|
| // Iteration
|
| - typedef ValueVector::iterator iterator;
|
| - typedef ValueVector::const_iterator const_iterator;
|
| -
|
| ListValue::iterator begin() { return list_.begin(); }
|
| ListValue::iterator end() { return list_.end(); }
|
|
|
| ListValue::const_iterator begin() const { return list_.begin(); }
|
| ListValue::const_iterator end() const { return list_.end(); }
|
|
|
| + // Overridden from Value:
|
| + virtual bool GetAsList(ListValue** out_value);
|
| + virtual Value* DeepCopy() const;
|
| + virtual bool Equals(const Value* other) const;
|
| +
|
| private:
|
| ValueVector list_;
|
|
|
|
|