2024-05-31 22:59:00 -04:00
|
|
|
#ifndef RFL_ADDSTRUCTNAME_HPP_
|
|
|
|
#define RFL_ADDSTRUCTNAME_HPP_
|
|
|
|
|
|
|
|
#include <tuple>
|
|
|
|
|
|
|
|
#include "Field.hpp"
|
|
|
|
#include "Literal.hpp"
|
|
|
|
#include "internal/StringLiteral.hpp"
|
|
|
|
#include "internal/get_type_name.hpp"
|
|
|
|
#include "internal/remove_namespaces.hpp"
|
|
|
|
#include "make_named_tuple.hpp"
|
|
|
|
|
|
|
|
namespace rfl {
|
|
|
|
|
2024-06-08 14:10:59 -04:00
|
|
|
template <internal::StringLiteral field_name_>
|
|
|
|
struct AddStructName {
|
|
|
|
/// Adds the name of the struct as a new field.
|
|
|
|
template <class StructType>
|
|
|
|
static auto process(auto&& _view) {
|
2024-06-16 00:13:15 -04:00
|
|
|
using LiteralType =
|
|
|
|
Literal<internal::remove_namespaces<internal::get_type_name<StructType>()>()>;
|
2024-06-08 14:10:59 -04:00
|
|
|
using FieldType = Field<field_name_, LiteralType>;
|
|
|
|
const auto add_new_field = [](auto&&... _fields) {
|
2024-06-16 00:13:15 -04:00
|
|
|
return make_named_tuple(FieldType(LiteralType()), std::move(_fields)...);
|
2024-06-08 14:10:59 -04:00
|
|
|
};
|
|
|
|
return std::apply(add_new_field, std::move(_view.fields()));
|
|
|
|
}
|
|
|
|
};
|
2024-05-31 22:59:00 -04:00
|
|
|
|
2024-06-08 14:10:59 -04:00
|
|
|
} // namespace rfl
|
2024-05-31 22:59:00 -04:00
|
|
|
|
|
|
|
#endif
|