src/cpp-common: improve C++ UUID utilities
Philippe Proulx writing below.
This patch improves the C++ common UUID utilities.
Francis wrote the initial version of `bt2_common::Uuid`, and then we
worked together to improve many little things at once, leading to this
patch.
His original message was:
> Add `bt2_common::Uuid`
>
> This patch adds the `bt2_common::Uuid` class which represent UUIDs.
>
> `Uuid` instances can be created from byte array, strings, or
> bt2_common::UuidView objects.
>
> The generate() static method returns a Uuid object with newly
> generated UUID.
>
> The operator UuidView() method returns a bt2_common::UuidView object
> representing the entire content of the UUID.
>
> The data() method returns a const pointer to the underlying
> std::array<>.
>
> The str() method returns a new `std::string` instance containing the
> canonical string representation of the UUID.
The final improvements are:
* Add said `bt2_common::Uuid` class.
I also added the operator[](), operator=(), isNil(), begin(), and
end() methods, the `Val` and `ConstIter` aliases, and the fact that
most of the class relies on creating a `bt2_common::UuidView` to wrap
itself when needed.
data() just returns `const Val *`.
* In `bt2_common::UuidView`:
* Make the class `final`.
* Add the `Val` and `ConstIter` aliases.
* Add operator<(): makes it possible to use a `bt2_common::UuidView`
as an `std::set` value type or as an `std::map` key type, and to use
it with STL algorithms.
* Make size() `constexpr`.
* Rename string() to str() for consistency with internal C++ naming.
* Add begin() and end().
* Add operator=() which accepts a UUID pointer.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Id049953aecc51562e5939db546cb7d82bbaf88eb
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10822
Tested-by: jenkins <jenkins@lttng.org>
This page took 0.044983 seconds and 4 git commands to generate.