Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed May 17, 2024
1 parent 903a146 commit f3100d7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 13 deletions.
59 changes: 50 additions & 9 deletions doc/uuid/uuid.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ namespace uuids {
class uuid
{
public:
// data
private:
std::uint8_t data[ 16 ];
std::uint8_t data_[ 16 ] = {}; // exposition only
public:
// constructors
uuid() = default;
uuid( std::uint8_t const (&r)[ 16 ] );
// iteration
using value_type = std::uint8_t;
Expand All @@ -39,6 +42,11 @@ public:
const_iterator begin() const noexcept;
const_iterator end() const noexcept;
// data
std::uint8_t* data() noexcept;
std::uint8_t const* data() const noexcept;
// size
constexpr size_type size() const noexcept;
Expand Down Expand Up @@ -133,6 +141,28 @@ BOOST_CLASS_IMPLEMENTATION(boost::uuids::uuid, boost::serialization::primitive_t
template<> struct std::hash<boost::uuids::uuid>;
----

=== Constructors

```
uuid() = default;
```

Effects: :: Zero-initializes `data_`.

Postconditions: :: `is_nil()`.

```
uuid( std::uint8_t const (&r)[ 16 ] );
```

Effects: :: Initializes the elements of `data_` from the corresponding elements of `r`.

Example: ::
+
```
uuid dns = {{ 0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8 }};
```

=== Iteration

Both constant and mutable iterators are provided.
Expand All @@ -142,14 +172,14 @@ iterator begin() noexcept;
const_iterator begin() const noexcept;
```

Returns: :: `data + 0`.
Returns: :: `data()`.

```
iterator end() noexcept;
const_iterator end() const noexcept;
```

Returns: :: `data + 16`.
Returns: :: `data() + size()`.

Example: ::
+
Expand All @@ -170,6 +200,17 @@ for( uuid::iterator it = u.begin(); it != u.end(); ++it )
}
```

=== Data

```
std::uint8_t* data() noexcept;
```
```
std::uint8_t const* data() const noexcept;
```

Returns: :: `data_`.

=== Size

The size of a `uuid` (in octets) is fixed at 16.
Expand Down Expand Up @@ -292,7 +333,7 @@ Effects: :: Exchanges the values of `*this` and `rhs`.
bool operator==( uuid const& lhs, uuid const& rhs ) noexcept;
```

Returns: :: As if `std::memcmp( lhs.data, rhs.data, 16 ) == 0`.
Returns: :: As if `std::memcmp( lhs.data(), rhs.data(), 16 ) == 0`.

```
bool operator!=( uuid const& lhs, uuid const& rhs ) noexcept;
Expand All @@ -304,7 +345,7 @@ Returns: :: `!(lhs == rhs)`.
bool operator<( uuid const& lhs, uuid const& rhs ) noexcept;
```

Returns: :: As if `std::memcmp( lhs.data, rhs.data, 16 ) < 0`.
Returns: :: As if `std::memcmp( lhs.data(), rhs.data(), 16 ) < 0`.

```
bool operator>( uuid const& lhs, uuid const& rhs ) noexcept;
Expand All @@ -328,7 +369,7 @@ Returns: :: `!(lhs < rhs)`.
std::strong_ordering operator<=>( uuid const& lhs, uuid const& rhs ) noexcept;
```

Returns: :: As if `std::memcmp( lhs.data, rhs.data, 16 ) \<\=> 0`.
Returns: :: As if `std::memcmp( lhs.data(), rhs.data(), 16 ) \<\=> 0`.

=== Free Swap

Expand Down
8 changes: 4 additions & 4 deletions include/boost/uuid/namespaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ namespace ns {
inline uuid dns() noexcept
{
uuid result = {{
0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1 ,
0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1,
0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8 }};
return result;
}

inline uuid url() noexcept
{
uuid result = {{
0x6b, 0xa7, 0xb8, 0x11, 0x9d, 0xad, 0x11, 0xd1 ,
0x6b, 0xa7, 0xb8, 0x11, 0x9d, 0xad, 0x11, 0xd1,
0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8 }};
return result;
}

inline uuid oid() noexcept
{
uuid result = {{
0x6b, 0xa7, 0xb8, 0x12, 0x9d, 0xad, 0x11, 0xd1 ,
0x6b, 0xa7, 0xb8, 0x12, 0x9d, 0xad, 0x11, 0xd1,
0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8 }};
return result;
}

inline uuid x500dn() noexcept
{
uuid result = {{
0x6b, 0xa7, 0xb8, 0x14, 0x9d, 0xad, 0x11, 0xd1 ,
0x6b, 0xa7, 0xb8, 0x14, 0x9d, 0xad, 0x11, 0xd1,
0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8 }};
return result;
}
Expand Down

0 comments on commit f3100d7

Please sign in to comment.