Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1127)

Unified Diff: base/values.h

Issue 7649006: more changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix another typo Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/value_conversions.cc ('k') | base/values.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values.h
diff --git a/base/values.h b/base/values.h
index a30791bc6357c671f56c02c0c39e61027c11aabb..b9c3ecf3bffcf43963aacabcb8159347dc8770a4 100644
--- a/base/values.h
+++ b/base/values.h
@@ -40,8 +40,8 @@
namespace base {
class BinaryValue;
+class BooleanValue;
class DictionaryValue;
-class FundamentalValue;
class ListValue;
class StringValue;
class Value;
@@ -49,9 +49,7 @@ class Value;
typedef std::vector<Value*> ValueVector;
typedef std::map<std::string, Value*> ValueMap;
-// The Value class is the base class for Values. A Value can be instantiated
-// via the Create*Value() factory methods, or by directly creating instances of
-// the subclasses.
+// The Value class is the base class for Values.
class BASE_EXPORT Value {
public:
enum Type {
@@ -67,16 +65,6 @@ class BASE_EXPORT Value {
virtual ~Value();
- // Convenience methods for creating Value objects for various
- // kinds of values without thinking about which class implements them.
- // These can always be expected to return a valid Value*.
- static Value* CreateNullValue();
- static FundamentalValue* CreateBooleanValue(bool in_value);
- static FundamentalValue* CreateIntegerValue(int in_value);
- static FundamentalValue* CreateDoubleValue(double in_value);
- static StringValue* CreateStringValue(const std::string& in_value);
- static StringValue* CreateStringValue(const string16& in_value);
-
// 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 Type to determine whether you can cast from
@@ -110,12 +98,12 @@ class BASE_EXPORT Value {
virtual bool Equals(const Value* other) const;
// Compares if two Value objects have equal contents. Can handle NULLs.
- // NULLs are considered equal but different from Value::CreateNullValue().
+ // NULLs are considered equal but different from NullValue.
static bool Equals(const Value* a, const Value* b);
protected:
- // This isn't safe for end-users (they should use the Create*Value()
- // static methods above), but it's useful for subclasses.
+ // This isn't safe for end-users (they should use the *Value::New()),
+ // but it's useful for subclasses.
explicit Value(Type type);
private:
@@ -126,29 +114,50 @@ class BASE_EXPORT Value {
DISALLOW_COPY_AND_ASSIGN(Value);
};
-// FundamentalValue represents the simple fundamental types of values.
-class BASE_EXPORT FundamentalValue : public Value {
+BASE_EXPORT Value* NullValue();
+BASE_EXPORT BooleanValue* TrueValue();
+BASE_EXPORT BooleanValue* FalseValue();
+
+class BASE_EXPORT BooleanValue : public Value {
public:
- explicit FundamentalValue(bool in_value);
- explicit FundamentalValue(int in_value);
- explicit FundamentalValue(double in_value);
- virtual ~FundamentalValue();
+ explicit BooleanValue(bool value);
+ virtual ~BooleanValue();
+
+ static BooleanValue* New(bool value);
// Overridden from Value:
virtual bool GetAsBoolean(bool* out_value) const OVERRIDE;
+ virtual BooleanValue* DeepCopy() const OVERRIDE;
+ virtual bool Equals(const Value* other) const OVERRIDE;
+
+ private:
+ bool value_;
+
+ DISALLOW_COPY_AND_ASSIGN(BooleanValue);
+};
+
+class BASE_EXPORT NumberValue : public Value {
+ public:
+ explicit NumberValue(int value);
+ explicit NumberValue(double value);
+ virtual ~NumberValue();
+
+ static NumberValue* New(int value);
+ static NumberValue* New(double value);
+
+ // Overridden from Value:
virtual bool GetAsInteger(int* out_value) const OVERRIDE;
virtual bool GetAsDouble(double* out_value) const OVERRIDE;
- virtual FundamentalValue* DeepCopy() const OVERRIDE;
+ virtual NumberValue* DeepCopy() const OVERRIDE;
virtual bool Equals(const Value* other) const OVERRIDE;
private:
union {
- bool boolean_value_;
int integer_value_;
double double_value_;
};
- DISALLOW_COPY_AND_ASSIGN(FundamentalValue);
+ DISALLOW_COPY_AND_ASSIGN(NumberValue);
};
class BASE_EXPORT StringValue : public Value {
@@ -161,6 +170,9 @@ class BASE_EXPORT StringValue : public Value {
virtual ~StringValue();
+ static StringValue* New(const std::string& value);
+ static StringValue* New(const string16& value);
+
// Overridden from Value:
virtual bool GetAsString(std::string* out_value) const OVERRIDE;
virtual bool GetAsString(string16* out_value) const OVERRIDE;
« no previous file with comments | « base/value_conversions.cc ('k') | base/values.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698