OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
18 #include "../direction_type.h"
19 #include "../signal_type.h"
20 #include "../tile_type.h"
21 #include "../track_type.h"
27 template <
typename T,
size_t N>
struct ArrayT<T[N]> {
28 static const size_t length = N;
37 template <
typename E,
typename T>
51 template <
typename E,
typename T>
69 template <
typename E,
typename T>
70 inline CStrA ComposeNameT(E value, T &t,
const char *t_unk, E val_inv,
const char *name_inv)
73 if (value == val_inv) {
75 }
else if (value == 0) {
78 for (
size_t i = 0; i < ArrayT<T>::length; i++) {
79 if ((value & (1 << i)) == 0)
continue;
80 out.AddFormat(
"%s%s", (out.
Size() > 0 ?
"+" :
""), (
const char*)t[i]);
81 value &= ~(E)(1 << i);
83 if (value != 0) out.AddFormat(
"%s%s", (out.
Size() > 0 ?
"+" :
""), t_unk);
85 return out.Transfer();
108 m_type_id = src.m_type_id;
114 if ((
size_t)m_ptr < (
size_t)other.m_ptr)
return true;
115 if ((
size_t)m_ptr > (
size_t)other.m_ptr)
return false;
116 if (m_type_id < other.m_type_id)
return true;
121 typedef std::map<KnownStructKey, CStrA> KNOWN_NAMES;
138 void CDECL
WriteLine(
const char *format, ...) WARN_FORMAT(2, 3);
139 void WriteValue(const
char *name, const
char *value_str);
148 void BeginStruct(
size_t type_id,
const char *name,
const void *ptr);
uint32 TileIndex
The index/ID of a Tile.
static size_t & LastTypeId()
Keep track of the last assigned type_id.
void WriteIndent()
Write some leading spaces into the output.
TrackdirBits
Enumeration of bitmasks for the TrackDirs.
void WriteEnumT(const char *name, E e)
Dump given enum value (as a number and as named value)
Blob based case sensitive ANSI/UTF-8 string.
void EndStruct()
Close structure '}<LF>'.
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...
CStrA ValueStr(Trackdir td)
Return name of given Trackdir.
void CDECL WriteLine(const char *format,...) WARN_FORMAT(2
Write a line with indent at the beginning and <LF> at the end.
KNOWN_NAMES m_known_names
map of known object instances and their structured names
void WriteTile(const char *name, TileIndex t)
Write name & TileIndex to the output.
Used as a key into map of known object instances.
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.
int m_indent
current indent/nesting level
size_t Size() const
Return number of items in the Blob.
bool FindKnownName(size_t type_id, const void *ptr, CStrA &name)
Find the given instance in our anti-recursion repository.
Class that represents the dump-into-string target.
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).
std::stack< CStrA > m_cur_struct
here we will track the current structure name
void CDECL void WriteValue(const char *name, const char *value_str)
Write 'name = value' with indent and new-line.
CStrA GetCurrentStructName()
Return structured name of the current class/structure.
void BeginStruct(size_t type_id, const char *name, const void *ptr)
Open new structure (one level deeper than the current one) 'name = {<LF>'.
CStrA m_out
the output string
Trackdir
Enumeration for tracks and directions.
T * Data()
Return pointer to the first data item - non-const version.