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

Unified Diff: base/values.h

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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/trace_event/trace_event_unittest.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 21c3f5fb5cfcd64cc81569057c74f4b11d0cdafa..14a02e4077ea3ea7cad83a9ee1275360c033fbc1 100644
--- a/base/values.h
+++ b/base/values.h
@@ -49,15 +49,15 @@ class Value;
// See the file-level comment above for more information.
class BASE_EXPORT Value {
public:
- enum Type {
- TYPE_NULL = 0,
- TYPE_BOOLEAN,
- TYPE_INTEGER,
- TYPE_DOUBLE,
- TYPE_STRING,
- TYPE_BINARY,
- TYPE_DICTIONARY,
- TYPE_LIST
+ enum class Type {
+ NONE = 0,
+ BOOLEAN,
+ INTEGER,
+ DOUBLE,
+ STRING,
+ BINARY,
+ DICTIONARY,
+ LIST
// Note: Do not add more types. See the file-level comment above for why.
};
@@ -134,7 +134,7 @@ class BASE_EXPORT FundamentalValue : public Value {
// 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
+ // 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;
@@ -287,7 +287,7 @@ class BASE_EXPORT DictionaryValue : public Value {
// |out_value| is optional and will only be set if non-NULL.
bool GetBoolean(StringPiece path, bool* out_value) const;
bool GetInteger(StringPiece path, int* out_value) const;
- // Values of both type TYPE_INTEGER and TYPE_DOUBLE can be obtained as
+ // Values of both type Type::INTEGER and Type::DOUBLE can be obtained as
// doubles.
bool GetDouble(StringPiece path, double* out_value) const;
bool GetString(StringPiece path, std::string* out_value) const;
@@ -427,7 +427,7 @@ class BASE_EXPORT ListValue : public Value {
// |out_value| is optional and will only be set if non-NULL.
bool GetBoolean(size_t index, bool* out_value) const;
bool GetInteger(size_t index, int* out_value) const;
- // Values of both type TYPE_INTEGER and TYPE_DOUBLE can be obtained as
+ // Values of both type Type::INTEGER and Type::DOUBLE can be obtained as
// doubles.
bool GetDouble(size_t index, double* out_value) const;
bool GetString(size_t index, std::string* out_value) const;
@@ -562,6 +562,10 @@ BASE_EXPORT inline std::ostream& operator<<(std::ostream& out,
return out << static_cast<const Value&>(value);
}
+// Stream operator so that enum class Types can be used in log statements.
+BASE_EXPORT std::ostream& operator<<(std::ostream& out,
+ const Value::Type& type);
+
} // namespace base
#endif // BASE_VALUES_H_
« no previous file with comments | « base/trace_event/trace_event_unittest.cc ('k') | base/values.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698