| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DBUS_OBJECT_PATH_H_ | 5 #ifndef DBUS_OBJECT_PATH_H_ |
| 6 #define DBUS_OBJECT_PATH_H_ | 6 #define DBUS_OBJECT_PATH_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "dbus/dbus_export.h" |
| 11 |
| 10 namespace dbus { | 12 namespace dbus { |
| 11 | 13 |
| 12 // ObjectPath is a type used to distinguish D-Bus object paths from simple | 14 // ObjectPath is a type used to distinguish D-Bus object paths from simple |
| 13 // strings, especially since normal practice is that these should be only | 15 // strings, especially since normal practice is that these should be only |
| 14 // initialized from static constants or obtained from remote objects and no | 16 // initialized from static constants or obtained from remote objects and no |
| 15 // assumptions about their value made. | 17 // assumptions about their value made. |
| 16 class ObjectPath { | 18 class CHROME_DBUS_EXPORT ObjectPath { |
| 17 public: | 19 public: |
| 18 // Permit initialization without a value for passing to | 20 // Permit initialization without a value for passing to |
| 19 // dbus::MessageReader::PopObjectPath to fill in and from std::string | 21 // dbus::MessageReader::PopObjectPath to fill in and from std::string |
| 20 // objects. | 22 // objects. |
| 21 // | 23 // |
| 22 // The compiler synthesised copy constructor and assignment operator are | 24 // The compiler synthesised copy constructor and assignment operator are |
| 23 // sufficient for our needs, as is implicit initialization of a std::string | 25 // sufficient for our needs, as is implicit initialization of a std::string |
| 24 // from a string constant. | 26 // from a string constant. |
| 25 ObjectPath() {} | 27 ObjectPath() {} |
| 26 explicit ObjectPath(const std::string& value) : value_(value) {} | 28 explicit ObjectPath(const std::string& value) : value_(value) {} |
| 27 | 29 |
| 28 // Retrieves value as a std::string. | 30 // Retrieves value as a std::string. |
| 29 const std::string& value() const { return value_; } | 31 const std::string& value() const { return value_; } |
| 30 | 32 |
| 31 // Returns true if the value is a valid object path. | 33 // Returns true if the value is a valid object path. |
| 32 bool IsValid() const; | 34 bool IsValid() const; |
| 33 | 35 |
| 34 // Permit sufficient comparison to allow an ObjectPath to be used as a | 36 // Permit sufficient comparison to allow an ObjectPath to be used as a |
| 35 // key in a std::map. | 37 // key in a std::map. |
| 36 bool operator<(const ObjectPath&) const; | 38 bool operator<(const ObjectPath&) const; |
| 37 | 39 |
| 38 // Permit testing for equality, required for mocks to work and useful for | 40 // Permit testing for equality, required for mocks to work and useful for |
| 39 // observers. | 41 // observers. |
| 40 bool operator==(const ObjectPath&) const; | 42 bool operator==(const ObjectPath&) const; |
| 41 bool operator!=(const ObjectPath&) const; | 43 bool operator!=(const ObjectPath&) const; |
| 44 |
| 42 private: | 45 private: |
| 43 std::string value_; | 46 std::string value_; |
| 44 }; | 47 }; |
| 45 | 48 |
| 46 } // namespace dbus | 49 } // namespace dbus |
| 47 | 50 |
| 48 #endif // DBUS_OBJECT_PATH_H_ | 51 #endif // DBUS_OBJECT_PATH_H_ |
| OLD | NEW |