Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Unified Diff: utilities.cc

Issue 6592070: cromo: Add ExtractUint32 function (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cromo.git@master
Patch Set: undo added include Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utilities.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utilities.cc
diff --git a/utilities.cc b/utilities.cc
index ffe6edd744d394143efa7e06d099c8b66f55fdbd..6d400f62f49f221b794e2a568d4be8830f0c6787 100644
--- a/utilities.cc
+++ b/utilities.cc
@@ -36,6 +36,29 @@ const char *ExtractString(const DBusPropertyMap properties,
return to_return;
}
+uint32_t ExtractUint32(const DBusPropertyMap properties,
+ const char *key,
+ uint32_t not_found_response,
+ DBus::Error &error) {
+ DBusPropertyMap::const_iterator p;
+ unsigned int to_return = not_found_response;
+ try {
+ p = properties.find(key);
+ if (p != properties.end()) {
+ to_return = p->second.reader().get_uint32();
+ }
+ } catch (const DBus::Error &e) {
+ LOG(ERROR)<<"Bad type for: " << key;
+ // Setting an already-set error causes an assert fail inside dbus-c++.
+ if (!error.is_set()) {
+ // NB: the copy constructor for DBus::Error causes a template to
+ // be instantiated that kills our -Werror build
+ error.set(e.name(), e.message());
+ }
+ }
+ return to_return;
+}
+
bool HexEsnToDecimal(const std::string &esn_hex, std::string *out) {
size_t length = esn_hex.length();
if (length > 8) {
« no previous file with comments | « utilities.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698