Add operator* and non-const accessors to wrapper classes#603
Add operator* and non-const accessors to wrapper classes#603liuzicheng1987 merged 2 commits intomainfrom
Conversation
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>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Summary of ChangesHello @liuzicheng1987, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces operator* and non-const .get() accessors to various wrapper classes for improved API convenience and consistency, along with corresponding documentation updates. The changes are generally well-implemented. I've identified a minor formatting issue in one of the documentation files and a few opportunities for code simplification and consistency in the C++ headers by using noexcept and const where appropriate.
include/rfl/Flatten.hpp
Outdated
| /// Returns the underlying object. | ||
| Type& operator*() { return value_; } |
There was a problem hiding this comment.
For consistency with other accessor methods and to provide stronger compile-time guarantees, it's good practice to mark methods that do not throw exceptions as noexcept.
| /// Returns the underlying object. | |
| Type& operator*() { return value_; } | |
| Type& operator*() noexcept { return value_; } |
include/rfl/Flatten.hpp
Outdated
| /// Returns the underlying object. | ||
| const Type& operator*() const { return value_; } |
There was a problem hiding this comment.
For consistency with other accessor methods and to provide stronger compile-time guarantees, it's good practice to mark methods that do not throw exceptions as noexcept.
| /// Returns the underlying object. | |
| const Type& operator*() const { return value_; } | |
| const Type& operator*() const noexcept { return value_; } |
include/rfl/Flatten.hpp
Outdated
| /// Returns the underlying object. | ||
| Type& value() { return value_; } |
There was a problem hiding this comment.
include/rfl/Flatten.hpp
Outdated
| /// Returns the underlying object. | ||
| const Type& value() const { return value_; } |
There was a problem hiding this comment.
For consistency with other accessor methods and to provide stronger compile-time guarantees, it's good practice to mark methods that do not throw exceptions as noexcept.
| /// Returns the underlying object. | |
| const Type& value() const { return value_; } | |
| const Type& value() const noexcept { return value_; } |
include/rfl/Generic.hpp
Outdated
| /// Returns the underlying object. | ||
| VariantType& get() { return value_; } |
include/rfl/Timestamp.hpp
Outdated
| /// Returns the underlying object. | ||
| const std::tm& operator*() const { return tm_; } |
There was a problem hiding this comment.
For consistency with other accessor methods and to provide stronger compile-time guarantees, it's good practice to mark methods that do not throw exceptions as noexcept.
| /// Returns the underlying object. | |
| const std::tm& operator*() const { return tm_; } | |
| const std::tm& operator*() const noexcept { return tm_; } |
include/rfl/Timestamp.hpp
Outdated
| /// Returns the underlying object. | ||
| std::tm& operator()() { return tm_; } |
There was a problem hiding this comment.
For consistency with other accessor methods and to provide stronger compile-time guarantees, it's good practice to mark methods that do not throw exceptions as noexcept.
| /// Returns the underlying object. | |
| std::tm& operator()() { return tm_; } | |
| std::tm& operator()() noexcept { return tm_; } |
include/rfl/Timestamp.hpp
Outdated
| /// Returns the underlying object. | ||
| const std::tm& operator()() const { return tm_; } |
There was a problem hiding this comment.
For consistency with other accessor methods and to provide stronger compile-time guarantees, it's good practice to mark methods that do not throw exceptions as noexcept.
| /// Returns the underlying object. | |
| const std::tm& operator()() const { return tm_; } | |
| const std::tm& operator()() const noexcept { return tm_; } |
include/rfl/Timestamp.hpp
Outdated
| /// Returns the underlying object. | ||
| std::tm& value() { return tm_; } |
There was a problem hiding this comment.
include/rfl/Timestamp.hpp
Outdated
| /// Returns the underlying object. | ||
| const std::tm& value() const { return tm_; } |
There was a problem hiding this comment.
For consistency with other accessor methods and to provide stronger compile-time guarantees, it's good practice to mark methods that do not throw exceptions as noexcept.
| /// Returns the underlying object. | |
| const std::tm& value() const { return tm_; } | |
| const std::tm& value() const noexcept { return tm_; } |
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>
Added
operator*and non-const.get()to reflect-cpp wrapper classes for better API convenience and consistency. Updated documentation accordingly.PR created automatically by Jules for task 9490559753035774407 started by @liuzicheng1987