OpenTTD Source: DumpTarget Struct Reference

OpenTTD Source 14.0-RC3

Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Data Fields
DumpTarget Struct Reference

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
typedef std::map< KnownStructKey, std::string > | KNOWN_NAMES

## Public Member Functions
std::string | GetCurrentStructName ()
| Return structured name of the current class/structure.
bool | FindKnownName (size_t type_id, const void *ptr, std::string &name)
| Find the given instance in our anti-recursion repository. More...
void | WriteIndent ()
| Write some leading spaces into the output.
void | WriteValue (const std::string &name, int value)
| Write 'name = value' with indent and new-line.
void | WriteValue (const std::string &name, const std::string &value_str)
| Write 'name = value' with indent and new-line.
void | WriteTile (const std::string &name, TileIndex t)
| Write name & TileIndex to the output.
template<typename E >
void | WriteEnumT (const std::string &name, E e)
| Dump given enum value (as a number and as named value)
void | BeginStruct (size_t type_id, const std::string &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 (const std::string &name, const S *s)
| Dump nested object (or only its name if this instance is already known).

## Static Public Member Functions
static size_t & | LastTypeId ()
| Keep track of the last assigned type_id. More...

## Data Fields
std::string | m_out
| the output string
int | m_indent
| current indent/nesting level
std::stack< std::string > | m_cur_struct
| here we will track the current structure name
KNOWN_NAMES | m_known_names
| map of known object instances and their structured names

## Detailed Description

Class that represents the dump-into-string target.

Definition at line 95 of file dbg_helpers.h.

## Member Function Documentation

## ◆ FindKnownName()

bool DumpTarget::FindKnownName | ( | size_t | type_id,
|  | const void * | ptr,
|  | std::string & | name
| ) |  |

Find the given instance in our anti-recursion repository.

Return true and set name when object was found.

Definition at line 94 of file dbg_helpers.cpp.

References m_known_names.

## ◆ LastTypeId()

size_t & DumpTarget::LastTypeId | ( |  | ) |
| static

Keep track of the last assigned type_id.

Used for anti-recursion. static

Definition at line 73 of file dbg_helpers.cpp.

The documentation for this struct was generated from the following files:

- src/misc/dbg_helpers.h
- src/misc/dbg_helpers.cpp