blob: 6310502f6edda290e25a1aafbbd3247cf9d79583 [file] [log] [blame]
Darin Petkove0a312e2011-07-20 13:45:28 -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/dbus_properties.h"
6
Darin Petkovceb68172011-07-29 14:47:48 -07007#include <base/logging.h>
8
Darin Petkove0a312e2011-07-20 13:45:28 -07009namespace shill {
10
11// static
12bool DBusProperties::GetString(const DBusPropertiesMap &properties,
13 const std::string &key,
14 std::string *value) {
15 DBusPropertiesMap::const_iterator it = properties.find(key);
16 if (it == properties.end()) {
17 return false;
18 }
19 *value = it->second.reader().get_string();
Darin Petkovceb68172011-07-29 14:47:48 -070020 VLOG(2) << key << " = " << *value;
Darin Petkove0a312e2011-07-20 13:45:28 -070021 return true;
22}
23
24// static
Nathan Williamse9840802012-04-18 18:47:40 -040025bool DBusProperties::GetObjectPath(const DBusPropertiesMap &properties,
26 const std::string &key,
27 std::string *value) {
28 DBusPropertiesMap::const_iterator it = properties.find(key);
29 if (it == properties.end()) {
30 return false;
31 }
32 *value = it->second.reader().get_path();
33 VLOG(2) << key << " = " << *value;
34 return true;
35}
36
37// static
Darin Petkove0a312e2011-07-20 13:45:28 -070038bool DBusProperties::GetUint32(const DBusPropertiesMap &properties,
39 const std::string &key,
40 uint32 *value) {
41 DBusPropertiesMap::const_iterator it = properties.find(key);
42 if (it == properties.end()) {
43 return false;
44 }
45 *value = it->second.reader().get_uint32();
Darin Petkovceb68172011-07-29 14:47:48 -070046 VLOG(2) << key << " = " << *value;
47 return true;
48}
49
50// static
51bool DBusProperties::GetUint16(const DBusPropertiesMap &properties,
52 const std::string &key,
53 uint16 *value) {
54 DBusPropertiesMap::const_iterator it = properties.find(key);
55 if (it == properties.end()) {
56 return false;
57 }
58 *value = it->second.reader().get_uint16();
59 VLOG(2) << key << " = " << *value;
Darin Petkove0a312e2011-07-20 13:45:28 -070060 return true;
61}
62
63} // namespace shill