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

Side by Side Diff: base/values.h

Issue 3041038: Make ValuesTest use std::strings (instead of wstrings) for dictionary keys. (Closed)
Patch Set: comment fix Created 10 years, 4 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_unittest.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 5 // This file specifies a recursive data storage class called Value intended for
6 // intended for storing setting and other persistable data. 6 // storing setting and other persistable data. It includes the ability to
7 // It includes the ability to specify (recursive) lists and dictionaries, so 7 // specify (recursive) lists and dictionaries, so it's fairly expressive.
8 // it's fairly expressive. However, the API is optimized for the common case, 8 // However, the API is optimized for the common case, namely storing a
9 // namely storing a hierarchical tree of simple values. Given a 9 // hierarchical tree of simple values. Given a DictionaryValue root, you can
10 // DictionaryValue root, you can easily do things like: 10 // easily do things like:
11 // 11 //
12 // root->SetString(L"global.pages.homepage", L"http://goateleporter.com"); 12 // root->SetString("global.pages.homepage", "http://goateleporter.com");
13 // std::wstring homepage = L"http://google.com"; // default/fallback value 13 // std::string homepage = "http://google.com"; // default/fallback value
14 // root->GetString(L"global.pages.homepage", &homepage); 14 // root->GetString("global.pages.homepage", &homepage);
15 // 15 //
16 // where "global" and "pages" are also DictionaryValues, and "homepage" 16 // where "global" and "pages" are also DictionaryValues, and "homepage" is a
17 // is a string setting. If some elements of the path didn't exist yet, 17 // string setting. If some elements of the path didn't exist yet, the
18 // the SetString() method would create the missing elements and attach them 18 // SetString() method would create the missing elements and attach them to root
19 // to root before attaching the homepage value. 19 // before attaching the homepage value.
20 20
21 #ifndef BASE_VALUES_H_ 21 #ifndef BASE_VALUES_H_
22 #define BASE_VALUES_H_ 22 #define BASE_VALUES_H_
23 #pragma once 23 #pragma once
24 24
25 #include <iterator> 25 #include <iterator>
26 #include <map> 26 #include <map>
27 #include <string> 27 #include <string>
28 #include <vector> 28 #include <vector>
29 29
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // Constructor is private so that only objects with valid buffer pointers 195 // Constructor is private so that only objects with valid buffer pointers
196 // and size values can be created. 196 // and size values can be created.
197 BinaryValue(char* buffer, size_t size); 197 BinaryValue(char* buffer, size_t size);
198 198
199 char* buffer_; 199 char* buffer_;
200 size_t size_; 200 size_t size_;
201 201
202 DISALLOW_COPY_AND_ASSIGN(BinaryValue); 202 DISALLOW_COPY_AND_ASSIGN(BinaryValue);
203 }; 203 };
204 204
205 // DictionaryValue provides a key-value dictionary with (optional) "path"
206 // parsing for recursive access; see the comment at the top of the file. Keys
207 // are |std::string|s and should be UTF-8 encoded.
205 // TODO(viettrungluu): Things marked DEPRECATED will be removed. crbug.com/23581 208 // TODO(viettrungluu): Things marked DEPRECATED will be removed. crbug.com/23581
206 class DictionaryValue : public Value { 209 class DictionaryValue : public Value {
207 public: 210 public:
208 DictionaryValue(); 211 DictionaryValue();
209 ~DictionaryValue(); 212 ~DictionaryValue();
210 213
211 // Subclassed methods 214 // Subclassed methods
212 Value* DeepCopy() const; 215 Value* DeepCopy() const;
213 virtual bool Equals(const Value* other) const; 216 virtual bool Equals(const Value* other) const;
214 217
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // This method deserializes the subclass-specific format into a Value object. 485 // This method deserializes the subclass-specific format into a Value object.
483 // If the return value is non-NULL, the caller takes ownership of returned 486 // If the return value is non-NULL, the caller takes ownership of returned
484 // Value. If the return value is NULL, and if error_code is non-NULL, 487 // Value. If the return value is NULL, and if error_code is non-NULL,
485 // error_code will be set with the underlying error. 488 // error_code will be set with the underlying error.
486 // If |error_message| is non-null, it will be filled in with a formatted 489 // If |error_message| is non-null, it will be filled in with a formatted
487 // error message including the location of the error if appropriate. 490 // error message including the location of the error if appropriate.
488 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; 491 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0;
489 }; 492 };
490 493
491 #endif // BASE_VALUES_H_ 494 #endif // BASE_VALUES_H_
OLDNEW
« no previous file with comments | « no previous file | base/values_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698