-
Notifications
You must be signed in to change notification settings - Fork 179
Added DOxygen-style doctrings to most functions and methods #663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
90d5621
Began adding documentation
liuzicheng1987 60b7e3e
More documentation
liuzicheng1987 d9c5e8b
Added docstrings to the parsing directory
liuzicheng1987 3351515
Added more comments
liuzicheng1987 08fdf6f
Minor bugfixes
liuzicheng1987 762296d
Update include/rfl/Deprecated.hpp
liuzicheng1987 631e33e
Update include/rfl/DefaultVal.hpp
liuzicheng1987 024a7a4
Update include/rfl/Hex.hpp
liuzicheng1987 fd8cf5e
Update include/rfl/Attribute.hpp
liuzicheng1987 20a21d7
Update include/rfl/Binary.hpp
liuzicheng1987 12b6ae8
Update include/rfl/Positional.hpp
liuzicheng1987 aa3d8ba
Update include/rfl/Rename.hpp
liuzicheng1987 46c7d03
More comments + minor fixes
liuzicheng1987 9afab21
Merge branch 'f/docstrings' of github.com:getml/reflect-cpp into f/do…
liuzicheng1987 a0446ee
Merge branch 'main' into f/docstrings
liuzicheng1987 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12,126 +12,190 @@ | |||||
|
|
||||||
| namespace rfl { | ||||||
|
|
||||||
| /// Wraps a field value to mark it as an XML attribute. | ||||||
| /// In XML serialization, fields wrapped in Attribute will be rendered as attributes | ||||||
| /// on the XML element rather than child elements. For non-XML formats, this wrapper | ||||||
| /// is transparent and behaves like a normal field. | ||||||
| /// Example: <element attr="value"> instead of <element><field>value</field></element> | ||||||
| /// @tparam T The type of the attribute value | ||||||
| template <class T> | ||||||
| struct Attribute { | ||||||
| using Type = T; | ||||||
| using ReflectionType = T; | ||||||
|
|
||||||
| /// Default constructor. | ||||||
| Attribute() : value_(Type()) {} | ||||||
|
|
||||||
| /// Constructs from a const reference to the value. | ||||||
| /// @param _value The value to store | ||||||
| Attribute(const Type& _value) : value_(_value) {} | ||||||
|
|
||||||
| /// Constructs from an rvalue reference to the value. | ||||||
| /// @param _value The value to store (will be moved) | ||||||
| Attribute(Type&& _value) noexcept : value_(std::move(_value)) {} | ||||||
|
|
||||||
| /// Move constructor. | ||||||
| /// @param _attr The Attribute to move from | ||||||
| Attribute(Attribute<T>&& _attr) noexcept = default; | ||||||
|
|
||||||
| /// Copy constructor. | ||||||
| /// @param _attr The Attribute to copy from | ||||||
| Attribute(const Attribute<Type>& _attr) = default; | ||||||
|
|
||||||
| /// Copy constructor from Attribute with compatible type. | ||||||
| /// @tparam U Type compatible with T | ||||||
| /// @param _attr The Attribute to copy the value from | ||||||
| template <class U> | ||||||
| Attribute(const Attribute<U>& _attr) : value_(_attr.get()) {} | ||||||
|
|
||||||
| /// Move constructor from Attribute with compatible type. | ||||||
| /// @tparam U Type compatible with T | ||||||
| /// @param _attr The Attribute to move the value from | ||||||
| template <class U> | ||||||
| Attribute(Attribute<U>&& _attr) : value_(_attr.get()) {} | ||||||
|
|
||||||
| /// Constructs from any type convertible to Type (copy). | ||||||
| /// @tparam U Type convertible to T | ||||||
| /// @param _value The value to convert and store | ||||||
| template <class U> | ||||||
| requires std::is_convertible_v<U, Type> | ||||||
| Attribute(const U& _value) : value_(_value) {} | ||||||
|
|
||||||
| /// Constructs from any type convertible to Type (move). | ||||||
| /// @tparam U Type convertible to T | ||||||
| /// @param _value The value to convert and store (will be moved) | ||||||
| template <class U> | ||||||
| requires std::is_convertible_v<U, Type> | ||||||
| Attribute(U&& _value) noexcept : value_(std::forward<U>(_value)) {} | ||||||
|
|
||||||
| /// Constructs from an Attribute with compatible type. | ||||||
| /// @tparam U Type convertible to T | ||||||
| /// @param _attr The Attribute to copy the value from | ||||||
| template <class U> | ||||||
| requires std::is_convertible_v<U, Type> | ||||||
| Attribute(const Attribute<U>& _attr) : value_(_attr.value()) {} | ||||||
|
|
||||||
| /// Assigns the underlying object to its default value. | ||||||
| /// Assigns the underlying object to its default value using the Default sentinel. | ||||||
| /// @tparam U The type (must be default constructible) | ||||||
| /// @param The default sentinel value | ||||||
| template <class U = Type> | ||||||
| requires std::is_default_constructible_v<U> | ||||||
| Attribute(const Default&) : value_(Type()) {} | ||||||
|
|
||||||
| /// Destructor. | ||||||
| ~Attribute() = default; | ||||||
|
|
||||||
| /// Returns the underlying object. | ||||||
| /// Returns the underlying value. | ||||||
| /// @return Const reference to the stored value | ||||||
| const Type& get() const noexcept { return value_; } | ||||||
|
|
||||||
| /// Returns the underlying object. | ||||||
| /// Returns the underlying value. | ||||||
| /// @return Reference to the stored value | ||||||
| Type& get() noexcept { return value_; } | ||||||
|
|
||||||
| /// Returns the underlying object. | ||||||
| /// Dereference operator - returns the underlying value. | ||||||
| /// @return Reference to the stored value | ||||||
| Type& operator*() noexcept { return value_; } | ||||||
|
|
||||||
| /// Returns the underlying object. | ||||||
| /// Dereference operator (const) - returns the underlying value. | ||||||
| /// @return Const reference to the stored value | ||||||
| const Type& operator*() const noexcept { return value_; } | ||||||
|
|
||||||
| /// Returns the underlying object. | ||||||
| /// Function call operator - returns the underlying value. | ||||||
| /// @return Reference to the stored value | ||||||
| Type& operator()() noexcept { return value_; } | ||||||
|
|
||||||
| /// Returns the underlying object. | ||||||
| /// Function call operator (const) - returns the underlying value. | ||||||
| /// @return Const reference to the stored value | ||||||
| const Type& operator()() const noexcept { return value_; } | ||||||
|
|
||||||
| /// Assigns the underlying object. | ||||||
| /// Assigns a new value. | ||||||
| /// @param _value The value to assign | ||||||
| /// @return Reference to this Attribute | ||||||
| auto& operator=(const Type& _value) { | ||||||
| value_ = _value; | ||||||
| return *this; | ||||||
| } | ||||||
|
|
||||||
| /// Assigns the underlying object. | ||||||
| /// Assigns a new value (move version). | ||||||
| /// @param _value The value to assign (will be moved) | ||||||
| /// @return Reference to this Attribute | ||||||
| auto& operator=(Type&& _value) noexcept { | ||||||
| value_ = std::move(_value); | ||||||
| return *this; | ||||||
| } | ||||||
|
|
||||||
| /// Assigns the underlying object. | ||||||
| /// Assigns from any type convertible to the underlying type. | ||||||
| /// @tparam U Type convertible to T | ||||||
| /// @param _value The value to convert and assign | ||||||
| /// @return Reference to this Attribute | ||||||
| template <class U> | ||||||
| requires std::is_convertible_v<U, Type> | ||||||
| auto& operator=(const U& _value) { | ||||||
| value_ = _value; | ||||||
| return *this; | ||||||
| } | ||||||
|
|
||||||
| /// Assigns the underlying object to its default value. | ||||||
| /// Assigns the value to its default using the Default sentinel. | ||||||
| /// @tparam U The type (must be default constructible) | ||||||
| /// @param The default sentinel value | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For unnamed parameters in Doxygen, it's a good practice to provide a placeholder name (like
Suggested change
|
||||||
| /// @return Reference to this Attribute | ||||||
| template <class U = Type> | ||||||
| requires std::is_default_constructible_v<U> | ||||||
| auto& operator=(const Default&) { | ||||||
| value_ = Type(); | ||||||
| return *this; | ||||||
| } | ||||||
|
|
||||||
| /// Assigns the underlying object. | ||||||
| /// Copy assignment operator. | ||||||
| /// @param _attr The Attribute to copy from | ||||||
| /// @return Reference to this Attribute | ||||||
| Attribute<T>& operator=(const Attribute<T>& _attr) = default; | ||||||
|
|
||||||
| /// Assigns the underlying object. | ||||||
| /// Move assignment operator. | ||||||
| /// @param _attr The Attribute to move from | ||||||
| /// @return Reference to this Attribute | ||||||
| Attribute<T>& operator=(Attribute<T>&& _attr) = default; | ||||||
|
|
||||||
| /// Assigns the underlying object. | ||||||
| /// Assigns from another Attribute with compatible type (copy). | ||||||
| /// @tparam U Type compatible with T | ||||||
| /// @param _attr The Attribute to copy the value from | ||||||
| /// @return Reference to this Attribute | ||||||
| template <class U> | ||||||
| auto& operator=(const Attribute<U>& _attr) { | ||||||
| value_ = _attr.get(); | ||||||
| return *this; | ||||||
| } | ||||||
|
|
||||||
| /// Assigns the underlying object. | ||||||
| /// Assigns from another Attribute with compatible type (move). | ||||||
| /// @tparam U Type compatible with T | ||||||
| /// @param _attr The Attribute to move the value from | ||||||
| /// @return Reference to this Attribute | ||||||
| template <class U> | ||||||
| auto& operator=(Attribute<U>&& _attr) { | ||||||
| value_ = std::forward<T>(_attr.value_); | ||||||
| value_ = std::move(_attr.value_); | ||||||
| return *this; | ||||||
| } | ||||||
|
|
||||||
| /// We want all parsers other than the XML parser to treat attributes like | ||||||
| /// normal fields, so we just implement the reflection interface. | ||||||
| /// Returns the underlying value for reflection (used by parsers). | ||||||
| /// Non-XML parsers treat attributes like normal fields. | ||||||
| /// @return Const reference to the stored value | ||||||
| const ReflectionType& reflection() const { return value_; } | ||||||
|
|
||||||
| /// Assigns the underlying object. | ||||||
| /// Sets the value (copy version). | ||||||
| /// @param _value The value to set | ||||||
| void set(const Type& _value) { value_ = _value; } | ||||||
|
|
||||||
| /// Assigns the underlying object. | ||||||
| /// Sets the value (move version). | ||||||
| /// @param _value The value to set (will be moved) | ||||||
| void set(Type&& _value) { value_ = std::move(_value); } | ||||||
|
|
||||||
| /// Returns the underlying object. | ||||||
| /// Returns the underlying value. | ||||||
| /// @return Reference to the stored value | ||||||
| Type& value() noexcept { return value_; } | ||||||
|
|
||||||
| /// Returns the underlying object. | ||||||
| /// Returns the underlying value (const). | ||||||
| /// @return Const reference to the stored value | ||||||
| const Type& value() const noexcept { return value_; } | ||||||
|
|
||||||
| /// The underlying value. | ||||||
|
|
||||||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For unnamed parameters in Doxygen, it's a good practice to provide a placeholder name (like
_orunused) for clarity in the generated documentation. This makes it clear that the parameter is intentionally unnamed.