50 lines
940 B
C++
50 lines
940 B
C++
#pragma once
|
|
|
|
#include <sp/common/DataBuffer.h>
|
|
#include <sp/common/Templates.h>
|
|
|
|
namespace sp {
|
|
|
|
template <typename ValueType>
|
|
class Field {
|
|
public:
|
|
// Provide an access to the stored value
|
|
ValueType& GetValue() {
|
|
return m_Value;
|
|
}
|
|
const ValueType& GetValue() const {
|
|
return m_Value;
|
|
}
|
|
|
|
Field& operator=(const ValueType& value) {
|
|
m_Value = value;
|
|
return *this;
|
|
}
|
|
|
|
private:
|
|
ValueType m_Value;
|
|
};
|
|
|
|
namespace details {
|
|
|
|
template <typename... TFields>
|
|
struct FieldsBuilder {};
|
|
|
|
template <>
|
|
struct FieldsBuilder<> {
|
|
using Type = std::tuple<>;
|
|
};
|
|
|
|
template <typename... TFields>
|
|
struct FieldsBuilder<std::tuple<TFields...>> {
|
|
using Type = typename FieldsBuilder<TFields...>::Type;
|
|
};
|
|
|
|
template <typename TField, typename... TFields>
|
|
struct FieldsBuilder<TField, TFields...> {
|
|
using Type = sp::tuple_cat_t<std::tuple<Field<TField>>, typename FieldsBuilder<TFields...>::Type>;
|
|
};
|
|
} // namespace details
|
|
|
|
} // namespace sp
|