| Index: base/values.h
|
| diff --git a/base/values.h b/base/values.h
|
| index 8becd3046ac0616bbb691b21ebabeed079850ef9..4d66d519c1b1ef13854de0ddd90dc04e37686f72 100644
|
| --- a/base/values.h
|
| +++ b/base/values.h
|
| @@ -61,6 +61,8 @@ class BASE_EXPORT Value {
|
| // Note: Do not add more types. See the file-level comment above for why.
|
| };
|
|
|
| + Value(); // A null value.
|
| +
|
| virtual ~Value();
|
|
|
| static std::unique_ptr<Value> CreateNullValue();
|
| @@ -73,10 +75,23 @@ class BASE_EXPORT Value {
|
| // safe to use the Type to determine whether you can cast from
|
| // Value* to (Implementing Class)*. Also, a Value object never changes
|
| // its type after construction.
|
| - Type GetType() const { return type_; }
|
| + Type GetType() const { return type_; } // DEPRECATED, use type().
|
| + Type type() const { return type_; }
|
|
|
| // Returns true if the current object represents a given type.
|
| bool IsType(Type type) const { return type == type_; }
|
| + bool is_bool() const { return type() == Type::BOOLEAN; }
|
| + bool is_int() const { return type() == Type::INTEGER; }
|
| + bool is_double() const { return type() == Type::DOUBLE; }
|
| + bool is_string() const { return type() == Type::STRING; }
|
| + bool is_blob() const { return type() == Type::BINARY; }
|
| + bool is_dict() const { return type() == Type::DICTIONARY; }
|
| + bool is_list() const { return type() == Type::LIST; }
|
| +
|
| + // These will all fatally assert if the type doesn't match.
|
| + bool GetBool() const;
|
| + int GetInt() const;
|
| + double GetDouble() const; // Implicitly converts from int if necessary.
|
|
|
| // These methods allow the convenient retrieval of the contents of the Value.
|
| // If the current object can be converted into the given type, the value is
|
| @@ -118,35 +133,35 @@ class BASE_EXPORT Value {
|
| // These aren't safe for end-users, but they are useful for subclasses.
|
| explicit Value(Type type);
|
| Value(const Value& that);
|
| + Value(Value&& that);
|
| Value& operator=(const Value& that);
|
| + Value& operator=(Value&& that);
|
| +
|
| + // TODO(brettw) move to public when FundamentalValue is gone.
|
| + explicit Value(bool in_bool);
|
| + explicit Value(int in_int);
|
| + explicit Value(double in_double);
|
|
|
| private:
|
| + void InternalCopyFrom(const Value& that);
|
| +
|
| Type type_;
|
| +
|
| + union {
|
| + bool bool_value_;
|
| + int int_value_;
|
| + double double_value_;
|
| + };
|
| };
|
|
|
| // FundamentalValue represents the simple fundamental types of values.
|
| +// TODO(brettw) remove when callers are updated to use raw Value.
|
| class BASE_EXPORT FundamentalValue : public Value {
|
| public:
|
| explicit FundamentalValue(bool in_value);
|
| explicit FundamentalValue(int in_value);
|
| explicit FundamentalValue(double in_value);
|
| ~FundamentalValue() override;
|
| -
|
| - // Overridden from Value:
|
| - bool GetAsBoolean(bool* out_value) const override;
|
| - bool GetAsInteger(int* out_value) const override;
|
| - // Values of both type Type::INTEGER and Type::DOUBLE can be obtained as
|
| - // doubles.
|
| - bool GetAsDouble(double* out_value) const override;
|
| - FundamentalValue* DeepCopy() const override;
|
| - bool Equals(const Value* other) const override;
|
| -
|
| - private:
|
| - union {
|
| - bool boolean_value_;
|
| - int integer_value_;
|
| - double double_value_;
|
| - };
|
| };
|
|
|
| class BASE_EXPORT StringValue : public Value {
|
|
|