 |
TrinityCore
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
18#ifndef TRINITYCORE_QUERY_RESULT_STRUCTURED_H
19#define TRINITYCORE_QUERY_RESULT_STRUCTURED_H
21#include <boost/preprocessor/cat.hpp>
22#include <boost/preprocessor/comma_if.hpp>
23#include <boost/preprocessor/facilities/empty.hpp>
24#include <boost/preprocessor/seq/enum.hpp>
25#include <boost/preprocessor/seq/for_each.hpp>
26#include <boost/preprocessor/seq/for_each_i.hpp>
27#include <boost/preprocessor/stringize.hpp>
29#define DEFINE_FIELD_ACCESSOR_CACHE_FIELD_INDEX_INIT(r, data, i, field) BOOST_PP_COMMA_IF(i) field(result.GetFieldMetadata(BOOST_PP_STRINGIZE(field)).Index)
31#define DEFINE_FIELD_ACCESSOR_CACHE_FIELD(r, data, field) Field const& field() const\
33 return Fields[indexes.field];\
36#define DEFINE_FIELD_ACCESSOR_CACHE(namespace_name, struct_name, result_type, fields_list) \
37 struct namespace_name struct_name \
41 Indexes(result_type const& result) :\
42 BOOST_PP_SEQ_FOR_EACH_I(DEFINE_FIELD_ACCESSOR_CACHE_FIELD_INDEX_INIT, ~, fields_list) { }\
43 std::size_t BOOST_PP_SEQ_ENUM(fields_list);\
45 BOOST_PP_SEQ_FOR_EACH(DEFINE_FIELD_ACCESSOR_CACHE_FIELD, ~, fields_list) \
46 struct_name(result_type const& result) : Fields(result.Fetch()), indexes(indexes_impl(result)) { }\
48 static Indexes const& indexes_impl(result_type const& result) noexcept { static Indexes const instance(result); return instance; }\
49 Indexes const& indexes;\
52#define DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(result_type, fields_list) DEFINE_FIELD_ACCESSOR_CACHE(BOOST_PP_EMPTY(), BOOST_PP_CAT(FieldAccessors, __LINE__), result_type, fields_list)