Darin Petkov | e0a312e | 2011-07-20 13:45:28 -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/dbus_properties.h" |
| 6 | |
Darin Petkov | ceb6817 | 2011-07-29 14:47:48 -0700 | [diff] [blame] | 7 | #include <base/logging.h> |
| 8 | |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 9 | namespace shill { |
| 10 | |
| 11 | // static |
| 12 | bool 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 Petkov | ceb6817 | 2011-07-29 14:47:48 -0700 | [diff] [blame] | 20 | VLOG(2) << key << " = " << *value; |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 21 | return true; |
| 22 | } |
| 23 | |
| 24 | // static |
| 25 | bool DBusProperties::GetUint32(const DBusPropertiesMap &properties, |
| 26 | const std::string &key, |
| 27 | uint32 *value) { |
| 28 | DBusPropertiesMap::const_iterator it = properties.find(key); |
| 29 | if (it == properties.end()) { |
| 30 | return false; |
| 31 | } |
| 32 | *value = it->second.reader().get_uint32(); |
Darin Petkov | ceb6817 | 2011-07-29 14:47:48 -0700 | [diff] [blame] | 33 | VLOG(2) << key << " = " << *value; |
| 34 | return true; |
| 35 | } |
| 36 | |
| 37 | // static |
| 38 | bool DBusProperties::GetUint16(const DBusPropertiesMap &properties, |
| 39 | const std::string &key, |
| 40 | uint16 *value) { |
| 41 | DBusPropertiesMap::const_iterator it = properties.find(key); |
| 42 | if (it == properties.end()) { |
| 43 | return false; |
| 44 | } |
| 45 | *value = it->second.reader().get_uint16(); |
| 46 | VLOG(2) << key << " = " << *value; |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 47 | return true; |
| 48 | } |
| 49 | |
| 50 | } // namespace shill |