|
OpenTTD Source 20260218-master-g2123fca5ea
|
Class that represents the dump-into-string target. More...
#include <dbg_helpers.h>
Data Structures | |
| struct | KnownStructKey |
| Used as a key into map of known object instances. More... | |
Public Types | |
| using | KnownNamesMap = std::map<KnownStructKey, std::string> |
| Mapping of the KnownStructKey to the name for that structure. | |
Public Member Functions | |
| std::string | GetCurrentStructName () |
| Return structured name of the current class/structure. | |
| std::optional< std::string > | FindKnownAsName (size_t type_id, const void *ptr) |
| Find the given instance in our anti-recursion repository. | |
| void | WriteIndent () |
| Write some leading spaces into the output. | |
| void | WriteValue (std::string_view name, const auto &value) |
| Write 'name = value' with indent and new-line. | |
| void | WriteTile (std::string_view name, TileIndex t) |
| Write name & TileIndex to the output. | |
| template<typename E> | |
| void | WriteEnumT (std::string_view name, E e) |
| Dump given enum value (as a number and as named value). | |
| void | BeginStruct (size_t type_id, std::string_view name, const void *ptr) |
| Open new structure (one level deeper than the current one) 'name = {<LF>'. | |
| void | EndStruct () |
| Close structure '}<LF>'. | |
| template<typename S> | |
| void | WriteStructT (std::string_view name, const S *s) |
| Dump nested object (or only its name if this instance is already known). | |
| template<typename S> | |
| void | WriteStructT (std::string_view name, const std::deque< S > *s) |
| Dump nested object (or only its name if this instance is already known). | |
Static Public Member Functions | |
| static size_t | NewTypeId () |
| Create a new type_id. | |
Data Fields | |
| std::string | output_buffer |
| The output string. | |
| int | indent = 0 |
| Current indent/nesting level. | |
| std::stack< std::string > | cur_struct |
| Tracker of the current structure name. | |
| KnownNamesMap | known_names |
| Map of known object instances and their structured names. | |
Class that represents the dump-into-string target.
Definition at line 129 of file dbg_helpers.h.
| using DumpTarget::KnownNamesMap = std::map<KnownStructKey, std::string> |
Mapping of the KnownStructKey to the name for that structure.
Definition at line 152 of file dbg_helpers.h.
| void DumpTarget::BeginStruct | ( | size_t | type_id, |
| std::string_view | name, | ||
| const void * | ptr ) |
Open new structure (one level deeper than the current one) 'name = {<LF>'.
| type_id | Identifier of the type being dumped. |
| name | The name of the struct. |
| ptr | The content of the struct. |
Definition at line 148 of file dbg_helpers.cpp.
References cur_struct, GetCurrentStructName(), indent, known_names, output_buffer, and WriteIndent().
Referenced by WriteStructT(), and WriteStructT().
| void DumpTarget::EndStruct | ( | ) |
Close structure '}<LF>'.
Definition at line 172 of file dbg_helpers.cpp.
References cur_struct, indent, output_buffer, and WriteIndent().
Referenced by WriteStructT(), and WriteStructT().
| std::optional< std::string > DumpTarget::FindKnownAsName | ( | size_t | type_id, |
| const void * | ptr ) |
Find the given instance in our anti-recursion repository.
| type_id | Identifier of the type being dumped. |
| ptr | The content of the struct. |
std::nullopt when the type was not found. Definition at line 114 of file dbg_helpers.cpp.
References known_names.
Referenced by WriteStructT(), and WriteStructT().
| std::string DumpTarget::GetCurrentStructName | ( | ) |
Return structured name of the current class/structure.
Definition at line 100 of file dbg_helpers.cpp.
References cur_struct.
Referenced by BeginStruct().
|
static |
Create a new type_id.
Used for anti-recursion.
Definition at line 90 of file dbg_helpers.cpp.
Referenced by WriteStructT(), and WriteStructT().
|
inline |
Dump given enum value (as a number and as named value).
| name | The name of the enumeration. |
| e | The value of the enumeration. |
Definition at line 183 of file dbg_helpers.h.
References ValueStr(), and WriteValue().
| void DumpTarget::WriteIndent | ( | ) |
Write some leading spaces into the output.
Definition at line 123 of file dbg_helpers.cpp.
References indent, and output_buffer.
Referenced by BeginStruct(), EndStruct(), WriteTile(), and WriteValue().
|
inline |
Dump nested object (or only its name if this instance is already known).
| name | The name of the struct. |
| s | Pointer to the struct. |
Definition at line 196 of file dbg_helpers.h.
References BeginStruct(), EndStruct(), FindKnownAsName(), NewTypeId(), and WriteValue().
Referenced by WriteStructT().
|
inline |
Dump nested object (or only its name if this instance is already known).
| name | The name of the struct. |
| s | Pointer to the std::deque of structs. |
Definition at line 221 of file dbg_helpers.h.
References BeginStruct(), EndStruct(), FindKnownAsName(), NewTypeId(), WriteStructT(), and WriteValue().
| void DumpTarget::WriteTile | ( | std::string_view | name, |
| TileIndex | tile ) |
Write name & TileIndex to the output.
| name | The name to output. |
| tile | The tile to output. |
Definition at line 136 of file dbg_helpers.cpp.
References output_buffer, TileStr(), and WriteIndent().
|
inline |
Write 'name = value' with indent and new-line.
| name | The name. |
| value | The actual value to write. |
Definition at line 170 of file dbg_helpers.h.
References WriteIndent().
Referenced by WriteEnumT(), WriteStructT(), and WriteStructT().
| std::stack<std::string> DumpTarget::cur_struct |
Tracker of the current structure name.
Definition at line 156 of file dbg_helpers.h.
Referenced by BeginStruct(), EndStruct(), and GetCurrentStructName().
| int DumpTarget::indent = 0 |
Current indent/nesting level.
Definition at line 155 of file dbg_helpers.h.
Referenced by BeginStruct(), EndStruct(), and WriteIndent().
| KnownNamesMap DumpTarget::known_names |
Map of known object instances and their structured names.
Definition at line 157 of file dbg_helpers.h.
Referenced by BeginStruct(), and FindKnownAsName().
| std::string DumpTarget::output_buffer |
The output string.
Definition at line 154 of file dbg_helpers.h.
Referenced by BeginStruct(), EndStruct(), WriteIndent(), and WriteTile().