Add dbghelp.dll that works on XP, and include in base.isolate
[chromium-blink-merge.git] / base / prefs / pref_value_map.h
blob2db18ab2a187144ee834388afe550702c5d8c9b4
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_PREFS_PREF_VALUE_MAP_H_
6 #define BASE_PREFS_PREF_VALUE_MAP_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "base/prefs/base_prefs_export.h"
15 namespace base {
16 class Value;
19 // A generic string to value map used by the PrefStore implementations.
20 class BASE_PREFS_EXPORT PrefValueMap {
21 public:
22 typedef std::map<std::string, base::Value*>::iterator iterator;
23 typedef std::map<std::string, base::Value*>::const_iterator const_iterator;
25 PrefValueMap();
26 virtual ~PrefValueMap();
28 // Gets the value for |key| and stores it in |value|. Ownership remains with
29 // the map. Returns true if a value is present. If not, |value| is not
30 // touched.
31 bool GetValue(const std::string& key, const base::Value** value) const;
32 bool GetValue(const std::string& key, base::Value** value);
34 // Sets a new |value| for |key|. Takes ownership of |value|, which must be
35 // non-NULL. Returns true if the value changed.
36 bool SetValue(const std::string& key, base::Value* value);
38 // Removes the value for |key| from the map. Returns true if a value was
39 // removed.
40 bool RemoveValue(const std::string& key);
42 // Clears the map.
43 void Clear();
45 // Swaps the contents of two maps.
46 void Swap(PrefValueMap* other);
48 iterator begin();
49 iterator end();
50 const_iterator begin() const;
51 const_iterator end() const;
53 // Gets a boolean value for |key| and stores it in |value|. Returns true if
54 // the value was found and of the proper type.
55 bool GetBoolean(const std::string& key, bool* value) const;
57 // Sets the value for |key| to the boolean |value|.
58 void SetBoolean(const std::string& key, bool value);
60 // Gets a string value for |key| and stores it in |value|. Returns true if
61 // the value was found and of the proper type.
62 bool GetString(const std::string& key, std::string* value) const;
64 // Sets the value for |key| to the string |value|.
65 void SetString(const std::string& key, const std::string& value);
67 // Gets an int value for |key| and stores it in |value|. Returns true if
68 // the value was found and of the proper type.
69 bool GetInteger(const std::string& key, int* value) const;
71 // Sets the value for |key| to the int |value|.
72 void SetInteger(const std::string& key, const int value);
74 // Sets the value for |key| to the double |value|.
75 void SetDouble(const std::string& key, const double value);
77 // Compares this value map against |other| and stores all key names that have
78 // different values in |differing_keys|. This includes keys that are present
79 // only in one of the maps.
80 void GetDifferingKeys(const PrefValueMap* other,
81 std::vector<std::string>* differing_keys) const;
83 private:
84 typedef std::map<std::string, base::Value*> Map;
86 Map prefs_;
88 DISALLOW_COPY_AND_ASSIGN(PrefValueMap);
91 #endif // BASE_PREFS_PREF_VALUE_MAP_H_