Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Apr 30, 2024
1 parent 9d564b0 commit 7677167
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 120 deletions.
1 change: 1 addition & 0 deletions doc/uuid.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

include::uuid/introduction.adoc[]
include::uuid/changes.adoc[]

include::uuid/configuration.adoc[]
include::uuid/examples.adoc[]
include::uuid/reference.adoc[]
Expand Down
33 changes: 18 additions & 15 deletions doc/uuid/basic_random_generator.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[#basic_random_generator]
== <boost/uuid/basic_random_generator.hpp>
== <boost/uuid/{zwsp}basic_random_generator.hpp>

:idprefix: basic_random_generator_

Expand All @@ -24,8 +24,9 @@ public:
typedef uuid result_type;
basic_random_generator();
explicit basic_random_generator(UniformRandomNumberGenerator& gen);
explicit basic_random_generator(UniformRandomNumberGenerator* pGen);
explicit basic_random_generator( UniformRandomNumberGenerator& gen );
explicit basic_random_generator( UniformRandomNumberGenerator* pGen );
result_type operator()();
};
Expand All @@ -35,13 +36,15 @@ public:

=== basic_random_generator

The class template `basic_random_generator` class generates a random number based UUID from a random number generator
The class template `basic_random_generator` generates a version 4 random number-based UUID from a random number generator
(one that conforms to the standard concept https://en.cppreference.com/w/cpp/named_req/UniformRandomBitGenerator[UniformRandomBitGenerator]
or to the Boost.Random concept https://www.boost.org/doc/libs/1_85_0/doc/html/boost_random/reference.html#boost_random.reference.concepts.uniform_random_number_generator[UniformRandomNumberGenerator]).
The default constructor will properly seed the random number generator if it requires the behavior for proper operation.

The default constructor will seed the random number generator with entropy obtained from `std::random_device`.

Additional constructors allow you to provide your own `UniformRandomNumberGenerator` and you are responsible for properly seeding it if necessary.

```cpp
```
basic_random_generator();
```

Expand All @@ -51,39 +54,39 @@ Effects: :: Value-initializes `g_` and initializes `p_` to `nullptr`.
`generate( first, last )` member function that fills the range
`[first, last)` using entropy obtained from `std::random_device`.

NOTE: Random number generators conforming to the standard https://en.cppreference.com/w/cpp/named_req/RandomNumberEngine[RandomNumberEngine]
NOTE: Random number generators conforming to the standard concept https://en.cppreference.com/w/cpp/named_req/RandomNumberEngine[RandomNumberEngine]
or the Boost.Random concept https://www.boost.org/doc/libs/1_85_0/doc/html/boost_random/reference.html#boost_random.reference.concepts.pseudo_random_number_generator[PseudoRandomNumberGenerator]
provide such `seed` member functions.

```cpp
explicit basic_random_generator(UniformRandomNumberGenerator& gen);
```
explicit basic_random_generator( UniformRandomNumberGenerator& gen );
```

Effects: :: Value-initializes `g_` and initializes `p_` to `&gen`.

```cpp
explicit basic_random_generator(UniformRandomNumberGenerator* pGen);
```
explicit basic_random_generator( UniformRandomNumberGenerator* pGen );
```

Effects: :: Value-initializes `g_` and initializes `p_` to `pGen`.

```cpp
```
result_type operator()();
```

Effects: :: Generates and returns a version 4 UUID using random numbers
obtained from `*p_`, if `p_ != nullptr`, and from `g_`, otherwise.
obtained from `*p_`, if `p_ != nullptr`, or from `g_`, otherwise.

Example: ::
+
```cpp
```
using namespace boost::uuids;

basic_random_generator<boost::mt19937> bulkgen;

for( int i = 0; i < 1000; ++i )
{
u = bulkgen();
uuid u = bulkgen();
// do something with u
}
```
55 changes: 19 additions & 36 deletions doc/uuid/changes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,26 @@

* {cpp}03 is no longer supported, a {cpp}11 compiler is required.
This includes GCC 4.8 or later, MSVC 14.0 or later, and MinGW-w64.
* Removed direct dependencies on Core, Io, Move, NumericConversion, StaticAssert,
TTI, Random, ContainerHash. The library now only has five Boost dependencies
(as opposed to 39 in Boost 1.85.)
* Removed direct dependencies on Core, Io, Move, NumericConversion, StaticAssert, TTI, Random, ContainerHash.
The library now only has five Boost dependencies (as opposed to 39 in Boost 1.85.)
* Moved `std::hash` support from `uuid_hash.hpp` to `uuid.hpp`.
* Moved serialization support from `uuid_serialize.hpp` to `uuid.hpp`.
* Added convenience header `<boost/uuid.hpp>`.
* Improved quality and speed of `hash_value`.
* Removed platform-specific entropy providers; the implementation now
uses `std::random_device` as the source of entropy.
* Since `basic_name_generator` had only two valid instantiations, both of
which are already provided (`name_generator_md5` and `name_generator_sha1`),
it was made a private implementation detail and is no longer part of the
public interface.
* While `name_generator` and `name_generator_latest` are still provided for
compatibility, their use is no longer encouraged.
* The definitions of the well-known RFC 4122 namespaces have been moved to
their own header, `boost/uuid/namespaces.hpp`.
* Improved the quality and speed of `hash_value`.
* Removed platform-specific entropy providers; the implementation now uses `std::random_device` as the source of entropy.
* Since `basic_name_generator` had only two valid instantiations, both of which are already provided (`name_generator_md5` and `name_generator_sha1`),
it was made a private implementation detail and is no longer part of the public interface.
* While `name_generator` and `name_generator_latest` are still provided for compatibility, their use is no longer encouraged.
* The definitions of the well-known RFC 4122 namespaces have been moved to their own header, `boost/uuid/namespaces.hpp`.
* Added `operator\<\=>`.
* The generic (non-SIMD) implementations of `is_nil`, `operator==`,
`operator<`, `swap`, and `operator\<\=>` now use `__uint128_t` operations
when that type is available, and `uint64_t` operations otherwise.
* `basic_random_generator` has been moved to its own header,
`boost/uuid/basic_random_generator.hpp`.
* `basic_random_generator` has been changed to hold the underlying generator
by value, to avoid dynamic allocation and restore copyability.
* `random_generator_pure` is now an alias for
`basic_random_generator<std::random_device>` and its use is discouraged.
* `random_generator_md19937` is now an alias for
`basic_random_generator<std::mt19937>` and its use is discouraged.
* `random_generator` now uses a cryptographically strong pseudorandom number
generator (ChaCha20), seeded with entropy from `std::random_device`. It's
the recommended way to generate version 4 UUIDs.
* Added `time_generator_v1`, a generator that produces version 1 time-based
UUIDs.
* Added `uuid_clock`, a `<chrono>`-compatible clock with an epoch and a
resolution as specified in RFC 4122.
* Accessors for the timestamp, the time point, the clock sequence, and the
node identifier have been added to `uuid`.
* Improved the `what()` strings of the `std::runtime_error` exceptions
thrown by `string_generator`.
* The generic (non-SIMD) implementations of `is_nil`, `operator==`, `operator<`, `swap`, and `operator\<\=>` now use `__uint128_t` operations when that type is available, and `uint64_t` operations otherwise.
* `basic_random_generator` has been moved to its own header, `boost/uuid/basic_random_generator.hpp`.
* `basic_random_generator` has been changed to hold the underlying generator by value, to avoid dynamic allocation and restore copyability.
* `random_generator_pure` is now an alias for `basic_random_generator<std::random_device>` and its use is discouraged.
* `random_generator_mt19937` is now an alias for `basic_random_generator<std::mt19937>` and its use is discouraged.
* `random_generator` now uses a cryptographically strong pseudorandom number generator (ChaCha20/12), seeded with entropy from `std::random_device`.
It's the recommended way to generate version 4 UUIDs.
* Added `time_generator_v1`, a generator that produces version 1 time-based UUIDs.
* Added `uuid_clock`, a `<chrono>`-compatible clock with an epoch and a resolution as specified in RFC 4122.
* Accessors for the timestamp, the time point, the clock sequence, and the node identifier have been added to `uuid`.
* Improved the `what()` strings of the `std::runtime_error` exceptions thrown by `string_generator`.
26 changes: 13 additions & 13 deletions doc/uuid/name_generator_md5.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[#name_generator_md5]
== <boost/uuid/name_generator_md5.hpp>
== <boost/uuid/{zwsp}name_generator_md5.hpp>

:idprefix: name_generator_md5_

Expand All @@ -21,7 +21,7 @@ public:
explicit name_generator_md5( uuid const& namespace_uuid ) noexcept;
uuid operator()( char const* name ) const noexcept;
uuid operator()( wchar_t const * name ) const noexcept;
uuid operator()( wchar_t const* name ) const noexcept;
template<class Ch, class Traits, class Alloc>
uuid operator()( std::basic_string<Ch, Traits, Alloc> const& name ) const noexcept;
Expand All @@ -38,21 +38,21 @@ The class `name_generator_md5` generates name-based version 3 UUIDs (using MD5 a

There is no reason to use `name_generator_md5` except for compatibility. `name_generator_sha1` should be preferred in almost all cases.

```cpp
```
explicit name_generator_md5( uuid const& namespace_uuid );
```

Effects: :: Constructs a `name_generator_md5` that uses `namespace_uuid` as the namespace.

```cpp
```
uuid operator()( char const* name ) const;
```

Returns: :: A name-based UUID version 5 produced from a digest of the namespace passed to the constructor and the characters of the string `name`, treated as octets.
Returns: :: A name-based UUID version 3 produced from a digest of the namespace passed to the constructor and the characters of the string `name`, treated as octets.

Example: ::
+
```cpp
```
using namespace boost::uuids;

name_generator_md5 gen( ns::dns() );
Expand All @@ -65,15 +65,15 @@ std::cout << "\"boost.org\" UUID in DNS namespace, MD5 version: " << udoc << std
// "boost.org" UUID in DNS namespace, MD5 version: 888eca9c-e655-31a2-a46b-a2a821f6b150
```

```cpp
uuid operator()( wchar_t const * name ) const;
```
uuid operator()( wchar_t const* name ) const;
```

Returns: :: A name-based UUID version 5 produced from a digest of the namespace passed to the constructor and the string `name`, converted to octets formed from a little-endian serialization of the characters of `name` converted to `uint32_t`.
Returns: :: A name-based UUID version 3 produced from a digest of the namespace passed to the constructor and the string `name`, converted to octets formed from a little-endian serialization of the characters of `name` converted to `uint32_t`.

Example: ::
+
```cpp
```
using namespace boost::uuids;

name_generator_md5 gen( ns::dns() );
Expand All @@ -86,7 +86,7 @@ std::cout << "L\"boost.org\" UUID in DNS namespace, MD5 version: " << udoc << st
// L"boost.org" UUID in DNS namespace, MD5 version: 48149232-8cda-361b-b355-0bdb71d2cab3
```

```cpp
```
template<class Ch, class Traits, class Alloc>
uuid operator()( std::basic_string<Ch, Traits, Alloc> const& name ) const;
```
Expand All @@ -95,8 +95,8 @@ Requires: :: `Ch` must be either `char` or `wchar_t`.

Returns: :: As if `operator()( name.c_str() )`.

```cpp
```
uuid operator()( void const* buffer, std::size_t byte_count ) const;
```

Returns: :: A name-based UUID version 5 produced from a digest of the namespace passed to the constructor and the octets in the range `[(char const*)buffer, (char const*)buffer + byte_count)`.
Returns: :: A name-based UUID version 3 produced from a digest of the namespace passed to the constructor and the `byte_count` octets starting from `buffer`.
22 changes: 11 additions & 11 deletions doc/uuid/name_generator_sha1.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[#name_generator_sha1]
== <boost/uuid/name_generator_sha1.hpp>
== <boost/uuid/{zwsp}name_generator_sha1.hpp>

:idprefix: name_generator_sha1_

Expand All @@ -21,7 +21,7 @@ public:
explicit name_generator_sha1( uuid const& namespace_uuid ) noexcept;
uuid operator()( char const* name ) const noexcept;
uuid operator()( wchar_t const * name ) const noexcept;
uuid operator()( wchar_t const* name ) const noexcept;
template<class Ch, class Traits, class Alloc>
uuid operator()( std::basic_string<Ch, Traits, Alloc> const& name ) const noexcept;
Expand All @@ -36,21 +36,21 @@ public:

The class `name_generator_sha1` generates name-based version 5 UUIDs (using SHA1 as the hashing algorithm.)

```cpp
```
explicit name_generator_sha1( uuid const& namespace_uuid );
```

Effects: :: Constructs a `name_generator_sha1` that uses `namespace_uuid` as the namespace.

```cpp
```
uuid operator()( char const* name ) const;
```

Returns: :: A name-based UUID version 5 produced from a digest of the namespace passed to the constructor and the characters of the string `name`, treated as octets.

Example: ::
+
```cpp
```
using namespace boost::uuids;

name_generator_sha1 gen( ns::dns() );
Expand All @@ -63,15 +63,15 @@ std::cout << "\"boost.org\" UUID in DNS namespace, SHA1 version: " << udoc << st
// "boost.org" UUID in DNS namespace, SHA1 version: 0043f363-bbb4-5369-840a-322df6ec1926
```

```cpp
uuid operator()( wchar_t const * name ) const;
```
uuid operator()( wchar_t const* name ) const;
```

Returns: :: A name-based UUID version 5 produced from a digest of the namespace passed to the constructor and the string `name`, converted to octets formed from a little-endian serialization of the characters of `name` converted to `uint32_t`.

Example: ::
+
```cpp
```
using namespace boost::uuids;

name_generator_sha1 gen( ns::dns() );
Expand All @@ -84,7 +84,7 @@ std::cout << "L\"boost.org\" UUID in DNS namespace, SHA1 version: " << udoc << s
// L"boost.org" UUID in DNS namespace, SHA1 version: c31c5016-3493-5dc2-8484-5813d495cc18
```

```cpp
```
template<class Ch, class Traits, class Alloc>
uuid operator()( std::basic_string<Ch, Traits, Alloc> const& name ) const;
```
Expand All @@ -93,8 +93,8 @@ Requires: :: `Ch` must be either `char` or `wchar_t`.

Returns: :: As if `operator()( name.c_str() )`.

```cpp
```
uuid operator()( void const* buffer, std::size_t byte_count ) const;
```

Returns: :: A name-based UUID version 5 produced from a digest of the namespace passed to the constructor and the octets in the range `[(char const*)buffer, (char const*)buffer + byte_count)`.
Returns: :: A name-based UUID version 5 produced from a digest of the namespace passed to the constructor and the `byte_count` octets starting from `buffer`.
8 changes: 4 additions & 4 deletions doc/uuid/namespaces.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ uuid x500dn() noexcept;

This header provides definitions of the four namespaces defined in https://tools.ietf.org/html/rfc4122#appendix-C[RFC 4122, Appendix C].

```cpp
```
uuid dns() noexcept;
```

Returns: :: The DNS namespace UUID from RFC 4122, `{6ba7b810-9dad-11d1-80b4-00c04fd430c8}`.

```cpp
```
uuid url() noexcept;
```

Returns: :: The URL namespace UUID from RFC 4122, `{6ba7b811-9dad-11d1-80b4-00c04fd430c8}`.


```cpp
```
uuid oid() noexcept;
```

Returns: :: The OID namespace UUID from RFC 4122, `{6ba7b812-9dad-11d1-80b4-00c04fd430c8}`.

```cpp
```
uuid x500dn() noexcept;
```

Expand Down
8 changes: 4 additions & 4 deletions doc/uuid/nil_generator.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ uuid nil_uuid() noexcept;

The `nil_generator` class always generates a nil `uuid`.

```cpp
```
uuid operator()() const noexcept;
```

Returns: :: A nil UUID.

Example: ::
+
```cpp
```
using namespace boost::uuid;

nil_generator gen;
Expand All @@ -44,15 +44,15 @@ assert( u.is_nil() );

=== nil_uuid

```cpp
```
uuid nil_uuid() noexcept;
```

Returns: :: A nil UUID.

Example: ::
+
```cpp
```
using namespace boost::uuid;

uuid u = nil_uuid();
Expand Down
Loading

0 comments on commit 7677167

Please sign in to comment.