From 3650e5beb1ef4297e427c3b0c7b5acd00e242667 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 8 Feb 2026 01:26:26 +0000 Subject: [PATCH 1/2] Add operator* and non-const get() to all wrapper classes This commit adds `operator*` (const and non-const) to all reflect-cpp wrapper classes, including `DefaultVal`, `Field`, `Validator`, `Description`, `Rename`, `Attribute`, `Flatten`, `Hex`, `Oct`, `Binary`, `Generic`, `Timestamp`, and `internal::Skip`. Additionally, it ensures that these classes have non-const `.get()`, `.value()`, and `operator()()` where appropriate, providing consistent access to the underlying value. Documentation has also been updated to reflect these changes. Co-authored-by: liuzicheng1987 <19538706+liuzicheng1987@users.noreply.github.com> --- docs/default_val.md | 2 +- docs/flatten_structs.md | 3 +++ docs/generic.md | 2 +- docs/json_schema.md | 2 ++ docs/named_tuple.md | 4 ++++ docs/number_systems.md | 2 +- docs/rfl_skip.md | 1 + docs/supported_formats/xml.md | 2 ++ docs/timestamps.md | 3 +-- docs/validating_numbers.md | 2 +- include/rfl/Attribute.hpp | 9 +++++++++ include/rfl/Binary.hpp | 9 +++++++++ include/rfl/DefaultVal.hpp | 9 +++++++++ include/rfl/Description.hpp | 9 +++++++++ include/rfl/Field.hpp | 9 +++++++++ include/rfl/Flatten.hpp | 12 ++++++++++++ include/rfl/Generic.hpp | 21 +++++++++++++++++++++ include/rfl/Hex.hpp | 9 +++++++++ include/rfl/Oct.hpp | 9 +++++++++ include/rfl/Rename.hpp | 9 +++++++++ include/rfl/Timestamp.hpp | 24 ++++++++++++++++++++++++ include/rfl/Validator.hpp | 18 ++++++++++++++++++ include/rfl/internal/Skip.hpp | 6 ++++++ 23 files changed, 170 insertions(+), 6 deletions(-) diff --git a/docs/default_val.md b/docs/default_val.md index e6b61fdd..7801dfb6 100644 --- a/docs/default_val.md +++ b/docs/default_val.md @@ -25,7 +25,7 @@ std::string s = p.last_name.value(); API convenience: -- .get(), .value(), operator()() — access the underlying value (const and non-const overloads). +- .get(), .value(), operator()(), operator*() — access the underlying value (const and non-const overloads). - set(...) — assign underlying value. ## JSON behaviour diff --git a/docs/flatten_structs.md b/docs/flatten_structs.md index 8544f638..6eb6bd7d 100644 --- a/docs/flatten_structs.md +++ b/docs/flatten_structs.md @@ -68,3 +68,6 @@ This flattens all fields into a single JSON object: {"firstName":"Homer","lastName":"Simpson","age":45,"salary":60000.0} ``` +## 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). diff --git a/docs/generic.md b/docs/generic.md index 8af89a30..99005d1b 100644 --- a/docs/generic.md +++ b/docs/generic.md @@ -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()`. This then allows you to handle allow 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()()`, 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. diff --git a/docs/json_schema.md b/docs/json_schema.md index f87e2e42..6332fd38 100644 --- a/docs/json_schema.md +++ b/docs/json_schema.md @@ -139,6 +139,8 @@ const std::string json_schema = rfl::json::to_schema(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). + You also add a description to the entire JSON schema: ```cpp diff --git a/docs/named_tuple.md b/docs/named_tuple.md index 7a90f2f1..64da742c 100644 --- a/docs/named_tuple.md +++ b/docs/named_tuple.md @@ -107,6 +107,10 @@ person.apply([](const auto& f) { auto field_name = f.name(); const auto& value = f.value(); }); + +### `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). ``` ### Monadic operations: `.transform` and `.and_then` diff --git a/docs/number_systems.md b/docs/number_systems.md index 89c58687..c3931052 100644 --- a/docs/number_systems.md +++ b/docs/number_systems.md @@ -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()` or simply `operator()`. +You can access the contained value using `.value()`, `.get()`, `operator()()`, or `operator*()` (const and non-const overloads). You can produce the string representation using `.str()`. diff --git a/docs/rfl_skip.md b/docs/rfl_skip.md index 2e53bb5b..64515f88 100644 --- a/docs/rfl_skip.md +++ b/docs/rfl_skip.md @@ -50,6 +50,7 @@ You can access the underlying value in the field `town` using any of the followi person.town(); person.town.get(); person.town.value(); +*person.town; ``` You can assign the underlying field just like any other field: diff --git a/docs/supported_formats/xml.md b/docs/supported_formats/xml.md index 533f60f5..cf1ddf41 100644 --- a/docs/supported_formats/xml.md +++ b/docs/supported_formats/xml.md @@ -137,6 +137,8 @@ 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). + 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: diff --git a/docs/timestamps.md b/docs/timestamps.md index 1dcae34a..26b73241 100644 --- a/docs/timestamps.md +++ b/docs/timestamps.md @@ -27,8 +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()` method and you can generate -the string representation using the `.str()` method. +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. ```cpp const std::tm birthday = person1.birthday.tm(); diff --git a/docs/validating_numbers.md b/docs/validating_numbers.md index dc99b904..c39c9d73 100644 --- a/docs/validating_numbers.md +++ b/docs/validating_numbers.md @@ -10,7 +10,7 @@ using IntGreaterThan10 = rfl::Validator>; 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 `.value()` method. +The underlying value can be retrieved using the `.get()`, `.value()`, `operator()()`, or `operator*()` method (const and non-const overloads). The current conditions are currently supported by reflect-cpp: diff --git a/include/rfl/Attribute.hpp b/include/rfl/Attribute.hpp index 1af50846..94377c83 100644 --- a/include/rfl/Attribute.hpp +++ b/include/rfl/Attribute.hpp @@ -55,6 +55,15 @@ struct Attribute { /// Returns the underlying object. const Type& get() const { return value_; } + /// Returns the underlying object. + Type& get() { return value_; } + + /// Returns the underlying object. + Type& operator*() { return value_; } + + /// Returns the underlying object. + const Type& operator*() const { return value_; } + /// Returns the underlying object. Type& operator()() { return value_; } diff --git a/include/rfl/Binary.hpp b/include/rfl/Binary.hpp index 6c5550d4..f06c6186 100644 --- a/include/rfl/Binary.hpp +++ b/include/rfl/Binary.hpp @@ -56,6 +56,15 @@ struct Binary { /// Returns the underlying object. const Type& get() const { return value_; } + /// Returns the underlying object. + Type& get() { return value_; } + + /// Returns the underlying object. + Type& operator*() { return value_; } + + /// Returns the underlying object. + const Type& operator*() const { return value_; } + /// Returns the underlying object. Type& operator()() { return value_; } diff --git a/include/rfl/DefaultVal.hpp b/include/rfl/DefaultVal.hpp index db43ebe4..73a8732e 100644 --- a/include/rfl/DefaultVal.hpp +++ b/include/rfl/DefaultVal.hpp @@ -53,6 +53,15 @@ struct DefaultVal { /// Returns the underlying object. const Type& get() const { return value_; } + /// Returns the underlying object. + Type& get() { return value_; } + + /// Returns the underlying object. + Type& operator*() { return value_; } + + /// Returns the underlying object. + const Type& operator*() const { return value_; } + /// Returns the underlying object. Type& operator()() { return value_; } diff --git a/include/rfl/Description.hpp b/include/rfl/Description.hpp index cc33560e..3f8d9fbd 100644 --- a/include/rfl/Description.hpp +++ b/include/rfl/Description.hpp @@ -68,6 +68,15 @@ struct Description { /// Returns the underlying object. const Type& get() const { return value_; } + /// Returns the underlying object. + Type& get() { return value_; } + + /// Returns the underlying object. + Type& operator*() { return value_; } + + /// Returns the underlying object. + const Type& operator*() const { return value_; } + /// Returns the underlying object. Type& operator()() { return value_; } diff --git a/include/rfl/Field.hpp b/include/rfl/Field.hpp index 2f436dad..c6281a22 100644 --- a/include/rfl/Field.hpp +++ b/include/rfl/Field.hpp @@ -61,6 +61,15 @@ struct Field { /// Returns the underlying object. const Type& get() const { return value_; } + /// Returns the underlying object. + Type& get() { return value_; } + + /// Returns the underlying object. + Type& operator*() { return value_; } + + /// Returns the underlying object. + const Type& operator*() const { return value_; } + /// The name of the field. constexpr static std::string_view name() { return name_.string_view(); } diff --git a/include/rfl/Flatten.hpp b/include/rfl/Flatten.hpp index 579cb7eb..aa96d0b6 100644 --- a/include/rfl/Flatten.hpp +++ b/include/rfl/Flatten.hpp @@ -47,12 +47,24 @@ struct Flatten { /// Returns the underlying object. const Type& get() const { return value_; } + /// Returns the underlying object. + Type& operator*() { return value_; } + + /// Returns the underlying object. + const Type& operator*() const { return value_; } + /// Returns the underlying object. Type& operator()() { return value_; } /// Returns the underlying object. const Type& operator()() const { return value_; } + /// Returns the underlying object. + Type& value() { return value_; } + + /// Returns the underlying object. + const Type& value() const { return value_; } + /// Assigns the underlying object. Flatten& operator=(const T& _value) { value_ = _value; diff --git a/include/rfl/Generic.hpp b/include/rfl/Generic.hpp index 3b1f97a6..8494d143 100644 --- a/include/rfl/Generic.hpp +++ b/include/rfl/Generic.hpp @@ -53,6 +53,27 @@ class RFL_API Generic { /// Returns the underlying object. const VariantType& get() const { return value_; } + /// Returns the underlying object. + VariantType& get() { return value_; } + + /// Returns the underlying object. + VariantType& operator*() { return value_; } + + /// Returns the underlying object. + const VariantType& operator*() const { return value_; } + + /// Returns the underlying object. + VariantType& operator()() { return value_; } + + /// Returns the underlying object. + const VariantType& operator()() const { return value_; } + + /// Returns the underlying object. + VariantType& value() { return value_; } + + /// Returns the underlying object. + const VariantType& value() const { return value_; } + /// Whether the object contains the null value. bool is_null() const noexcept; diff --git a/include/rfl/Hex.hpp b/include/rfl/Hex.hpp index 678697f2..d410fbcd 100644 --- a/include/rfl/Hex.hpp +++ b/include/rfl/Hex.hpp @@ -54,6 +54,15 @@ struct Hex { /// Returns the underlying object. const Type& get() const { return value_; } + /// Returns the underlying object. + Type& get() { return value_; } + + /// Returns the underlying object. + Type& operator*() { return value_; } + + /// Returns the underlying object. + const Type& operator*() const { return value_; } + /// Returns the underlying object. Type& operator()() { return value_; } diff --git a/include/rfl/Oct.hpp b/include/rfl/Oct.hpp index cbe2467f..8fe799a2 100644 --- a/include/rfl/Oct.hpp +++ b/include/rfl/Oct.hpp @@ -55,6 +55,15 @@ struct Oct { /// Returns the underlying object. const Type& get() const { return value_; } + /// Returns the underlying object. + Type& get() { return value_; } + + /// Returns the underlying object. + Type& operator*() { return value_; } + + /// Returns the underlying object. + const Type& operator*() const { return value_; } + /// Returns the underlying object. Type& operator()() { return value_; } diff --git a/include/rfl/Rename.hpp b/include/rfl/Rename.hpp index 99adc62a..7e49103b 100644 --- a/include/rfl/Rename.hpp +++ b/include/rfl/Rename.hpp @@ -64,6 +64,15 @@ struct Rename { /// Returns the underlying object. const Type& get() const { return value_; } + /// Returns the underlying object. + Type& get() { return value_; } + + /// Returns the underlying object. + Type& operator*() { return value_; } + + /// Returns the underlying object. + const Type& operator*() const { return value_; } + /// Returns the underlying object. Type& operator()() { return value_; } diff --git a/include/rfl/Timestamp.hpp b/include/rfl/Timestamp.hpp index 64468229..e8efb397 100644 --- a/include/rfl/Timestamp.hpp +++ b/include/rfl/Timestamp.hpp @@ -71,6 +71,30 @@ class Timestamp { return from_string(_str); } + /// Returns the underlying object. + const std::tm& get() const { return tm_; } + + /// Returns the underlying object. + std::tm& get() { return tm_; } + + /// Returns the underlying object. + std::tm& operator*() { return tm_; } + + /// Returns the underlying object. + const std::tm& operator*() const { return tm_; } + + /// Returns the underlying object. + std::tm& operator()() { return tm_; } + + /// Returns the underlying object. + const std::tm& operator()() const { return tm_; } + + /// Returns the underlying object. + std::tm& value() { return tm_; } + + /// Returns the underlying object. + const std::tm& value() const { return tm_; } + /// Necessary for the serialization to work. ReflectionType reflection() const { char outstr[200]; diff --git a/include/rfl/Validator.hpp b/include/rfl/Validator.hpp index cd7cd578..98a59fe3 100644 --- a/include/rfl/Validator.hpp +++ b/include/rfl/Validator.hpp @@ -92,6 +92,24 @@ struct Validator { return value() == _other.value(); } + /// Returns the underlying object. + const T& get() const { return value_; } + + /// Returns the underlying object. + T& get() { return value_; } + + /// Returns the underlying object. + T& operator*() { return value_; } + + /// Returns the underlying object. + const T& operator*() const { return value_; } + + /// Returns the underlying object. + T& operator()() { return value_; } + + /// Returns the underlying object. + const T& operator()() const { return value_; } + /// Exposes the underlying value. T& value() { return value_; } diff --git a/include/rfl/internal/Skip.hpp b/include/rfl/internal/Skip.hpp index 843a167b..f5ec38d4 100644 --- a/include/rfl/internal/Skip.hpp +++ b/include/rfl/internal/Skip.hpp @@ -66,6 +66,12 @@ class Skip { /// Returns the underlying object. const Type& get() const { return value_; } + /// Returns the underlying object. + Type& operator*() { return value_; } + + /// Returns the underlying object. + const Type& operator*() const { return value_; } + /// Returns the underlying object. Type& operator()() { return value_; } From b84277ed3ece44f27645bb0f5ac2da5e79aeb473 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 8 Feb 2026 01:58:00 +0000 Subject: [PATCH 2/2] Add operator* and noexcept non-const accessors to wrapper classes This commit adds `operator*` (const and non-const) to all reflect-cpp wrapper classes, including `DefaultVal`, `Field`, `Validator`, `Description`, `Rename`, `Attribute`, `Flatten`, `Hex`, `Oct`, `Binary`, `Generic`, `Timestamp`, and `internal::Skip`. Additionally, it ensures that these classes have non-const `.get()`, `.value()`, and `operator()()`, providing consistent access to the underlying value. All these accessors are now marked as `noexcept` where appropriate. Documentation has also been updated to reflect these changes. Co-authored-by: liuzicheng1987 <19538706+liuzicheng1987@users.noreply.github.com> --- include/rfl/Attribute.hpp | 16 ++++++++-------- include/rfl/Binary.hpp | 16 ++++++++-------- include/rfl/DefaultVal.hpp | 16 ++++++++-------- include/rfl/Description.hpp | 16 ++++++++-------- include/rfl/Field.hpp | 16 ++++++++-------- include/rfl/Flatten.hpp | 16 ++++++++-------- include/rfl/Generic.hpp | 16 ++++++++-------- include/rfl/Hex.hpp | 16 ++++++++-------- include/rfl/Oct.hpp | 16 ++++++++-------- include/rfl/Rename.hpp | 16 ++++++++-------- include/rfl/Timestamp.hpp | 16 ++++++++-------- include/rfl/Validator.hpp | 16 ++++++++-------- include/rfl/internal/Skip.hpp | 16 ++++++++-------- 13 files changed, 104 insertions(+), 104 deletions(-) diff --git a/include/rfl/Attribute.hpp b/include/rfl/Attribute.hpp index 94377c83..37d3b315 100644 --- a/include/rfl/Attribute.hpp +++ b/include/rfl/Attribute.hpp @@ -53,22 +53,22 @@ struct Attribute { ~Attribute() = default; /// Returns the underlying object. - const Type& get() const { return value_; } + const Type& get() const noexcept { return value_; } /// Returns the underlying object. - Type& get() { return value_; } + Type& get() noexcept { return value_; } /// Returns the underlying object. - Type& operator*() { return value_; } + Type& operator*() noexcept { return value_; } /// Returns the underlying object. - const Type& operator*() const { return value_; } + const Type& operator*() const noexcept { return value_; } /// Returns the underlying object. - Type& operator()() { return value_; } + Type& operator()() noexcept { return value_; } /// Returns the underlying object. - const Type& operator()() const { return value_; } + const Type& operator()() const noexcept { return value_; } /// Assigns the underlying object. auto& operator=(const Type& _value) { @@ -129,10 +129,10 @@ struct Attribute { void set(Type&& _value) { value_ = std::move(_value); } /// Returns the underlying object. - Type& value() { return value_; } + Type& value() noexcept { return value_; } /// Returns the underlying object. - const Type& value() const { return value_; } + const Type& value() const noexcept { return value_; } /// The underlying value. Type value_; diff --git a/include/rfl/Binary.hpp b/include/rfl/Binary.hpp index f06c6186..f44bc5d5 100644 --- a/include/rfl/Binary.hpp +++ b/include/rfl/Binary.hpp @@ -54,22 +54,22 @@ struct Binary { ~Binary() = default; /// Returns the underlying object. - const Type& get() const { return value_; } + const Type& get() const noexcept { return value_; } /// Returns the underlying object. - Type& get() { return value_; } + Type& get() noexcept { return value_; } /// Returns the underlying object. - Type& operator*() { return value_; } + Type& operator*() noexcept { return value_; } /// Returns the underlying object. - const Type& operator*() const { return value_; } + const Type& operator*() const noexcept { return value_; } /// Returns the underlying object. - Type& operator()() { return value_; } + Type& operator()() noexcept { return value_; } /// Returns the underlying object. - const Type& operator()() const { return value_; } + const Type& operator()() const noexcept { return value_; } /// Assigns the underlying object. auto& operator=(const Type& _value) { @@ -122,10 +122,10 @@ struct Binary { std::string str() const { return reflection(); } /// Returns the underlying object. - Type& value() { return value_; } + Type& value() noexcept { return value_; } /// Returns the underlying object. - const Type& value() const { return value_; } + const Type& value() const noexcept { return value_; } /// The underlying value. Type value_; diff --git a/include/rfl/DefaultVal.hpp b/include/rfl/DefaultVal.hpp index 73a8732e..ca700851 100644 --- a/include/rfl/DefaultVal.hpp +++ b/include/rfl/DefaultVal.hpp @@ -51,22 +51,22 @@ struct DefaultVal { ~DefaultVal() = default; /// Returns the underlying object. - const Type& get() const { return value_; } + const Type& get() const noexcept { return value_; } /// Returns the underlying object. - Type& get() { return value_; } + Type& get() noexcept { return value_; } /// Returns the underlying object. - Type& operator*() { return value_; } + Type& operator*() noexcept { return value_; } /// Returns the underlying object. - const Type& operator*() const { return value_; } + const Type& operator*() const noexcept { return value_; } /// Returns the underlying object. - Type& operator()() { return value_; } + Type& operator()() noexcept { return value_; } /// Returns the underlying object. - const Type& operator()() const { return value_; } + const Type& operator()() const noexcept { return value_; } /// Assigns the underlying object. auto& operator=(const Type& _value) { @@ -123,10 +123,10 @@ struct DefaultVal { void set(Type&& _value) { value_ = std::move(_value); } /// Returns the underlying object. - Type& value() { return value_; } + Type& value() noexcept { return value_; } /// Returns the underlying object. - const Type& value() const { return value_; } + const Type& value() const noexcept { return value_; } /// The underlying value. Type value_; diff --git a/include/rfl/Description.hpp b/include/rfl/Description.hpp index 3f8d9fbd..1bdcbbc6 100644 --- a/include/rfl/Description.hpp +++ b/include/rfl/Description.hpp @@ -66,22 +66,22 @@ struct Description { constexpr static const internal::StringLiteral description_ = _description; /// Returns the underlying object. - const Type& get() const { return value_; } + const Type& get() const noexcept { return value_; } /// Returns the underlying object. - Type& get() { return value_; } + Type& get() noexcept { return value_; } /// Returns the underlying object. - Type& operator*() { return value_; } + Type& operator*() noexcept { return value_; } /// Returns the underlying object. - const Type& operator*() const { return value_; } + const Type& operator*() const noexcept { return value_; } /// Returns the underlying object. - Type& operator()() { return value_; } + Type& operator()() noexcept { return value_; } /// Returns the underlying object. - const Type& operator()() const { return value_; } + const Type& operator()() const noexcept { return value_; } /// Assigns the underlying object. auto& operator=(const Type& _value) { @@ -141,10 +141,10 @@ struct Description { void set(Type&& _value) { value_ = std::move(_value); } /// Returns the underlying object. - Type& value() { return value_; } + Type& value() noexcept { return value_; } /// Returns the underlying object. - const Type& value() const { return value_; } + const Type& value() const noexcept { return value_; } /// The underlying value. Type value_; diff --git a/include/rfl/Field.hpp b/include/rfl/Field.hpp index c6281a22..9175fd1f 100644 --- a/include/rfl/Field.hpp +++ b/include/rfl/Field.hpp @@ -59,25 +59,25 @@ struct Field { constexpr static const internal::StringLiteral name_ = _name; /// Returns the underlying object. - const Type& get() const { return value_; } + const Type& get() const noexcept { return value_; } /// Returns the underlying object. - Type& get() { return value_; } + Type& get() noexcept { return value_; } /// Returns the underlying object. - Type& operator*() { return value_; } + Type& operator*() noexcept { return value_; } /// Returns the underlying object. - const Type& operator*() const { return value_; } + const Type& operator*() const noexcept { return value_; } /// The name of the field. constexpr static std::string_view name() { return name_.string_view(); } /// Returns the underlying object. - Type& operator()() { return value_; } + Type& operator()() noexcept { return value_; } /// Returns the underlying object. - const Type& operator()() const { return value_; } + const Type& operator()() const noexcept { return value_; } /// Assigns the underlying object. auto& operator=(const Type& _value) { @@ -134,10 +134,10 @@ struct Field { void set(Type&& _value) { value_ = std::move(_value); } /// Returns the underlying object. - Type& value() { return value_; } + Type& value() noexcept { return value_; } /// Returns the underlying object. - const Type& value() const { return value_; } + const Type& value() const noexcept { return value_; } /// The underlying value. Type value_; diff --git a/include/rfl/Flatten.hpp b/include/rfl/Flatten.hpp index aa96d0b6..90bec71b 100644 --- a/include/rfl/Flatten.hpp +++ b/include/rfl/Flatten.hpp @@ -42,28 +42,28 @@ struct Flatten { ~Flatten() = default; /// Returns the underlying object. - Type& get() { return value_; } + Type& get() noexcept { return value_; } /// Returns the underlying object. - const Type& get() const { return value_; } + const Type& get() const noexcept { return value_; } /// Returns the underlying object. - Type& operator*() { return value_; } + Type& operator*() noexcept { return value_; } /// Returns the underlying object. - const Type& operator*() const { return value_; } + const Type& operator*() const noexcept { return value_; } /// Returns the underlying object. - Type& operator()() { return value_; } + Type& operator()() noexcept { return value_; } /// Returns the underlying object. - const Type& operator()() const { return value_; } + const Type& operator()() const noexcept { return value_; } /// Returns the underlying object. - Type& value() { return value_; } + Type& value() noexcept { return value_; } /// Returns the underlying object. - const Type& value() const { return value_; } + const Type& value() const noexcept { return value_; } /// Assigns the underlying object. Flatten& operator=(const T& _value) { diff --git a/include/rfl/Generic.hpp b/include/rfl/Generic.hpp index 8494d143..ad652deb 100644 --- a/include/rfl/Generic.hpp +++ b/include/rfl/Generic.hpp @@ -51,28 +51,28 @@ class RFL_API Generic { ~Generic(); /// Returns the underlying object. - const VariantType& get() const { return value_; } + const VariantType& get() const noexcept { return value_; } /// Returns the underlying object. - VariantType& get() { return value_; } + VariantType& get() noexcept { return value_; } /// Returns the underlying object. - VariantType& operator*() { return value_; } + VariantType& operator*() noexcept { return value_; } /// Returns the underlying object. - const VariantType& operator*() const { return value_; } + const VariantType& operator*() const noexcept { return value_; } /// Returns the underlying object. - VariantType& operator()() { return value_; } + VariantType& operator()() noexcept { return value_; } /// Returns the underlying object. - const VariantType& operator()() const { return value_; } + const VariantType& operator()() const noexcept { return value_; } /// Returns the underlying object. - VariantType& value() { return value_; } + VariantType& value() noexcept { return value_; } /// Returns the underlying object. - const VariantType& value() const { return value_; } + const VariantType& value() const noexcept { return value_; } /// Whether the object contains the null value. bool is_null() const noexcept; diff --git a/include/rfl/Hex.hpp b/include/rfl/Hex.hpp index d410fbcd..fb8a48fe 100644 --- a/include/rfl/Hex.hpp +++ b/include/rfl/Hex.hpp @@ -52,22 +52,22 @@ struct Hex { ~Hex() = default; /// Returns the underlying object. - const Type& get() const { return value_; } + const Type& get() const noexcept { return value_; } /// Returns the underlying object. - Type& get() { return value_; } + Type& get() noexcept { return value_; } /// Returns the underlying object. - Type& operator*() { return value_; } + Type& operator*() noexcept { return value_; } /// Returns the underlying object. - const Type& operator*() const { return value_; } + const Type& operator*() const noexcept { return value_; } /// Returns the underlying object. - Type& operator()() { return value_; } + Type& operator()() noexcept { return value_; } /// Returns the underlying object. - const Type& operator()() const { return value_; } + const Type& operator()() const noexcept { return value_; } /// Assigns the underlying object. auto& operator=(const Type& _value) { @@ -124,10 +124,10 @@ struct Hex { std::string str() const { return reflection(); } /// Returns the underlying object. - Type& value() { return value_; } + Type& value() noexcept { return value_; } /// Returns the underlying object. - const Type& value() const { return value_; } + const Type& value() const noexcept { return value_; } /// The underlying value. Type value_; diff --git a/include/rfl/Oct.hpp b/include/rfl/Oct.hpp index 8fe799a2..20e0c330 100644 --- a/include/rfl/Oct.hpp +++ b/include/rfl/Oct.hpp @@ -53,22 +53,22 @@ struct Oct { ~Oct() = default; /// Returns the underlying object. - const Type& get() const { return value_; } + const Type& get() const noexcept { return value_; } /// Returns the underlying object. - Type& get() { return value_; } + Type& get() noexcept { return value_; } /// Returns the underlying object. - Type& operator*() { return value_; } + Type& operator*() noexcept { return value_; } /// Returns the underlying object. - const Type& operator*() const { return value_; } + const Type& operator*() const noexcept { return value_; } /// Returns the underlying object. - Type& operator()() { return value_; } + Type& operator()() noexcept { return value_; } /// Returns the underlying object. - const Type& operator()() const { return value_; } + const Type& operator()() const noexcept { return value_; } /// Assigns the underlying object. auto& operator=(const Type& _value) { @@ -125,10 +125,10 @@ struct Oct { std::string str() const { return reflection(); } /// Returns the underlying object. - Type& value() { return value_; } + Type& value() noexcept { return value_; } /// Returns the underlying object. - const Type& value() const { return value_; } + const Type& value() const noexcept { return value_; } /// The underlying value. Type value_; diff --git a/include/rfl/Rename.hpp b/include/rfl/Rename.hpp index 7e49103b..c3bd79d9 100644 --- a/include/rfl/Rename.hpp +++ b/include/rfl/Rename.hpp @@ -62,22 +62,22 @@ struct Rename { constexpr static const internal::StringLiteral name_ = _name; /// Returns the underlying object. - const Type& get() const { return value_; } + const Type& get() const noexcept { return value_; } /// Returns the underlying object. - Type& get() { return value_; } + Type& get() noexcept { return value_; } /// Returns the underlying object. - Type& operator*() { return value_; } + Type& operator*() noexcept { return value_; } /// Returns the underlying object. - const Type& operator*() const { return value_; } + const Type& operator*() const noexcept { return value_; } /// Returns the underlying object. - Type& operator()() { return value_; } + Type& operator()() noexcept { return value_; } /// Returns the underlying object. - const Type& operator()() const { return value_; } + const Type& operator()() const noexcept { return value_; } /// Assigns the underlying object. auto& operator=(const Type& _value) { @@ -134,10 +134,10 @@ struct Rename { void set(Type&& _value) { value_ = std::move(_value); } /// Returns the underlying object. - Type& value() { return value_; } + Type& value() noexcept { return value_; } /// Returns the underlying object. - const Type& value() const { return value_; } + const Type& value() const noexcept { return value_; } /// The underlying value. Type value_; diff --git a/include/rfl/Timestamp.hpp b/include/rfl/Timestamp.hpp index e8efb397..fe78e85f 100644 --- a/include/rfl/Timestamp.hpp +++ b/include/rfl/Timestamp.hpp @@ -72,28 +72,28 @@ class Timestamp { } /// Returns the underlying object. - const std::tm& get() const { return tm_; } + const std::tm& get() const noexcept { return tm_; } /// Returns the underlying object. - std::tm& get() { return tm_; } + std::tm& get() noexcept { return tm_; } /// Returns the underlying object. - std::tm& operator*() { return tm_; } + std::tm& operator*() noexcept { return tm_; } /// Returns the underlying object. - const std::tm& operator*() const { return tm_; } + const std::tm& operator*() const noexcept { return tm_; } /// Returns the underlying object. - std::tm& operator()() { return tm_; } + std::tm& operator()() noexcept { return tm_; } /// Returns the underlying object. - const std::tm& operator()() const { return tm_; } + const std::tm& operator()() const noexcept { return tm_; } /// Returns the underlying object. - std::tm& value() { return tm_; } + std::tm& value() noexcept { return tm_; } /// Returns the underlying object. - const std::tm& value() const { return tm_; } + const std::tm& value() const noexcept { return tm_; } /// Necessary for the serialization to work. ReflectionType reflection() const { diff --git a/include/rfl/Validator.hpp b/include/rfl/Validator.hpp index 98a59fe3..ffb5d08e 100644 --- a/include/rfl/Validator.hpp +++ b/include/rfl/Validator.hpp @@ -93,28 +93,28 @@ struct Validator { } /// Returns the underlying object. - const T& get() const { return value_; } + const T& get() const noexcept { return value_; } /// Returns the underlying object. - T& get() { return value_; } + T& get() noexcept { return value_; } /// Returns the underlying object. - T& operator*() { return value_; } + T& operator*() noexcept { return value_; } /// Returns the underlying object. - const T& operator*() const { return value_; } + const T& operator*() const noexcept { return value_; } /// Returns the underlying object. - T& operator()() { return value_; } + T& operator()() noexcept { return value_; } /// Returns the underlying object. - const T& operator()() const { return value_; } + const T& operator()() const noexcept { return value_; } /// Exposes the underlying value. - T& value() { return value_; } + T& value() noexcept { return value_; } /// Exposes the underlying value. - const T& value() const { return value_; } + const T& value() const noexcept { return value_; } /// Necessary for the serialization to work. const T& reflection() const { return value_; } diff --git a/include/rfl/internal/Skip.hpp b/include/rfl/internal/Skip.hpp index f5ec38d4..30cee133 100644 --- a/include/rfl/internal/Skip.hpp +++ b/include/rfl/internal/Skip.hpp @@ -61,22 +61,22 @@ class Skip { ~Skip() = default; /// Returns the underlying object. - Type& get() { return value_; } + Type& get() noexcept { return value_; } /// Returns the underlying object. - const Type& get() const { return value_; } + const Type& get() const noexcept { return value_; } /// Returns the underlying object. - Type& operator*() { return value_; } + Type& operator*() noexcept { return value_; } /// Returns the underlying object. - const Type& operator*() const { return value_; } + const Type& operator*() const noexcept { return value_; } /// Returns the underlying object. - Type& operator()() { return value_; } + Type& operator()() noexcept { return value_; } /// Returns the underlying object. - const Type& operator()() const { return value_; } + const Type& operator()() const noexcept { return value_; } /// Assigns the underlying object. auto& operator=(const Type& _value) { @@ -136,10 +136,10 @@ class Skip { void set(Type&& _value) { value_ = std::move(_value); } /// Returns the underlying object. - Type& value() { return value_; } + Type& value() noexcept { return value_; } /// Returns the underlying object. - const Type& value() const { return value_; } + const Type& value() const noexcept { return value_; } private: /// The underlying value