OpenTTD Source 20241224-master-gee860a5c8e
dbg_helpers.h File Reference

Functions to be used for debug printings. More...

#include <stack>
#include "../direction_type.h"
#include "../signal_type.h"
#include "../tile_type.h"
#include "../track_type.h"

Go to the source code of this file.

Data Structures

struct  ArrayT< T[N]>
 Helper template class that provides C array length and item type. More...
 
struct  DumpTarget
 Class that represents the dump-into-string target. More...
 
struct  DumpTarget::KnownStructKey
 Used as a key into map of known object instances. More...
 

Functions

template<typename E , typename T >
ArrayT< T >::Item ItemAtT (E idx, const T &t, typename ArrayT< T >::Item t_unk)
 Helper template function that returns item of array at given index or t_unk when index is out of bounds.
 
template<typename E , typename T >
ArrayT< T >::Item ItemAtT (E idx, const T &t, typename ArrayT< T >::Item t_unk, E idx_inv, typename ArrayT< T >::Item t_inv)
 Helper template function that returns item of array at given index or t_inv when index == idx_inv or t_unk when index is out of bounds.
 
template<typename E , typename T >
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 set bit in the given value or t_inv when index == idx_inv or t_unk when index is out of bounds.
 
std::string ValueStr (Trackdir td)
 Return name of given Trackdir.
 
std::string ValueStr (TrackdirBits td_bits)
 Return composed name of given TrackdirBits.
 
std::string ValueStr (DiagDirection dd)
 Return name of given DiagDirection.
 
std::string ValueStr (SignalType t)
 Return name of given SignalType.
 

Detailed Description

Functions to be used for debug printings.

Definition in file dbg_helpers.h.

Function Documentation

◆ ComposeNameT()

template<typename E , typename T >
std::string ComposeNameT ( value,
T &  t,
const char *  t_unk,
val_inv,
const char *  name_inv 
)
inline

Helper template function that returns compound bitfield name that is concatenation of names of each set bit in the given value or t_inv when index == idx_inv or t_unk when index is out of bounds.

Definition at line 67 of file dbg_helpers.h.

Referenced by ValueStr().

◆ ItemAtT() [1/2]

template<typename E , typename T >
ArrayT< T >::Item ItemAtT ( idx,
const T &  t,
typename ArrayT< T >::Item  t_unk 
)
inline

Helper template function that returns item of array at given index or t_unk when index is out of bounds.

Definition at line 35 of file dbg_helpers.h.

Referenced by ValueStr(), ValueStr(), and ValueStr().

◆ ItemAtT() [2/2]

template<typename E , typename T >
ArrayT< T >::Item ItemAtT ( idx,
const T &  t,
typename ArrayT< T >::Item  t_unk,
idx_inv,
typename ArrayT< T >::Item  t_inv 
)
inline

Helper template function that returns item of array at given index or t_inv when index == idx_inv or t_unk when index is out of bounds.

Definition at line 49 of file dbg_helpers.h.

◆ ValueStr() [1/4]

std::string ValueStr ( DiagDirection  dd)

Return name of given DiagDirection.

Definition at line 44 of file dbg_helpers.cpp.

References diagdir_names, INVALID_DIAGDIR, and ItemAtT().

◆ ValueStr() [2/4]

std::string ValueStr ( SignalType  t)

Return name of given SignalType.

Definition at line 56 of file dbg_helpers.cpp.

References ItemAtT(), and signal_type_names.

◆ ValueStr() [3/4]

std::string ValueStr ( Trackdir  td)

Return name of given Trackdir.

Definition at line 26 of file dbg_helpers.cpp.

References INVALID_TRACKDIR, ItemAtT(), and trackdir_names.

Referenced by DumpTarget::WriteEnumT().

◆ ValueStr() [4/4]

std::string ValueStr ( TrackdirBits  td_bits)

Return composed name of given TrackdirBits.

Definition at line 32 of file dbg_helpers.cpp.

References ComposeNameT(), INVALID_TRACKDIR_BIT, and trackdir_names.