@@ -15,32 +15,28 @@ While the <<ref_value>> container makes it easy to create ad-hoc structures,
1515often it is necessary to convert between JSON and user-defined types or types
1616from the standard library.
1717
18- The function template <<ref_value_from>> provides an interface to construct
19- a <<ref_value>> from a type `T` . The function template <<ref_value_to>>
20- converts in the opposite direction, from a type `T` to <<ref_value>>. Both
21- support a wide variety of different
18+ Boost.JSON provides several components to achieve this. For example, the
19+ function template <<ref_value_from>> provides an interface to construct
20+ a <<ref_value>> from a type `T` , and the function template <<ref_value_to>>
21+ converts in the opposite direction, from a type `T` to <<ref_value>>. These
22+ components support a wide variety of different
2223https://en.cppreference.com/w/cpp/language/types[fundamental types], such as
23- `int` or `double` , standard library types, such as `std::string` or
24- `std::vector<T>` , and can be extended to support user-defined types.
24+ `int` or `double` , standard library types, such as {std_string} or
25+ {std_vector} , and can be extended to support user-defined types.
2526
2627[source]
2728----
2829include::../../../test/snippets.cpp[tag=snippet_conv_1,indent=0]
2930----
3031
31- For the type `T` , the appropriate conversion approach is chosen from the
32- following list of categories. The first matching category is selected .
32+ For a type `T` the library chooses a conversion implementation that corresponds
33+ to the first matching category from the following list .
3334
3435.Conversion categories
3536[%autowidth,cols=4]
3637|===
3738|Category of T|Comment|`value_from` behavior|`value_to` behavior
3839
39- |Custom conversion.
40- |
41- |Custom behavior.
42- |Custom behavior.
43-
4440|Boost.JSON container.
4541|
4642|The result is equal to the input value.
@@ -55,66 +51,66 @@ following list of categories. The first matching category is selected.
5551|
5652a| The result is a number equal to input and has the type
5753
58- * `std::int64_t` , if `T` is a signed integer' ; or
54+ * `std::int64_t` , if `T` is a signed integer; or
5955* `std::uint64_t` , if `T` is an unsigned integer; or
6056* `double` otherwise.
6157|The result is created via <<ref_value_to_number>>.
6258
63- |Type satisfying <<ref_is_null_like >>
59+ |<<ref_null_category >>
6460|Intended for types like {std_monostate} .
6561|The result is a null value.
6662|The result is default-constructed.
6763
68- |Type satisfying <<ref_is_string_like>>.
69- |A sequence of `char` s, e.g. `std::string` .
64+ |<<ref_string_category>>
65+ |A sequence of `` char`` s, e.g. {std_string} .
7066|The result is a <<ref_string>>.
7167|The result is constructed from a <<ref_string_view>>.
7268
73- |Type satisfying <<ref_is_variant_like>>.
74- |`std::variant` and similar types, e.g. `boost::variant2::variant` .
69+ |<<ref_variant_category>>
70+ |{std_variant} and similar types, e.g. {ref_variant} .
7571|The result is equal to the result of conversion of the active variant
7672 alternative.
7773|The result holds the first alternative for which a conversion succeeds.
7874
79- |Type satisfying <<ref_is_optional_like >>
80- |
75+ |<<ref_optional_category >>
76+ |{std_optional} and similar types, e.g. {ref_optional} .
8177|If the input value is empty, the result is a `null` . Otherwise it is
8278 equivalent to conversion of the object stored inside of optional.
8379|The result is default constructed if the input value is `null` . Otherwise the
8480 result is constructed from the result of conversion of the input to the
8581 type stored in optional.
8682
87- |Type satisfying <<ref_is_map_like>>.
88- |A one-to-one mapping (e.g. `std::map` ) with string-like keys.
83+ |<<ref_map_category>>
84+ |A one-to-one mapping (e.g. {std_map} ) with string-like keys.
8985|The result is an <<ref_object>>.
9086|The result is default-constructed, and elements are `insert` -ed at the end.
9187
92- |Type satisfying <<ref_is_sequence_like>>.
93- |A sequence of elements, e.g. `std::vector` .
88+ |<<ref_sequence_category>>
89+ |A sequence of elements, e.g. {std_vector} .
9490|The result is an <<ref_array>>.
9591|The result is default-constructed, and elements are `insert` -ed at the end.
9692
97- |Type satisfying <<ref_is_tuple_like>>.
98- |A heterogenous sequence with fixed size, e.g. `std::tuple` and `std::pair` .
93+ |<<ref_tuple_category>>
94+ |A heterogenous sequence with fixed size, e.g. {std_tuple} and {std_pair} .
9995|The result is an <<ref_array>>.
10096|The result is constructed with the array elements as constructor arguments.
10197
102- |Type satisfying <<ref_is_described_class >>
98+ |<<ref_described_class_category >>
10399|
104100|The result is an <<ref_object>> with described members' names as keys.
105101|The result is default-constructed and described members are assigned
106102 corresponding values.
107103
108- |Type satisfying <<ref_is_described_enum >>
104+ |<<ref_described_enum_category >>
109105|
110106|If the input value is equal to one of the described enumerators, the result is
111107 a <<ref_string>>, containing its name. Otherwise it's equal to the input
112108 value converted to its underlying type.
113109|The result is the described enumerator, corresponding to the input
114110 <<ref_string>>.
115111
116- |Type satisfying <<ref_is_path_like>>.
117- |`std::filesystem::path` and similar types, e.g. `boost::filesystem::path` .
112+ |<<ref_path_category>>
113+ |{std_path} and similar types, e.g. {ref_path} .
118114|The result is equal to the result of `path::generic_string` .
119115|The result is constructed from two pointers to `const char` .
120116|===
@@ -127,11 +123,11 @@ contained objects is applied recursively. For example:
127123include::../../../test/snippets.cpp[tag=snippet_conv_recursive,indent=0]
128124----
129125
130- Here, the map is converted into an <<ref_object>>, since it matches
131- <<ref_is_map_like >>. Each of its keys is converted into a <<ref_string>>, as
132- `std::string` matches <<ref_is_string_like >>, and each of its values is
133- converted into an <<ref_array>>, as `std::pair` matches <<ref_is_tuple_like >>.
134- Finally, elements of pairs are converted into a `std::int64_t` number and
126+ Here, the map is converted to an <<ref_object>>, since its conversion category
127+ is <<ref_map_category >>. Each of its keys is converted into a <<ref_string>>,
128+ as `std::string` is of <<ref_string_category >>, and each of its values is
129+ converted into an <<ref_array>>, as `std::pair` is of <<ref_tuple_category >>.
130+ Finally, elements of pairs are converted to a `std::int64_t` number and
135131a `bool` .
136132
137133:leveloffset: +1
@@ -140,8 +136,8 @@ include::custom.adoc[]
140136include::nothrow.adoc[]
141137include::alloc.adoc[]
142138include::context.adoc[]
143- include::forward.adoc[]
144139include::direct.adoc[]
140+ include::forward.adoc[]
145141include::guidelines.adoc[]
146142
147143:leveloffset: -1
0 commit comments