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

Unified Diff: base/values.cc

Issue 2151793002: Add base::Value::GetTypeName(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments, fix build Created 4 years, 5 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/values.h ('k') | chromeos/network/onc/onc_validator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values.cc
diff --git a/base/values.cc b/base/values.cc
index 4772b647748f112260667c75cb570979b034c4b4..2021cd2661ec131b3b78fc156ec6acef20b75e4a 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -21,6 +21,11 @@ namespace base {
namespace {
+const char* const kTypeNames[] = {"null", "boolean", "integer", "double",
+ "string", "binary", "dictionary", "list"};
+static_assert(arraysize(kTypeNames) == Value::TYPE_LIST + 1,
+ "kTypeNames Has Wrong Size");
+
std::unique_ptr<Value> CopyWithoutEmptyChildren(const Value& node);
// Make a deep copy of |node|, but don't include empty lists or dictionaries
@@ -77,6 +82,11 @@ std::unique_ptr<Value> Value::CreateNullValue() {
return WrapUnique(new Value(TYPE_NULL));
}
+// static
+const char* Value::GetTypeName(Value::Type type) {
+ return kTypeNames[type];
dcheng 2016/07/15 07:05:12 Or perhaps just DCHECK(type < arraysize(kTypeNames
Lei Zhang 2016/07/15 07:34:10 Done.
+}
+
bool Value::GetAsBinary(const BinaryValue** out_value) const {
return false;
}
« no previous file with comments | « base/values.h ('k') | chromeos/network/onc/onc_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698