DumpTarget Struct Reference

Class that represents the dump-into-string target. More...

#include <dbg_helpers.h>


Public Types

typedef std::map
< KnownStructKey, CStrA
KNOWN_NAMES

Public Member Functions

CStrA GetCurrentStructName ()
 Return structured name of the current class/structure.
bool FindKnownName (size_t type_id, const void *ptr, CStrA &name)
 Find the given instance in our anti-recursion repository.
void WriteIndent ()
 Write some leading spaces into the output.
void WriteLine (const char *format,...)
 Write a line with indent at the beginning and <LF> at the end.
void WriteValue (const char *name, const char *value_str)
 Write 'name = value' with indent and new-line.
void WriteTile (const char *name, TileIndex t)
 Write name & TileIndex to the output.
template<typename E>
void WriteEnumT (const char *name, E e)
 Dump given enum value (as a number and as named value).
void BeginStruct (size_t type_id, const char *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 char *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.

Data Fields

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

Data Structures

struct  KnownStructKey
 Used as a key into map of known object instances. More...


Detailed Description

Class that represents the dump-into-string target.

Definition at line 86 of file dbg_helpers.h.


Member Function Documentation

size_t & DumpTarget::LastTypeId (  )  [static]

Keep track of the last assigned type_id.

Used for anti-recursion. static

Definition at line 69 of file dbg_helpers.cpp.

Referenced by WriteStructT().

CStrA DumpTarget::GetCurrentStructName (  ) 

Return structured name of the current class/structure.

Definition at line 76 of file dbg_helpers.cpp.

References m_cur_struct, and CBlobT< Titem_, Tbase_ >::Transfer().

Referenced by BeginStruct().

bool DumpTarget::FindKnownName ( size_t  type_id,
const void *  ptr,
CStrA name 
)

Find the given instance in our anti-recursion repository.

Return true and set name when object was found.

Definition at line 90 of file dbg_helpers.cpp.

References m_known_names.

Referenced by WriteStructT().

void DumpTarget::WriteIndent (  ) 

Write some leading spaces into the output.

Definition at line 102 of file dbg_helpers.cpp.

References CStrT< Tchar, TcaseInsensitive >::GrowSizeNC(), m_indent, and m_out.

Referenced by BeginStruct(), EndStruct(), WriteLine(), WriteTile(), and WriteValue().

void DumpTarget::WriteLine ( const char *  format,
  ... 
)

Write a line with indent at the beginning and <LF> at the end.

Definition at line 109 of file dbg_helpers.cpp.

References CStrT< Tchar, TcaseInsensitive >::AddFormatL(), CStrT< Tchar, TcaseInsensitive >::AppendStr(), m_out, and WriteIndent().

Referenced by WriteStructT().

void DumpTarget::WriteValue ( const char *  name,
const char *  value_str 
)

Write 'name = value' with indent and new-line.

Definition at line 120 of file dbg_helpers.cpp.

References CStrT< Tchar, TcaseInsensitive >::AddFormat(), m_out, and WriteIndent().

Referenced by WriteEnumT().

void DumpTarget::WriteTile ( const char *  name,
TileIndex  tile 
)

Write name & TileIndex to the output.

Definition at line 127 of file dbg_helpers.cpp.

References CStrT< Tchar, TcaseInsensitive >::AddFormat(), m_out, TileStr(), and WriteIndent().

template<typename S>
void DumpTarget::WriteStructT ( const char *  name,
const S *  s 
) [inline]

Dump nested object (or only its name if this instance is already known).

Definition at line 144 of file dbg_helpers.h.

References BeginStruct(), CBlobT< Titem_, Tbase_ >::Data(), EndStruct(), FindKnownName(), LastTypeId(), and WriteLine().


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

Generated on Mon Mar 23 00:25:49 2009 for OpenTTD by  doxygen 1.5.6