1 #ifndef TOC_STRINGTABLE_H_INCLUDED 2 #define TOC_STRINGTABLE_H_INCLUDED 45 :
public CTableEntry<IntToType<Id::value - 1> >
50 struct CTableEntry<IntToType<-1> >
53 static constexpr
int getOffset(T) {
59 template <
class Id,
class U>
60 constexpr
bool checkDuplicate(Id, U* ptr)
62 return CTableEntry<Id>::convertable(ptr) ?
true : (
63 checkDuplicate(IntToType<Id::value - 1>(), ptr));
68 constexpr
bool checkDuplicate(IntToType<-1>, U* ptr)
74 template <
class T,
class U>
75 struct MergeStringTables
87 typedef typename std::conditional<
89 CTableEntry<T>::important && !checkDuplicate(IntToType<T::value - 1>(), (
typename CTableEntry<T>::type_t*)NULL),
91 MergeStringTables<decltype(makeStringTable(IntToType<T::value - 1>())), CTableEntry<T> >,
93 decltype(makeStringTable(IntToType<T::value - 1>()))
99 struct string_table_t<IntToType<-1> >
101 typedef CTableEntry<IntToType<-1> > type;
106 constexpr
typename string_table_t<T>::type makeStringTable(T)
108 return MergeStringTables<
109 decltype(makeStringTable(IntToType<T::value - 1>())),
116 constexpr CTableEntry<IntToType<-1> > makeStringTable(IntToType<-1> t)
118 return CTableEntry<IntToType<-1> >();
121 #define TOC_DECLARE_NAME(id, name) \ 122 struct CTableSelector_ ## name ## _t; \ 124 struct CTableEntry<IntToType<id> > \ 126 typedef CTableSelector_ ## name ## _t type_t; \ 127 typedef CTableEntry<IntToType<id> > name ## _t; \ 128 const char name[sizeof(#name)] = #name; \ 129 static constexpr bool important = true; \ 130 static constexpr bool convertable(const void *) { \ 133 static constexpr bool convertable(const type_t *) { \ 136 static constexpr int raw_offset = \ 137 packed_sizeof(makeStringTable(IntToType<id - 1>())); \ 138 static constexpr int offset = (raw_offset == 1) ? \ 140 static constexpr int getOffset(); \ 144 struct CTableIntSelector;
146 #define TOC_DECLARE_INT(id, val, is_important) \ 148 struct CTableEntry<IntToType<id> > \ 150 typedef CTableIntSelector<IntToType<val> > type_t; \ 151 const int value = val; \ 152 static constexpr bool important = is_important; \ 153 static constexpr bool convertable(const void *) { \ 156 static constexpr bool convertable(const type_t *) { \ 159 static constexpr int raw_offset = \ 160 packed_sizeof(makeStringTable(IntToType<id - 1>())); \ 161 static constexpr int offset = (raw_offset == 1) ? \ 163 static constexpr int getOffset(IntToType<val>) { \ 164 return (raw_offset == 1) ? 0 : raw_offset; \ 168 template<
class Length>
171 const typename string_table_t<Length>::type impl = makeStringTable(Length());
A part of TOC table compile-time generator.