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

Side by Side Diff: base/values.h

Issue 614103004: replace 'virtual ... OVERRIDE' with '... override' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: process base/ Created 6 years, 2 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
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 // FundamentalValue represents the simple fundamental types of values. 118 // FundamentalValue represents the simple fundamental types of values.
119 class BASE_EXPORT FundamentalValue : public Value { 119 class BASE_EXPORT FundamentalValue : public Value {
120 public: 120 public:
121 explicit FundamentalValue(bool in_value); 121 explicit FundamentalValue(bool in_value);
122 explicit FundamentalValue(int in_value); 122 explicit FundamentalValue(int in_value);
123 explicit FundamentalValue(double in_value); 123 explicit FundamentalValue(double in_value);
124 virtual ~FundamentalValue(); 124 virtual ~FundamentalValue();
125 125
126 // Overridden from Value: 126 // Overridden from Value:
127 virtual bool GetAsBoolean(bool* out_value) const OVERRIDE; 127 bool GetAsBoolean(bool* out_value) const override;
128 virtual bool GetAsInteger(int* out_value) const OVERRIDE; 128 bool GetAsInteger(int* out_value) const override;
129 // Values of both type TYPE_INTEGER and TYPE_DOUBLE can be obtained as 129 // Values of both type TYPE_INTEGER and TYPE_DOUBLE can be obtained as
130 // doubles. 130 // doubles.
131 virtual bool GetAsDouble(double* out_value) const OVERRIDE; 131 bool GetAsDouble(double* out_value) const override;
132 virtual FundamentalValue* DeepCopy() const OVERRIDE; 132 FundamentalValue* DeepCopy() const override;
133 virtual bool Equals(const Value* other) const OVERRIDE; 133 bool Equals(const Value* other) const override;
134 134
135 private: 135 private:
136 union { 136 union {
137 bool boolean_value_; 137 bool boolean_value_;
138 int integer_value_; 138 int integer_value_;
139 double double_value_; 139 double double_value_;
140 }; 140 };
141 }; 141 };
142 142
143 class BASE_EXPORT StringValue : public Value { 143 class BASE_EXPORT StringValue : public Value {
144 public: 144 public:
145 // Initializes a StringValue with a UTF-8 narrow character string. 145 // Initializes a StringValue with a UTF-8 narrow character string.
146 explicit StringValue(const std::string& in_value); 146 explicit StringValue(const std::string& in_value);
147 147
148 // Initializes a StringValue with a string16. 148 // Initializes a StringValue with a string16.
149 explicit StringValue(const string16& in_value); 149 explicit StringValue(const string16& in_value);
150 150
151 virtual ~StringValue(); 151 virtual ~StringValue();
152 152
153 // Returns |value_| as a pointer or reference. 153 // Returns |value_| as a pointer or reference.
154 std::string* GetString(); 154 std::string* GetString();
155 const std::string& GetString() const; 155 const std::string& GetString() const;
156 156
157 // Overridden from Value: 157 // Overridden from Value:
158 virtual bool GetAsString(std::string* out_value) const OVERRIDE; 158 bool GetAsString(std::string* out_value) const override;
159 virtual bool GetAsString(string16* out_value) const OVERRIDE; 159 bool GetAsString(string16* out_value) const override;
160 virtual bool GetAsString(const StringValue** out_value) const OVERRIDE; 160 bool GetAsString(const StringValue** out_value) const override;
161 virtual StringValue* DeepCopy() const OVERRIDE; 161 StringValue* DeepCopy() const override;
162 virtual bool Equals(const Value* other) const OVERRIDE; 162 bool Equals(const Value* other) const override;
163 163
164 private: 164 private:
165 std::string value_; 165 std::string value_;
166 }; 166 };
167 167
168 class BASE_EXPORT BinaryValue: public Value { 168 class BASE_EXPORT BinaryValue: public Value {
169 public: 169 public:
170 // Creates a BinaryValue with a null buffer and size of 0. 170 // Creates a BinaryValue with a null buffer and size of 0.
171 BinaryValue(); 171 BinaryValue();
172 172
173 // Creates a BinaryValue, taking ownership of the bytes pointed to by 173 // Creates a BinaryValue, taking ownership of the bytes pointed to by
174 // |buffer|. 174 // |buffer|.
175 BinaryValue(scoped_ptr<char[]> buffer, size_t size); 175 BinaryValue(scoped_ptr<char[]> buffer, size_t size);
176 176
177 virtual ~BinaryValue(); 177 virtual ~BinaryValue();
178 178
179 // For situations where you want to keep ownership of your buffer, this 179 // For situations where you want to keep ownership of your buffer, this
180 // factory method creates a new BinaryValue by copying the contents of the 180 // factory method creates a new BinaryValue by copying the contents of the
181 // buffer that's passed in. 181 // buffer that's passed in.
182 static BinaryValue* CreateWithCopiedBuffer(const char* buffer, size_t size); 182 static BinaryValue* CreateWithCopiedBuffer(const char* buffer, size_t size);
183 183
184 size_t GetSize() const { return size_; } 184 size_t GetSize() const { return size_; }
185 185
186 // May return NULL. 186 // May return NULL.
187 char* GetBuffer() { return buffer_.get(); } 187 char* GetBuffer() { return buffer_.get(); }
188 const char* GetBuffer() const { return buffer_.get(); } 188 const char* GetBuffer() const { return buffer_.get(); }
189 189
190 // Overridden from Value: 190 // Overridden from Value:
191 virtual BinaryValue* DeepCopy() const OVERRIDE; 191 BinaryValue* DeepCopy() const override;
192 virtual bool Equals(const Value* other) const OVERRIDE; 192 bool Equals(const Value* other) const override;
193 193
194 private: 194 private:
195 scoped_ptr<char[]> buffer_; 195 scoped_ptr<char[]> buffer_;
196 size_t size_; 196 size_t size_;
197 197
198 DISALLOW_COPY_AND_ASSIGN(BinaryValue); 198 DISALLOW_COPY_AND_ASSIGN(BinaryValue);
199 }; 199 };
200 200
201 // DictionaryValue provides a key-value dictionary with (optional) "path" 201 // DictionaryValue provides a key-value dictionary with (optional) "path"
202 // parsing for recursive access; see the comment at the top of the file. Keys 202 // parsing for recursive access; see the comment at the top of the file. Keys
203 // are |std::string|s and should be UTF-8 encoded. 203 // are |std::string|s and should be UTF-8 encoded.
204 class BASE_EXPORT DictionaryValue : public Value { 204 class BASE_EXPORT DictionaryValue : public Value {
205 public: 205 public:
206 DictionaryValue(); 206 DictionaryValue();
207 virtual ~DictionaryValue(); 207 virtual ~DictionaryValue();
208 208
209 // Overridden from Value: 209 // Overridden from Value:
210 virtual bool GetAsDictionary(DictionaryValue** out_value) OVERRIDE; 210 bool GetAsDictionary(DictionaryValue** out_value) override;
211 virtual bool GetAsDictionary( 211 bool GetAsDictionary(const DictionaryValue** out_value) const override;
212 const DictionaryValue** out_value) const OVERRIDE;
213 212
214 // Returns true if the current dictionary has a value for the given key. 213 // Returns true if the current dictionary has a value for the given key.
215 bool HasKey(const std::string& key) const; 214 bool HasKey(const std::string& key) const;
216 215
217 // Returns the number of Values in this dictionary. 216 // Returns the number of Values in this dictionary.
218 size_t size() const { return dictionary_.size(); } 217 size_t size() const { return dictionary_.size(); }
219 218
220 // Returns whether the dictionary is empty. 219 // Returns whether the dictionary is empty.
221 bool empty() const { return dictionary_.empty(); } 220 bool empty() const { return dictionary_.empty(); }
222 221
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 354
356 const std::string& key() const { return it_->first; } 355 const std::string& key() const { return it_->first; }
357 const Value& value() const { return *it_->second; } 356 const Value& value() const { return *it_->second; }
358 357
359 private: 358 private:
360 const DictionaryValue& target_; 359 const DictionaryValue& target_;
361 ValueMap::const_iterator it_; 360 ValueMap::const_iterator it_;
362 }; 361 };
363 362
364 // Overridden from Value: 363 // Overridden from Value:
365 virtual DictionaryValue* DeepCopy() const OVERRIDE; 364 DictionaryValue* DeepCopy() const override;
366 virtual bool Equals(const Value* other) const OVERRIDE; 365 bool Equals(const Value* other) const override;
367 366
368 private: 367 private:
369 ValueMap dictionary_; 368 ValueMap dictionary_;
370 369
371 DISALLOW_COPY_AND_ASSIGN(DictionaryValue); 370 DISALLOW_COPY_AND_ASSIGN(DictionaryValue);
372 }; 371 };
373 372
374 // This type of Value represents a list of other Value values. 373 // This type of Value represents a list of other Value values.
375 class BASE_EXPORT ListValue : public Value { 374 class BASE_EXPORT ListValue : public Value {
376 public: 375 public:
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 virtual void Swap(ListValue* other); 468 virtual void Swap(ListValue* other);
470 469
471 // Iteration. 470 // Iteration.
472 iterator begin() { return list_.begin(); } 471 iterator begin() { return list_.begin(); }
473 iterator end() { return list_.end(); } 472 iterator end() { return list_.end(); }
474 473
475 const_iterator begin() const { return list_.begin(); } 474 const_iterator begin() const { return list_.begin(); }
476 const_iterator end() const { return list_.end(); } 475 const_iterator end() const { return list_.end(); }
477 476
478 // Overridden from Value: 477 // Overridden from Value:
479 virtual bool GetAsList(ListValue** out_value) OVERRIDE; 478 bool GetAsList(ListValue** out_value) override;
480 virtual bool GetAsList(const ListValue** out_value) const OVERRIDE; 479 bool GetAsList(const ListValue** out_value) const override;
481 virtual ListValue* DeepCopy() const OVERRIDE; 480 ListValue* DeepCopy() const override;
482 virtual bool Equals(const Value* other) const OVERRIDE; 481 bool Equals(const Value* other) const override;
483 482
484 private: 483 private:
485 ValueVector list_; 484 ValueVector list_;
486 485
487 DISALLOW_COPY_AND_ASSIGN(ListValue); 486 DISALLOW_COPY_AND_ASSIGN(ListValue);
488 }; 487 };
489 488
490 // This interface is implemented by classes that know how to serialize and 489 // This interface is implemented by classes that know how to serialize and
491 // deserialize Value objects. 490 // deserialize Value objects.
492 class BASE_EXPORT ValueSerializer { 491 class BASE_EXPORT ValueSerializer {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 } 525 }
527 526
528 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, 527 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out,
529 const ListValue& value) { 528 const ListValue& value) {
530 return out << static_cast<const Value&>(value); 529 return out << static_cast<const Value&>(value);
531 } 530 }
532 531
533 } // namespace base 532 } // namespace base
534 533
535 #endif // BASE_VALUES_H_ 534 #endif // BASE_VALUES_H_
OLDNEW
« base/i18n/rtl.cc ('K') | « base/tools_sanity_unittest.cc ('k') | base/win/enum_variant.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698