blob: d90546725d39ee7acf028834892c0b1e25261ad1 [file] [log] [blame]
mukesh agrawal7a4e4002011-09-06 11:26:05 -07001// 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
10using std::map;
11using std::string;
12
13namespace shill {
14
15KeyValueStore::KeyValueStore() {}
16
17bool KeyValueStore::ContainsBool(const string &name) const {
18 return ContainsKey(bool_properties_, name);
19}
20
21bool KeyValueStore::ContainsString(const string &name) const {
22 return ContainsKey(string_properties_, name);
23}
24
25bool KeyValueStore::GetBool(const string &name) const {
26 map<string, bool>::const_iterator it(bool_properties_.find(name));
mukesh agrawal1a056262011-10-05 14:36:54 -070027 CHECK(it != bool_properties_.end()) << "for bool property " << name;
mukesh agrawal7a4e4002011-09-06 11:26:05 -070028 return it->second;
29}
30
31const string &KeyValueStore::GetString(const string &name) const {
32 map<string, string>::const_iterator it(string_properties_.find(name));
mukesh agrawal1a056262011-10-05 14:36:54 -070033 CHECK(it != string_properties_.end()) << "for string property " << name;
mukesh agrawal7a4e4002011-09-06 11:26:05 -070034 return it->second;
35}
36
37void KeyValueStore::SetBool(const string &name, bool value) {
38 bool_properties_[name] = value;
39}
40
41void KeyValueStore::SetString(const string &name, const string &value) {
42 string_properties_[name] = value;
43}
44
45} // namespace shill