OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
17 #include "../direction_type.h"
18 #include "../signal_type.h"
19 #include "../tile_type.h"
20 #include "../track_type.h"
26 template <
typename T,
size_t N>
struct ArrayT<T[N]> {
27 static const size_t length = N;
36 template <
typename E,
typename T>
50 template <
typename E,
typename T>
68 template <
typename E,
typename T>
69 inline std::string
ComposeNameT(E value, T &t,
const char *t_unk, E val_inv,
const char *name_inv)
72 if (value == val_inv) {
74 }
else if (value == 0) {
77 for (
size_t i = 0; i < ArrayT<T>::length; i++) {
78 if ((value & (1 << i)) == 0)
continue;
79 out += (!out.empty() ?
"+" :
"");
81 value &= ~(E)(1 << i);
84 out += (!out.empty() ?
"+" :
"");
111 if ((
size_t)m_ptr < (
size_t)other.m_ptr)
return true;
112 if ((
size_t)m_ptr > (
size_t)other.m_ptr)
return false;
113 if (m_type_id < other.m_type_id)
return true;
118 typedef std::map<KnownStructKey, std::string> KNOWN_NAMES;
131 bool FindKnownName(
size_t type_id,
const void *ptr, std::string &name);
136 void WriteValue(
const char *name,
const char *value_str);
145 void BeginStruct(
size_t type_id,
const char *name,
const void *ptr);
158 std::string known_as;
161 std::string known_as_str = std::string(
"known_as.") + name;
bool FindKnownName(size_t type_id, const void *ptr, std::string &name)
Find the given instance in our anti-recursion repository.
uint32 TileIndex
The index/ID of a Tile.
static size_t & LastTypeId()
Keep track of the last assigned type_id.
std::string 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...
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)
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...
std::string GetCurrentStructName()
Return structured name of the current class/structure.
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.
std::stack< std::string > m_cur_struct
here we will track the current structure name
std::string ValueStr(Trackdir td)
Return name of given Trackdir.
Helper template class that provides C array length and item type.
int m_indent
current indent/nesting level
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).
void WriteValue(const char *name, int value)
Write 'name = value' with indent and new-line.
std::string m_out
the output string
void BeginStruct(size_t type_id, const char *name, const void *ptr)
Open new structure (one level deeper than the current one) 'name = {<LF>'.
Trackdir
Enumeration for tracks and directions.