RawPointerT< Pointer > Class Template Reference

#include <IoManip.h>

Collaboration diagram for RawPointerT< Pointer >:

Public Member Functions

 RawPointerT (const char *aLabel, const Pointer &aPtr)
 
RawPointerT< Pointer > & asExtra ()
 Report the pointed-to-object on a dedicated Debug::Extra line. More...
 
RawPointerT< Pointer > & orNil (const char *nilTextToUse="[nil]")
 enable and, optionally, customize reporting of nil pointers More...
 

Public Attributes

const char * label
 
const char * nilText = nullptr
 the name or description of the being-debugged object More...
 
const Pointer & ptr
 
bool onExtraLine = false
 a possibly nil pointer to the being-debugged object More...
 

Detailed Description

template<class Pointer>
class RawPointerT< Pointer >

manipulator tuning methods

Our convenience manipulator/wrapper classes often have methods that tune their "printing" effects (e.g., AsHex::minDigits()). STL streams also have manipulators that tune how subsequent operator "<<" parameters are printed (e.g., std::setw()). The calling code can also print various decorations (i.e. prefixes and suffixes). The following principles are useful when deciding what manipulator methods to add and how to implement them:

  • Add a manipulator method if callers would otherwise have to restore stream format after calling the manipulator. For example, AsHex::toUpper() frees callers from doing std::uppercase << asHex(n) << std::nouppercase.
  • Add a manipulator method if callers would otherwise have to use conditionals to get the same effect. For example, AsList::prefixedBy() frees callers from doing (c.empty() ? "" : "/") << asList(c).
  • Add a manipulator method if callers would otherwise have to repeat a combination of actions to get the right effect. For example, AsList::minDigits() prevents duplication of the following caller code: ‘std::setfill('0’) << std::setw(8) << asHex(n)`.
  • Avoid adding a manipulator method that can be fully replaced with a single caller item. For example, do not add AsX::foo() if callers can do bar << asX(y) or asX(y) << bar and get exactly the same effect.
  • Manipulators should honor existing stream formatting to the extent possible (e.g., AsHex honors std::uppercase by default). Safely prints an object pointed to by the given pointer: [label]<object> Prints nothing at all if the pointer is nil.

Definition at line 50 of file IoManip.h.

Constructor & Destructor Documentation

◆ RawPointerT()

template<class Pointer >
RawPointerT< Pointer >::RawPointerT ( const char *  aLabel,
const Pointer &  aPtr 
)
inline

Definition at line 52 of file IoManip.h.

Member Function Documentation

◆ asExtra()

template<class Pointer >
RawPointerT<Pointer>& RawPointerT< Pointer >::asExtra ( )
inline

Definition at line 56 of file IoManip.h.

References RawPointerT< Pointer >::onExtraLine.

◆ orNil()

template<class Pointer >
RawPointerT<Pointer>& RawPointerT< Pointer >::orNil ( const char *  nilTextToUse = "[nil]")
inline

Definition at line 59 of file IoManip.h.

References RawPointerT< Pointer >::nilText.

Member Data Documentation

◆ label

template<class Pointer >
const char* RawPointerT< Pointer >::label

Definition at line 61 of file IoManip.h.

Referenced by operator<<().

◆ nilText

template<class Pointer >
const char* RawPointerT< Pointer >::nilText = nullptr

whether and how to report a nil pointer; use orNil() to enable

Definition at line 64 of file IoManip.h.

Referenced by operator<<(), and RawPointerT< Pointer >::orNil().

◆ onExtraLine

template<class Pointer >
bool RawPointerT< Pointer >::onExtraLine = false

Definition at line 67 of file IoManip.h.

Referenced by RawPointerT< Pointer >::asExtra(), and operator<<().

◆ ptr

template<class Pointer >
const Pointer& RawPointerT< Pointer >::ptr

Definition at line 66 of file IoManip.h.

Referenced by operator<<().


The documentation for this class was generated from the following file:

 

Introduction

Documentation

Support

Miscellaneous