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

Side by Side Diff: base/values.h

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 unified diff | Download patch
« no previous file with comments | « no previous file | base/values.cc » ('j') | base/values.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file specifies a recursive data storage class called Value intended for 5 // This file specifies a recursive data storage class called Value intended for
6 // storing settings and other persistable data. 6 // storing settings and other persistable data.
7 // 7 //
8 // A Value represents something that can be stored in JSON or passed to/from 8 // A Value represents something that can be stored in JSON or passed to/from
9 // JavaScript. As such, it is NOT a generalized variant type, since only the 9 // JavaScript. As such, it is NOT a generalized variant type, since only the
10 // types supported by JavaScript/JSON are supported. 10 // types supported by JavaScript/JSON are supported.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 TYPE_BINARY, 58 TYPE_BINARY,
59 TYPE_DICTIONARY, 59 TYPE_DICTIONARY,
60 TYPE_LIST 60 TYPE_LIST
61 // Note: Do not add more types. See the file-level comment above for why. 61 // Note: Do not add more types. See the file-level comment above for why.
62 }; 62 };
63 63
64 virtual ~Value(); 64 virtual ~Value();
65 65
66 static std::unique_ptr<Value> CreateNullValue(); 66 static std::unique_ptr<Value> CreateNullValue();
67 67
68 // Returns the name for a given |type|.
69 static const char* GetTypeName(Type type);
70
68 // Returns the type of the value stored by the current Value object. 71 // Returns the type of the value stored by the current Value object.
69 // Each type will be implemented by only one subclass of Value, so it's 72 // Each type will be implemented by only one subclass of Value, so it's
70 // safe to use the Type to determine whether you can cast from 73 // safe to use the Type to determine whether you can cast from
71 // Value* to (Implementing Class)*. Also, a Value object never changes 74 // Value* to (Implementing Class)*. Also, a Value object never changes
72 // its type after construction. 75 // its type after construction.
73 Type GetType() const { return type_; } 76 Type GetType() const { return type_; }
74 77
75 // Returns true if the current object represents a given type. 78 // Returns true if the current object represents a given type.
76 bool IsType(Type type) const { return type == type_; } 79 bool IsType(Type type) const { return type == type_; }
77 80
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 563 }
561 564
562 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, 565 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out,
563 const ListValue& value) { 566 const ListValue& value) {
564 return out << static_cast<const Value&>(value); 567 return out << static_cast<const Value&>(value);
565 } 568 }
566 569
567 } // namespace base 570 } // namespace base
568 571
569 #endif // BASE_VALUES_H_ 572 #endif // BASE_VALUES_H_
OLDNEW
« no previous file with comments | « no previous file | base/values.cc » ('j') | base/values.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698