20 #include "../direction_type.h" 21 #include "../signal_type.h" 22 #include "../tile_type.h" 23 #include "../track_type.h" 29 template <
typename T,
size_t N>
struct ArrayT<T[N]> {
30 static const size_t length = N;
39 template <
typename E,
typename T>
53 template <
typename E,
typename T>
71 template <
typename E,
typename T>
72 inline CStrA ComposeNameT(E value, T &t,
const char *t_unk, E val_inv,
const char *name_inv)
75 if (value == val_inv) {
77 }
else if (value == 0) {
80 for (
size_t i = 0; i < ArrayT<T>::length; i++) {
81 if ((value & (1 << i)) == 0)
continue;
82 out.AddFormat(
"%s%s", (out.
Size() > 0 ?
"+" :
""), (
const char*)t[i]);
83 value &= ~(E)(1 << i);
85 if (value != 0) out.AddFormat(
"%s%s", (out.
Size() > 0 ?
"+" :
""), t_unk);
87 return out.Transfer();
110 m_type_id = src.m_type_id;
116 if ((
size_t)m_ptr < (
size_t)other.m_ptr)
return true;
117 if ((
size_t)m_ptr > (
size_t)other.m_ptr)
return false;
118 if (m_type_id < other.m_type_id)
return true;
123 typedef std::map<KnownStructKey, CStrA> KNOWN_NAMES;
134 static size_t& LastTypeId();
135 CStrA GetCurrentStructName();
136 bool FindKnownName(
size_t type_id,
const void *ptr,
CStrA &name);
140 void CDECL WriteLine(
const char *format, ...) WARN_FORMAT(2, 3);
141 void WriteValue(
const char *name,
const char *value_str);
142 void WriteTile(
const char *name,
TileIndex t);
150 void BeginStruct(
size_t type_id,
const char *name,
const void *ptr);
156 static size_t type_id = ++LastTypeId();
160 WriteLine(
"%s = <null>", name);
164 if (FindKnownName(type_id, s, known_as)) {
166 WriteLine(
"%s = known_as.%s", name, known_as.
Data());
169 BeginStruct(type_id, name, s);
CStrA m_out
the output string
SignalType
Type of signal, i.e.
CStrA ComposeNameT(E value, T &t, const char *t_unk, E val_inv, const char *name_inv)
Helper template function that returns compound bitfield name that is concatenation of names of each s...
Helper template class that provides C array length and item type.
void WriteEnumT(const char *name, E e)
Dump given enum value (as a number and as named value)
Used as a key into map of known object instances.
KNOWN_NAMES m_known_names
map of known object instances and their structured names
Blob based case sensitive ANSI/UTF-8 string.
int m_indent
current indent/nesting level
Trackdir
Enumeration for tracks and directions.
std::stack< CStrA > m_cur_struct
here we will track the current structure name
DiagDirection
Enumeration for diagonal directions.
void WriteStructT(const char *name, const S *s)
Dump nested object (or only its name if this instance is already known).
uint32 TileIndex
The index/ID of a Tile.
T * Data()
Return pointer to the first data item - non-const version.
TrackdirBits
Enumeration of bitmasks for the TrackDirs.
CStrA ValueStr(Trackdir td)
Return name of given Trackdir.
size_t Size() const
Return number of items in the Blob.
ArrayT< T >::item_t ItemAtT(E idx, const T &t, typename ArrayT< T >::item_t t_unk)
Helper template function that returns item of array at given index or t_unk when index is out of boun...
void WriteValue(void *ptr, VarType conv, int64 val)
Write the value of a setting.
Class that represents the dump-into-string target.