mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium OS 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. |
| 4 | |
| 5 | #include "shill/key_value_store.h" |
| 6 | |
| 7 | #include <base/logging.h> |
| 8 | #include <base/stl_util-inl.h> |
| 9 | |
| 10 | using std::map; |
| 11 | using std::string; |
| 12 | |
| 13 | namespace shill { |
| 14 | |
| 15 | KeyValueStore::KeyValueStore() {} |
| 16 | |
| 17 | bool KeyValueStore::ContainsBool(const string &name) const { |
| 18 | return ContainsKey(bool_properties_, name); |
| 19 | } |
| 20 | |
| 21 | bool KeyValueStore::ContainsString(const string &name) const { |
| 22 | return ContainsKey(string_properties_, name); |
| 23 | } |
| 24 | |
| 25 | bool KeyValueStore::GetBool(const string &name) const { |
| 26 | map<string, bool>::const_iterator it(bool_properties_.find(name)); |
mukesh agrawal | 1a05626 | 2011-10-05 14:36:54 -0700 | [diff] [blame^] | 27 | CHECK(it != bool_properties_.end()) << "for bool property " << name; |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 28 | return it->second; |
| 29 | } |
| 30 | |
| 31 | const string &KeyValueStore::GetString(const string &name) const { |
| 32 | map<string, string>::const_iterator it(string_properties_.find(name)); |
mukesh agrawal | 1a05626 | 2011-10-05 14:36:54 -0700 | [diff] [blame^] | 33 | CHECK(it != string_properties_.end()) << "for string property " << name; |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 34 | return it->second; |
| 35 | } |
| 36 | |
| 37 | void KeyValueStore::SetBool(const string &name, bool value) { |
| 38 | bool_properties_[name] = value; |
| 39 | } |
| 40 | |
| 41 | void KeyValueStore::SetString(const string &name, const string &value) { |
| 42 | string_properties_[name] = value; |
| 43 | } |
| 44 | |
| 45 | } // namespace shill |