Skip to content

Commit bfee791

Browse files
committed
Update documentation
1 parent dd11457 commit bfee791

3 files changed

Lines changed: 79 additions & 11 deletions

File tree

doc/uuid/changes.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
:idprefix: changes_
55

6+
== Changes in Boost 1.91.0
7+
8+
* Added `from_chars` to `boost/uuid/uuid_io.hpp`.
9+
* Added a `noexcept` `operator()` overload to `string_generator`.
10+
* `string_generator` now supports the Unicode character types in addition to `char` and `wchar_t`.
11+
612
== Changes in Boost 1.90.0
713

814
* `string_generator` is now `constexpr` on {cpp}14 and higher.

doc/uuid/string_generator.adoc

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ struct string_generator
1515
using result_type = uuid;
1616
1717
template<class Ch, class Traits, class Alloc>
18-
uuid operator()( std::basic_string<Ch, Traits, Alloc> const& s ) const;
18+
constexpr uuid operator()( std::basic_string<Ch, Traits, Alloc> const& s ) const;
1919
20-
uuid operator()( char const* s ) const;
21-
uuid operator()( wchar_t const* s ) const;
20+
template<class Ch>
21+
constexpr uuid operator()( Ch const* s ) const;
2222
2323
template<class CharIterator>
24-
uuid operator()( CharIterator begin, CharIterator end ) const;
24+
constexpr uuid operator()( CharIterator first, CharIterator last ) const;
25+
26+
template<class CharIterator>
27+
constexpr uuid operator()( CharIterator first, CharIterator last,
28+
int& pos, from_chars_error& err ) const noexcept;
2529
};
2630
2731
}} // namespace boost::uuids
@@ -52,10 +56,10 @@ Invalid input will generate a `std::runtime_error` exception.
5256

5357
```
5458
template<class Ch, class Traits, class Alloc>
55-
uuid operator()( std::basic_string<Ch, Traits, Alloc> const& s ) const;
59+
constexpr uuid operator()( std::basic_string<Ch, Traits, Alloc> const& s ) const;
5660
```
5761

58-
Requires: :: The character type `Ch` of `s` must be either `char` or `wchar_t`.
62+
Requires: :: The character type `Ch` of `s` must be one of `char`, `wchar_t`, `char8_t`, `char16_t`, `char32_t`.
5963

6064
Effects: :: Parses the string `s` into a `uuid` and returns the result.
6165

@@ -71,10 +75,12 @@ uuid u2 = gen( std::wstring( L"01234567-89AB-CDEF-0123-456789ABCDEF" ) );
7175
```
7276

7377
```
74-
uuid operator()( char const* s ) const;
75-
uuid operator()( wchar_t const* s ) const;
78+
template<class Ch>
79+
constexpr uuid operator()( Ch const* s ) const;
7680
```
7781

82+
Requires: :: `Ch` must be a character type (one of `char`, `wchar_t`, `char8_t`, `char16_t`, `char32_t`).
83+
7884
Effects: :: Parses the string `s` into a `uuid` and returns the result.
7985

8086
Example: ::
@@ -90,12 +96,12 @@ uuid u2 = gen( L"01234567-89ab-cdef-0123-456789abcdef" );
9096

9197
```
9298
template<class CharIterator>
93-
uuid operator()( CharIterator begin, CharIterator end ) const;
99+
constexpr uuid operator()( CharIterator first, CharIterator last ) const;
94100
```
95101

96-
Requires: :: `CharIterator` must be an input iterator with a value type of either `char` or `wchar_t`.
102+
Requires: :: `CharIterator` must be an input iterator with a character value type (one of `char`, `wchar_t`, `char8_t`, `char16_t`, `char32_t`).
97103

98-
Effects: :: Parses the character sequence `[begin, end)` into a `uuid` and returns the result.
104+
Effects: :: Parses the character sequence `[first, last)` into a `uuid` and returns the result.
99105

100106
Example: ::
101107
+
@@ -110,3 +116,18 @@ uuid u1 = gen( s1.begin(), s1.end() );
110116
std::wstring s2( L"01234567-89AB-CDEF-0123-456789ABCDEF" );
111117
uuid u2 = gen( s2.begin(), s2.end() );
112118
```
119+
120+
```
121+
template<class CharIterator>
122+
constexpr uuid operator()( CharIterator first, CharIterator last,
123+
int& pos, from_chars_error& err ) const noexcept;
124+
```
125+
126+
Requires: :: `CharIterator` must be an input iterator with a character value type (one of `char`, `wchar_t`, `char8_t`, `char16_t`, `char32_t`).
127+
128+
Effects: ::
129+
Parses the character sequence `[first, last)` into a `uuid` and returns the result.
130+
On error, `pos` contains the position at which parsing failed, and `err` contains the error.
131+
On success, `err` contains `from_chars_error::none`.
132+
133+
NOTE: Unlike `from_chars`, this function does not allow extra input; if after a complete UUID is parsed, unconsumed characters remain, `err` is set to `from_chars_error::unexpected_extra_input`.

doc/uuid/uuid_io.adoc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,29 @@ template<class Ch, std::size_t N>
3838
std::string to_string( uuid const& u );
3939
std::wstring to_wstring( uuid const& u );
4040
41+
// from_chars
42+
43+
enum class from_chars_error
44+
{
45+
none = 0,
46+
47+
unexpected_end_of_input,
48+
hex_digit_expected,
49+
dash_expected,
50+
closing_brace_expected,
51+
unexpected_extra_input
52+
};
53+
54+
template<class Ch> struct from_chars_result
55+
{
56+
Ch const* ptr;
57+
from_chars_error ec;
58+
};
59+
60+
template<class Ch>
61+
constexpr from_chars_result<Ch>
62+
from_chars( Ch const* first, Ch const* last, uuid& u ) noexcept;
63+
4164
}} // namespace boost::uuids
4265
----
4366

@@ -209,3 +232,21 @@ std::string s1 = to_string( u );
209232

210233
std::wstring s2 = to_wstring( u );
211234
```
235+
236+
=== from_chars
237+
238+
```
239+
template<class Ch>
240+
constexpr from_chars_result<Ch>
241+
from_chars( Ch const* first, Ch const* last, uuid& u ) noexcept;
242+
```
243+
244+
Requires: :: `Ch` must be a character type (one of `char`, `wchar_t`, `char8_t`, `char16_t`, `char32_t`).
245+
246+
Effects: ::
247+
Parses a `uuid` string representation from the characters in the range `[first, last)` and stores the result in `u`.
248+
On error, the returned `from_chars_result` struct contains the error code in `ec` and `ptr` points to the character at which parsing failed.
249+
On success, `ec` contains `from_chars_error::none` and `ptr` points to the character immediately after the last `uuid` character.
250+
251+
NOTE: The values `from_chars_error::closing_brace_expected` and `from_chars_error::unexpected_extra_input` are never returned by `from_chars`.
252+
They can be returned from the nonthrowing `string_generator::operator()` overload.

0 commit comments

Comments
 (0)