From 7619b0c33918fe2d432a4ca4ee1ebe4571799dd5 Mon Sep 17 00:00:00 2001 From: sha512sum Date: Tue, 27 Aug 2024 19:15:55 +0000 Subject: [PATCH] Add comments for every method in field set helpers --- src/lib/utils.cpp | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/src/lib/utils.cpp b/src/lib/utils.cpp index 2681150..51d6933 100644 --- a/src/lib/utils.cpp +++ b/src/lib/utils.cpp @@ -25,10 +25,16 @@ constexpr auto GetType(R(T::* ptr)) -> R; // return kUtils.With(&SomeStruct::field2, std::forward(self), std::move(field2)); // With field2 // } // }; -template +export template struct FieldsDescription { - utempl::Tuple tuple; - + utempl::Tuple tuple; /*!< tuple for field ptrs */ + /* Method accepting field index, self and new value for field and returns object with new field value + * + * \param I field index for object T + * \param self old object + * \param value new value for field + * \return T with new field value and values from self + */ template constexpr auto With(Self&& self, Value&& value) const requires([] { @@ -50,6 +56,13 @@ struct FieldsDescription { } | utempl::kSeq; }; + /* Method accepting field pointer, self and new value for field and returns object with new field value + * + * \param ptr field ptr for object T + * \param self old object + * \param value new value for field + * \return T with new field value and values from self + */ template constexpr auto With(Type(T::* ptr), Self&& self, Value&& value) const requires std::is_constructible_v @@ -72,10 +85,15 @@ consteval auto CreateFieldsDescriptionHelper(Fs&&... fs) -> FieldsDescription(fs)...}}; }; +/* Method accepting field ptrs and returns FieldsDescription + * + * \param ptrs field ptrs + * \return FieldsDescription with T and ptrs + */ export template -consteval auto CreateFieldsDescription(Rs(T::*... ptr)) { +consteval auto CreateFieldsDescription(Rs(T::*... ptrs)) { return [&](auto... is) { - return CreateFieldsDescriptionHelper(ptr...); + return CreateFieldsDescriptionHelper(ptrs...); } | utempl::kSeq; }; @@ -96,6 +114,13 @@ consteval auto CreateFieldsDescription(Rs(T::*... ptr)) { // }; export struct FieldSetHelper { + /* Method accepting field index, self and new value for field and returns object with new field value + * + * \param I field index for object T + * \param self old object + * \param value new value for field + * \return T with new field value and values from self + */ template static constexpr auto With(Self&& self, Value&& value) requires([] { @@ -117,6 +142,13 @@ export struct FieldSetHelper { } | utempl::kSeq>; }; + /* Method accepting field name, self and new value for field and returns object with new field value + * + * \param FieldName field name for object T + * \param self old object + * \param value new value for field + * \return T with new field value and values from self + */ template static constexpr auto With(Self&& self, Value&& value) -> decltype(With<[] { auto names = boost::pfr::names_as_array>();