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

Side by Side Diff: base/values.h

Issue 2804263002: IsValid (Closed)
Patch Set: Created 3 years, 8 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') | no next file with comments »
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // Returns true if the current object represents a given type. 114 // Returns true if the current object represents a given type.
115 bool IsType(Type type) const { return type == type_; } 115 bool IsType(Type type) const { return type == type_; }
116 bool is_bool() const { return type() == Type::BOOLEAN; } 116 bool is_bool() const { return type() == Type::BOOLEAN; }
117 bool is_int() const { return type() == Type::INTEGER; } 117 bool is_int() const { return type() == Type::INTEGER; }
118 bool is_double() const { return type() == Type::DOUBLE; } 118 bool is_double() const { return type() == Type::DOUBLE; }
119 bool is_string() const { return type() == Type::STRING; } 119 bool is_string() const { return type() == Type::STRING; }
120 bool is_blob() const { return type() == Type::BINARY; } 120 bool is_blob() const { return type() == Type::BINARY; }
121 bool is_dict() const { return type() == Type::DICTIONARY; } 121 bool is_dict() const { return type() == Type::DICTIONARY; }
122 bool is_list() const { return type() == Type::LIST; } 122 bool is_list() const { return type() == Type::LIST; }
123 123
124 bool IsValid() const;
125
124 // These will all fatally assert if the type doesn't match. 126 // These will all fatally assert if the type doesn't match.
125 bool GetBool() const; 127 bool GetBool() const;
126 int GetInt() const; 128 int GetInt() const;
127 double GetDouble() const; // Implicitly converts from int if necessary. 129 double GetDouble() const; // Implicitly converts from int if necessary.
128 const std::string& GetString() const; 130 const std::string& GetString() const;
129 const std::vector<char>& GetBlob() const; 131 const std::vector<char>& GetBlob() const;
130 132
131 size_t GetSize() const; // DEPRECATED, use GetBlob().size() instead. 133 size_t GetSize() const; // DEPRECATED, use GetBlob().size() instead.
132 const char* GetBuffer() const; // DEPRECATED, use GetBlob().data() instead. 134 const char* GetBuffer() const; // DEPRECATED, use GetBlob().data() instead.
133 135
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 return out << static_cast<const Value&>(value); 532 return out << static_cast<const Value&>(value);
531 } 533 }
532 534
533 // Stream operator so that enum class Types can be used in log statements. 535 // Stream operator so that enum class Types can be used in log statements.
534 BASE_EXPORT std::ostream& operator<<(std::ostream& out, 536 BASE_EXPORT std::ostream& operator<<(std::ostream& out,
535 const Value::Type& type); 537 const Value::Type& type);
536 538
537 } // namespace base 539 } // namespace base
538 540
539 #endif // BASE_VALUES_H_ 541 #endif // BASE_VALUES_H_
OLDNEW
« no previous file with comments | « no previous file | base/values.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698