Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/commented.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ This will result in the following XML:

`rfl::Commented` provides several ways to access and modify the underlying value and the comment:

- `.get()`, `.value()`, `operator()()` — access the underlying value (const and non-const overloads).
- `.get()`, `.value()`, `operator()()`, `operator*()`, `operator->()` — access the underlying value (const and non-const overloads).
- `.comment()` — returns an `std::optional<std::string>` containing the comment.
- `.add_comment(std::string)` — sets or updates the comment.
- `.set(...)`, `operator=(...)` — assign the underlying value.
Expand Down
2 changes: 1 addition & 1 deletion docs/default_val.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ std::string s = p.last_name.value();

API convenience:

- .get(), .value(), operator()(), operator*() — access the underlying value (const and non-const overloads).
- .get(), .value(), operator()(), operator*(), operator->() — access the underlying value (const and non-const overloads).
- set(...) — assign underlying value.

## JSON behaviour
Expand Down
2 changes: 1 addition & 1 deletion docs/flatten_structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ This flattens all fields into a single JSON object:

## API convenience

`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).
`rfl::Flatten` behaves like a thin wrapper around the underlying type. You can access the underlying value using `.get()`, `.value()`, `operator()()`, `operator*()`, or `operator->()` (const and non-const overloads).
2 changes: 1 addition & 1 deletion docs/generic.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The resulting JSON strings looks as follows:

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

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).
You can retrieve the underlying `std::variant` using `.get()`, `.value()`, `operator()()`, `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).

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
of these methods will return an `rfl::Result<...>` with the corresponding type, if the `rfl::Generic` does indeed contain such a type.
Expand Down
4 changes: 2 additions & 2 deletions docs/json_schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const std::string json_schema = rfl::json::to_schema<Person>(rfl::json::pretty);
}
```

`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).
`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()()`, `operator*()`, or `operator->()` (const and non-const overloads).

You also add a description to the entire JSON schema:

Expand Down Expand Up @@ -243,4 +243,4 @@ const std::string json_schema = rfl::json::to_schema<Person>(rfl::json::pretty);
}
```

`rfl::Deprecated` behaves like a thin wrapper around the underlying type, just like `rfl::Description`. You can access the underlying value using `.get()`, `.value()`, `operator()()`, or the assignment operator.
`rfl::Deprecated` behaves like a thin wrapper around the underlying type, just like `rfl::Description`. You can access the underlying value using `.get()`, `.value()`, `operator()()`, `operator*()`, `operator->()`, or the assignment operator.
2 changes: 1 addition & 1 deletion docs/named_tuple.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ person.apply([](const auto& f) {

### `rfl::Field` API convenience

`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).
`rfl::Field` behaves like a thin wrapper around the underlying type. You can access the underlying value using `.get()`, `.value()`, `operator()()`, `operator*()`, or `operator->()` (const and non-const overloads).
```

### Monadic operations: `.transform` and `.and_then`
Expand Down
2 changes: 1 addition & 1 deletion docs/number_systems.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ This results in the following JSON:
Note that the contained type must be integral for `rfl::Hex` and `rfl::Oct`. For `rfl::Binary`, it must be unsigned. Moreover,
the number of digits for `rfl::Binary` will be determined by the bitsize of the type.

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

You can produce the string representation using `.str()`.
2 changes: 1 addition & 1 deletion docs/supported_formats/xml.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ This will result in the following XML string:

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

`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).
`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()()`, `operator*()`, or `operator->()` (const and non-const overloads).

There also is a special field name called `xml_content` to be used when you want a value directly inserted into the content.
Again, only boolean values, string values, integral values or floating point values can be represented this way:
Expand Down
2 changes: 1 addition & 1 deletion docs/timestamps.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const auto person1 = Person{.birthday = "1970-01-01"};
const auto person2 = Person{.birthday = std::tm{...}};
```

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.
You can access the underlying `std::tm` struct using the `.tm()`, `.get()`, `.value()`, `operator()()`, `operator*()`, or `operator->()` method (const and non-const overloads). You can generate the string representation using the `.str()` method.

```cpp
const std::tm birthday = person1.birthday.tm();
Expand Down
2 changes: 1 addition & 1 deletion docs/validating_numbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using IntGreaterThan10 = rfl::Validator<int, rfl::Minimum<10>>;
When you then use the type `IntGreaterThan10` inside you `rfl::Field`, the condition will be automatically
validated.

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

The current conditions are currently supported by reflect-cpp:

Expand Down
8 changes: 8 additions & 0 deletions include/rfl/Attribute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ struct Attribute {
/// @return Const reference to the stored value
const Type& operator()() const noexcept { return value_; }

/// Pointer to the underlying value.
/// @return Pointer to the stored value
Type* operator->() noexcept { return &value_; }

/// Pointer to the underlying value (const).
/// @return Const pointer to the stored value
const Type* operator->() const noexcept { return &value_; }

/// Assigns a new value.
/// @param _value The value to assign
/// @return Reference to this Attribute
Expand Down
8 changes: 8 additions & 0 deletions include/rfl/Binary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ struct Binary {
/// @return Const reference to the stored value
const Type& operator()() const noexcept { return value_; }

/// Pointer to the underlying value.
/// @return Pointer to the stored value
Type* operator->() noexcept { return &value_; }

/// Pointer to the underlying value (const).
/// @return Const pointer to the stored value
const Type* operator->() const noexcept { return &value_; }

/// Assigns a new integer value.
/// @param _value The value to assign
/// @return Reference to this Binary
Expand Down
8 changes: 8 additions & 0 deletions include/rfl/Commented.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ struct Commented {
/// @return Const reference to the stored value
const Type& operator()() const { return value_; }

/// Pointer to the underlying value.
/// @return Pointer to the stored value
Type* operator->() { return &value_; }

/// Pointer to the underlying value (const).
/// @return Const pointer to the stored value
const Type* operator->() const { return &value_; }

/// Dereference operator - returns the underlying value.
/// @return Reference to the stored value
Type& operator*() { return value_; }
Expand Down
8 changes: 8 additions & 0 deletions include/rfl/DefaultVal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ struct DefaultVal {
/// @return Const reference to the stored value
const Type& operator()() const noexcept { return value_; }

/// Pointer to the underlying value.
/// @return Pointer to the stored value
Type* operator->() noexcept { return &value_; }

/// Pointer to the underlying value (const).
/// @return Const pointer to the stored value
const Type* operator->() const noexcept { return &value_; }

/// Assigns a new value.
/// @param _value The value to assign
/// @return Reference to this DefaultVal
Expand Down
8 changes: 8 additions & 0 deletions include/rfl/Deprecated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ struct Deprecated {
/// @return Const reference to the stored value
const Type& operator()() const { return value_; }

/// Pointer to the underlying value.
/// @return Pointer to the stored value
Type* operator->() { return &value_; }

/// Pointer to the underlying value (const).
/// @return Const pointer to the stored value
const Type* operator->() const { return &value_; }

/// Assigns a new value.
/// @param _value The value to assign
/// @return Reference to this Deprecated
Expand Down
8 changes: 8 additions & 0 deletions include/rfl/Description.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ struct Description {
/// @return Const reference to the stored value
const Type& operator()() const noexcept { return value_; }

/// Pointer to the underlying value.
/// @return Pointer to the stored value
Type* operator->() noexcept { return &value_; }

/// Pointer to the underlying value (const).
/// @return Const pointer to the stored value
const Type* operator->() const noexcept { return &value_; }

/// Assigns a new value.
/// @param _value The value to assign
/// @return Reference to this Description
Expand Down
8 changes: 8 additions & 0 deletions include/rfl/Field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ struct Field {
/// @return Const reference to the stored value
const Type& operator()() const noexcept { return value_; }

/// Pointer to the underlying value.
/// @return Pointer to the stored value
Type* operator->() noexcept { return &value_; }

/// Pointer to the underlying value (const).
/// @return Const pointer to the stored value
const Type* operator->() const noexcept { return &value_; }

/// Assigns a new value to the field.
/// @param _value The value to assign
/// @return Reference to this field
Expand Down
8 changes: 8 additions & 0 deletions include/rfl/Flatten.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ struct Flatten {
/// Returns the underlying object.
const Type& operator()() const noexcept { return value_; }

/// Pointer to the underlying value.
/// @return Pointer to the stored value
Type* operator->() noexcept { return &value_; }

/// Pointer to the underlying value (const).
/// @return Const pointer to the stored value
const Type* operator->() const noexcept { return &value_; }

/// Returns the underlying object.
Type& value() noexcept { return value_; }

Expand Down
8 changes: 8 additions & 0 deletions include/rfl/Hex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ struct Hex {
/// @return Const reference to the stored value
const Type& operator()() const noexcept { return value_; }

/// Pointer to the underlying value.
/// @return Pointer to the stored value
Type* operator->() noexcept { return &value_; }

/// Pointer to the underlying value (const).
/// @return Const pointer to the stored value
const Type* operator->() const noexcept { return &value_; }

/// Assigns a new integer value.
/// @param _value The value to assign
/// @return Reference to this Hex
Expand Down
8 changes: 8 additions & 0 deletions include/rfl/Oct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ struct Oct {
/// Returns the underlying object.
const Type& operator()() const noexcept { return value_; }

/// Pointer to the underlying value.
/// @return Pointer to the stored value
Type* operator->() noexcept { return &value_; }

/// Pointer to the underlying value (const).
/// @return Const pointer to the stored value
const Type* operator->() const noexcept { return &value_; }

/// Assigns the underlying object.
auto& operator=(const Type& _value) {
value_ = _value;
Expand Down
8 changes: 8 additions & 0 deletions include/rfl/Positional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ struct Positional {
/// @return Const reference to the stored value
const Type& operator()() const noexcept { return value_; }

/// Pointer to the underlying value.
/// @return Pointer to the stored value
Type* operator->() noexcept { return &value_; }

/// Pointer to the underlying value (const).
/// @return Const pointer to the stored value
const Type* operator->() const noexcept { return &value_; }

/// Assigns a new value.
/// @param _value The value to assign
/// @return Reference to this Positional
Expand Down
8 changes: 8 additions & 0 deletions include/rfl/Rename.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ struct Rename {
/// @return Const reference to the stored value
const Type& operator()() const noexcept { return value_; }

/// Pointer to the underlying value.
/// @return Pointer to the stored value
Type* operator->() noexcept { return &value_; }

/// Pointer to the underlying value (const).
/// @return Const pointer to the stored value
const Type* operator->() const noexcept { return &value_; }

/// Assigns a new value.
/// @param _value The value to assign
/// @return Reference to this Rename
Expand Down
8 changes: 8 additions & 0 deletions include/rfl/Short.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ struct Short {
/// @return Const reference to the underlying value.
const Type& operator()() const noexcept { return value_; }

/// @brief Pointer to the underlying value.
/// @return Pointer to the underlying value.
Type* operator->() noexcept { return &value_; }

/// @brief Pointer to the underlying value (const).
/// @return Const pointer to the underlying value.
const Type* operator->() const noexcept { return &value_; }

/// @brief Assigns a new value to the underlying object.
/// @param _value The value to assign.
/// @return Reference to this Short.
Expand Down
8 changes: 8 additions & 0 deletions include/rfl/Timestamp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ class Timestamp {
/// Returns the underlying object.
const std::tm& operator()() const noexcept { return tm_; }

/// Pointer to the underlying object.
/// @return Pointer to the stored std::tm
std::tm* operator->() noexcept { return &tm_; }

/// Pointer to the underlying object (const).
/// @return Const pointer to the stored std::tm
const std::tm* operator->() const noexcept { return &tm_; }

/// Returns the underlying object.
std::tm& value() noexcept { return tm_; }

Expand Down
8 changes: 8 additions & 0 deletions include/rfl/Validator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ struct Validator {
/// Returns the underlying object.
const T& operator()() const noexcept { return value_; }

/// Pointer to the underlying value.
/// @return Pointer to the stored value
T* operator->() noexcept { return &value_; }

/// Pointer to the underlying value (const).
/// @return Const pointer to the stored value
const T* operator->() const noexcept { return &value_; }

/// Exposes the underlying value.
T& value() noexcept { return value_; }

Expand Down
8 changes: 8 additions & 0 deletions include/rfl/internal/Skip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ class Skip {
/// Returns the underlying object.
const Type& operator()() const noexcept { return value_; }

/// Pointer to the underlying value.
/// @return Pointer to the stored value
Type* operator->() noexcept { return &value_; }

/// Pointer to the underlying value (const).
/// @return Const pointer to the stored value
const Type* operator->() const noexcept { return &value_; }

/// Assigns the underlying object.
auto& operator=(const Type& _value) {
value_ = _value;
Expand Down
Loading