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

Issue 6592070: cromo: Add ExtractUint32 function (Closed)

Created:
9 years, 9 months ago by Jason Glasgow
Modified:
9 years, 7 months ago
CC:
chromium-os-reviews_chromium.org
Visibility:
Public.

Description

cromo: Add ExtractUint32 function BUG=chromium-os:11879 TEST=use 'modem status' to monitor activation state while activating. Notice that cromo now reports state 1 -- MM_ACTIVATION_STATE_ACTIVATING Committed: http://chrome-svn/viewvc/chromeos?view=rev&revision=62bbe91

Patch Set 1 #

Patch Set 2 : Fix uint type #

Patch Set 3 : undo added include #

Unified diffs Side-by-side diffs Delta from patch set Stats (+34 lines, -0 lines) Patch
M utilities.h View 1 2 1 chunk +11 lines, -0 lines 0 comments Download
M utilities.cc View 1 1 chunk +23 lines, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
Jason Glasgow
9 years, 9 months ago (2011-03-01 18:04:01 UTC) #1
rochberg
On 2011/03/01 18:04:01, Jason Glasgow wrote: I'd love to see a return type of uint32. ...
9 years, 9 months ago (2011-03-01 18:25:53 UTC) #2
ers
9 years, 9 months ago (2011-03-01 20:32:59 UTC) #3
FYI, you can do something like this using templates

template<typename T>
T get_value(DBusPropertyMap::const_iterator p) {
  T retval;
  return retval;
}

template<> inline const char *get_value<const
char*>(DBusPropertyMap::const_iterator p) {
  return p->second.reader().get_string();
}

template<> inline uint32 get_value<uint32_t>(DBusPropertyMap::const_iterator
p) {
  return p->second.reader().get_uint32();
}

template<typename T>
T ExtractValue(const DBusPropertyMap properties,
               const char *key,
               T not_found_response,
               DBus::Error &error) {
  DBusPropertyMap::const_iterator p;
  T to_return = not_found_response;
  try {
    p = properties.find(key);
    if (p != properties.end()) {
      to_return = get_value<T>(p);
    }
  } 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;
}


On Tue, Mar 1, 2011 at 1:25 PM, <rochberg@chromium.org> wrote:

> On 2011/03/01 18:04:01, Jason Glasgow wrote:
>
> I'd love to see a return type of uint32.
> LGTM otherwise
>
>
> http://codereview.chromium.org/6592070/
>

Powered by Google App Engine
This is Rietveld 408576698