C++ namespace for unique_id helper functions. More...
Namespaces | |
namespace | impl |
C++ namespace for private implementation details. | |
Functions | |
static boost::uuids::uuid | fromHexString (std::string const &str) |
Generate UUID from canonical hex string. | |
static boost::uuids::uuid | fromMsg (uuid_msgs::UniqueID const &msg) |
Create UUID object from UniqueID message. | |
static boost::uuids::uuid | fromRandom (void) |
Generate a random UUID object. | |
static boost::uuids::uuid | fromURL (std::string const &url) |
Generate UUID from Uniform Resource Identifier. | |
static std::string | toHexString (boost::uuids::uuid const &uu) |
Get the canonical string representation for a boost UUID. | |
static std::string | toHexString (uuid_msgs::UniqueID const &msg) |
Get the canonical string representation for a UniqueID message. | |
static uuid_msgs::UniqueID | toMsg (boost::uuids::uuid const &uu) |
Create a UniqueID message from a UUID object. |
C++ namespace for unique_id helper functions.
Various ROS components use universally unique identifiers. This header provides functions for working with a common uuid_msgs/UniqueID message, and the boost uuid class.
Programmers are free to create UUID objects using any approved RFC 4122 method. The boost uuid interface supports them all.
Functions in this namespace provide simple APIs, not requiring detailed knowledge of RFC 4122 or the boost uuid interface. ROS applications are likely to need either a random or a name-based UUID.
static boost::uuids::uuid unique_id::fromHexString | ( | std::string const & | str | ) | [inline, static] |
Generate UUID from canonical hex string.
str | string containing canonical hex representation |
The canonical hex string is a human-readable representation of a correctly-formatted sixteen-byte UUID. In addition to the dashes, it should contain exactly 32 hexadecimal digits. The str can be any accepted by the boost uuid string generator, but that is not well-defined. The format produced by toHexString() works reliably: "01234567-89ab-cdef-0123-456789abcdef".
std::runtime_error
exception, or silently ignoring parts of the string. Definition at line 125 of file unique_id.h.
static boost::uuids::uuid unique_id::fromMsg | ( | uuid_msgs::UniqueID const & | msg | ) | [inline, static] |
Create UUID object from UniqueID message.
msg | uuid_msgs/UniqueID message. |
Definition at line 85 of file unique_id.h.
static boost::uuids::uuid unique_id::fromRandom | ( | void | ) | [inline, static] |
Generate a random UUID object.
Different calls to this function at any time or place will almost certainly generate different UUIDs. The method used is RFC 4122 variant 4.
Definition at line 100 of file unique_id.h.
static boost::uuids::uuid unique_id::fromURL | ( | std::string const & | url | ) | [inline, static] |
Generate UUID from Uniform Resource Identifier.
url | URL for identifier creation. |
Matching url strings must yield the same UUID. Different url strings will almost certainly generate different UUIDs. The method used is RFC 4122 variant 5, computing the SHA-1 hash of the url.
For any given url, this function returns the same UUID as the corresponding Python unique_id.fromURL()
function.
For example, Open Street Map identifiers are encoded like this, with decimal representations of the integer OSM node, way, or relation identifiers appended to the URL:
Definition at line 151 of file unique_id.h.
static std::string unique_id::toHexString | ( | boost::uuids::uuid const & | uu | ) | [inline, static] |
Get the canonical string representation for a boost UUID.
uu | boost::uuids::uuid object. |
A boost::uuids::uuid
object yields the same representation via its <<
operator or to_string()
function.
Definition at line 176 of file unique_id.h.
static std::string unique_id::toHexString | ( | uuid_msgs::UniqueID const & | msg | ) | [inline, static] |
Get the canonical string representation for a UniqueID message.
msg | uuid_msgs/UniqueID message. |
Definition at line 186 of file unique_id.h.
static uuid_msgs::UniqueID unique_id::toMsg | ( | boost::uuids::uuid const & | uu | ) | [inline, static] |
Create a UniqueID message from a UUID object.
uu | boost::uuids::uuid object. |
Definition at line 161 of file unique_id.h.