Skip to content

Commit b3f3238

Browse files
Merge branch 'main' into f/comments
2 parents 5409d78 + 9b57d01 commit b3f3238

24 files changed

Lines changed: 224 additions & 61 deletions

docs/default_val.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ std::string s = p.last_name.value();
2525

2626
API convenience:
2727

28-
- .get(), .value(), operator()() — access the underlying value (const and non-const overloads).
28+
- .get(), .value(), operator()(), operator*() — access the underlying value (const and non-const overloads).
2929
- set(...) — assign underlying value.
3030

3131
## JSON behaviour

docs/flatten_structs.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,6 @@ This flattens all fields into a single JSON object:
6868
{"firstName":"Homer","lastName":"Simpson","age":45,"salary":60000.0}
6969
```
7070

71+
## API convenience
72+
73+
`rfl::Flatten` behaves like a thin wrapper around the underlying type. You can access the underlying value using `.get()`, `.value()`, `operator()()`, or `operator*()` (const and non-const overloads).

docs/generic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The resulting JSON strings looks as follows:
5555

5656
`rfl::Generic` contains some convenience methods that allow you to handle parsed data:
5757

58-
You can retrieve the underlying `std::variant` using `.get()`. This then allows you to handle allow possible seven cases using the [visitor pattern](https://en.cppreference.com/w/cpp/utility/variant/visit).
58+
You can retrieve the underlying `std::variant` using `.get()`, `.value()`, `operator()()`, or `operator*()`. This then allows you to handle all possible seven cases using the [visitor pattern](https://en.cppreference.com/w/cpp/utility/variant/visit).
5959

6060
If you have a guess what the types of a particular field might be, you can use any of the seven convenience methods `.to_array()`, `.to_bool()`, `.to_double()`, `.to_int()`, `.to_null()`, `.to_object()`, `.to_string()`. Each
6161
of these methods will return an `rfl::Result<...>` with the corresponding type, if the `rfl::Generic` does indeed contain such a type.

docs/json_schema.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ const std::string json_schema = rfl::json::to_schema<Person>(rfl::json::pretty);
139139
}
140140
```
141141

142+
`rfl::Description` behaves like a thin wrapper around the underlying type. Much like `rfl::Field`, you can access the underlying value using `.get()`, `.value()`, `operator()()`, or `operator*()` (const and non-const overloads).
143+
142144
You also add a description to the entire JSON schema:
143145

144146
```cpp

docs/named_tuple.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ person.apply([](const auto& f) {
107107
auto field_name = f.name();
108108
const auto& value = f.value();
109109
});
110+
111+
### `rfl::Field` API convenience
112+
113+
`rfl::Field` behaves like a thin wrapper around the underlying type. You can access the underlying value using `.get()`, `.value()`, `operator()()`, or `operator*()` (const and non-const overloads).
110114
```
111115

112116
### Monadic operations: `.transform` and `.and_then`

docs/number_systems.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ This results in the following JSON:
2525
Note that the contained type must be integral for `rfl::Hex` and `rfl::Oct`. For `rfl::Binary`, it must be unsigned. Moreover,
2626
the number of digits for `rfl::Binary` will be determined by the bitsize of the type.
2727

28-
You can access the contained value using `.value()`, `.get()` or simply `operator()`.
28+
You can access the contained value using `.value()`, `.get()`, `operator()()`, or `operator*()` (const and non-const overloads).
2929

3030
You can produce the string representation using `.str()`.

docs/rfl_skip.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ You can access the underlying value in the field `town` using any of the followi
5050
person.town();
5151
person.town.get();
5252
person.town.value();
53+
*person.town;
5354
```
5455

5556
You can assign the underlying field just like any other field:

docs/supported_formats/xml.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ This will result in the following XML string:
137137

138138
Note that only boolean values, string values, integral values or floating point values can be represented as attributes.
139139

140+
`rfl::Attribute` behaves like a thin wrapper around the underlying type. Much like `rfl::Field`, you can access the underlying value using `.get()`, `.value()`, `operator()()`, or `operator*()` (const and non-const overloads).
141+
140142
There also is a special field name called `xml_content` to be used when you want a value directly inserted into the content.
141143
Again, only boolean values, string values, integral values or floating point values can be represented this way:
142144

docs/timestamps.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ const auto person1 = Person{.birthday = "1970-01-01"};
2727
const auto person2 = Person{.birthday = std::tm{...}};
2828
```
2929

30-
You can access the underlying `std::tm` struct using the `.tm()` method and you can generate
31-
the string representation using the `.str()` method.
30+
You can access the underlying `std::tm` struct using the `.tm()`, `.get()`, `.value()`, `operator()()`, or `operator*()` method (const and non-const overloads). You can generate the string representation using the `.str()` method.
3231

3332
```cpp
3433
const std::tm birthday = person1.birthday.tm();

docs/validating_numbers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using IntGreaterThan10 = rfl::Validator<int, rfl::Minimum<10>>;
1010
When you then use the type `IntGreaterThan10` inside you `rfl::Field`, the condition will be automatically
1111
validated.
1212

13-
The underlying value can be retrieved using the `.value()` method.
13+
The underlying value can be retrieved using the `.get()`, `.value()`, `operator()()`, or `operator*()` method (const and non-const overloads).
1414

1515
The current conditions are currently supported by reflect-cpp:
1616

0 commit comments

Comments
 (0)