diff options
author | keybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-14 20:08:06 +0000 |
---|---|---|
committer | keybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-14 20:08:06 +0000 |
commit | bc1b18ecfc890dde4aae0a5a5db27dde2796b25e (patch) | |
tree | 8e37e62d98047d218bf8fdeff2f10361fbaab961 /dbus/message.h | |
parent | ce1402accb9a01358fc1235f1319d934cd611248 (diff) | |
download | chromium_src-bc1b18ecfc890dde4aae0a5a5db27dde2796b25e.zip chromium_src-bc1b18ecfc890dde4aae0a5a5db27dde2796b25e.tar.gz chromium_src-bc1b18ecfc890dde4aae0a5a5db27dde2796b25e.tar.bz2 |
dbus: add ObjectPath type
Rather than use std::string for object paths, add a dbus::ObjectPath type
that wraps one while allowing more type-safety. This solves all sorts of
issues with confusing object paths for strings, and allows us to do
Properties code using templates disambiguating them from strings.
BUG=chromium:109194
TEST=built and run tests
Change-Id: Icaf6f19daea4af23a9d2ec0ed76d2cbd379d680e
Review URL: http://codereview.chromium.org/9378039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121920 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/message.h')
-rw-r--r-- | dbus/message.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/dbus/message.h b/dbus/message.h index 54227a0..4683abe 100644 --- a/dbus/message.h +++ b/dbus/message.h @@ -11,6 +11,7 @@ #include <dbus/dbus.h> #include "base/basictypes.h" +#include "dbus/object_path.h" namespace google { namespace protobuf { @@ -80,7 +81,7 @@ class Message { // Sets the destination, the path, the interface, the member, etc. void SetDestination(const std::string& destination); - void SetPath(const std::string& path); + void SetPath(const ObjectPath& path); void SetInterface(const std::string& interface); void SetMember(const std::string& member); void SetErrorName(const std::string& error_name); @@ -92,7 +93,7 @@ class Message { // Gets the destination, the path, the interface, the member, etc. // If not set, an empty string is returned. std::string GetDestination(); - std::string GetPath(); + ObjectPath GetPath(); std::string GetInterface(); std::string GetMember(); std::string GetErrorName(); @@ -265,7 +266,7 @@ class MessageWriter { void AppendUint64(uint64 value); void AppendDouble(double value); void AppendString(const std::string& value); - void AppendObjectPath(const std::string& value); + void AppendObjectPath(const ObjectPath& value); // Opens an array. The array contents can be added to the array with // |sub_writer|. The client code must close the array with @@ -302,7 +303,7 @@ class MessageWriter { // Appends the array of object paths. Arrays of object paths are often // used when exchanging object paths, hence it's worth having a // specialized function. - void AppendArrayOfObjectPaths(const std::vector<std::string>& object_paths); + void AppendArrayOfObjectPaths(const std::vector<ObjectPath>& object_paths); // Appends the protocol buffer as an array of bytes. The buffer is serialized // into an array of bytes before communication, since protocol buffers are not @@ -326,7 +327,7 @@ class MessageWriter { void AppendVariantOfUint64(uint64 value); void AppendVariantOfDouble(double value); void AppendVariantOfString(const std::string& value); - void AppendVariantOfObjectPath(const std::string& value); + void AppendVariantOfObjectPath(const ObjectPath& value); private: // Helper function used to implement AppendByte etc. @@ -374,7 +375,7 @@ class MessageReader { bool PopUint64(uint64* value); bool PopDouble(double* value); bool PopString(std::string* value); - bool PopObjectPath(std::string* value); + bool PopObjectPath(ObjectPath* value); // Sets up the given message reader to read an array at the current // iterator position. @@ -409,7 +410,7 @@ class MessageReader { // Arrays of object paths are often used to communicate with D-Bus // services like NetworkManager, hence it's worth having a specialized // function. - bool PopArrayOfObjectPaths(std::vector<std::string>* object_paths); + bool PopArrayOfObjectPaths(std::vector<ObjectPath>* object_paths); // Gets the array of bytes at the current iterator position. It then parses // this binary blob into the protocol buffer supplied. @@ -436,7 +437,7 @@ class MessageReader { bool PopVariantOfUint64(uint64* value); bool PopVariantOfDouble(double* value); bool PopVariantOfString(std::string* value); - bool PopVariantOfObjectPath(std::string* value); + bool PopVariantOfObjectPath(ObjectPath* value); // Get the data type of the value at the current iterator // position. INVALID_DATA will be returned if the iterator points to the |