Tracer  v0.0.1
A platform independant stack trace generator
tracer::AbstractPrinter Class Referenceabstract

Basic class for all printers. More...

#include <AbstractPrinter.hpp>

+ Inheritance diagram for tracer::AbstractPrinter:
+ Collaboration diagram for tracer::AbstractPrinter:

Public Member Functions

 AbstractPrinter ()
 Default constructor.
 
std::string genStringPreFrame (size_t frameNum)
 Generates a string for the frame information (prefix) More...
 
std::string genStringForFrame (size_t frameNum)
 Generates a string for the frame information. More...
 
std::string genStringPostFrame (size_t frameNum)
 Generates a string for the frame information (suffix) More...
 
std::string generateString ()
 Generates a string for the complete stack trace. More...
 
void printToFile (std::string file, bool append=true)
 Prints the stack trace to a file. More...
 
void printToStdOut ()
 prints the stack trace to STDOUT
 
void printToStdErr ()
 prints the stack trace to STDERR
 
void enableColor ()
 Enables colored output (ANSI escape sequences)
 
void disableColor ()
 Disables colored output (ANSI escape sequences)
 
void setTrace (Tracer *t)
 Sets the trace to print. More...
 

Protected Member Functions

virtual void setupTrace ()
 This function will be called when the trace is sets.
 
virtual std::string genStringPreFrameIMPL (size_t frameNum)
 Generate string for the frame info prefix. More...
 
virtual std::string genStringForFrameIMPL (size_t frameNum)=0
 Generate string for the frame info.
 
virtual std::string genStringPostFrameIMPL (size_t frameNum)
 Generate string for the frame info suffix. More...
 

Protected Attributes

Tracertrace = nullptr
 Pointer to the trace.
 
bool disableColorB = false
 Whether to disable colored output or not.
 

Detailed Description

Basic class for all printers.

Definition at line 39 of file AbstractPrinter.hpp.

Member Function Documentation

◆ generateString()

std::string tracer::AbstractPrinter::generateString ( )

Generates a string for the complete stack trace.

Returns
The generated string

Definition at line 47 of file AbstractPrinter.cpp.

◆ genStringForFrame()

std::string tracer::AbstractPrinter::genStringForFrame ( size_t  frameNum)

Generates a string for the frame information.

Parameters
frameNumThe number off the frame to process
Returns
The generated string

Definition at line 88 of file AbstractPrinter.cpp.

◆ genStringPostFrame()

std::string tracer::AbstractPrinter::genStringPostFrame ( size_t  frameNum)

Generates a string for the frame information (suffix)

Parameters
frameNumThe number off the frame to process
Returns
The generated string

Definition at line 100 of file AbstractPrinter.cpp.

◆ genStringPostFrameIMPL()

string AbstractPrinter::genStringPostFrameIMPL ( size_t  frameNum)
protectedvirtual

Generate string for the frame info suffix.

Default implementation.

Reimplemented in tracer::FilePrinter.

Definition at line 69 of file AbstractPrinter.cpp.

◆ genStringPreFrame()

std::string tracer::AbstractPrinter::genStringPreFrame ( size_t  frameNum)

Generates a string for the frame information (prefix)

Parameters
frameNumThe number off the frame to process
Returns
The generated string

Definition at line 76 of file AbstractPrinter.cpp.

◆ genStringPreFrameIMPL()

string AbstractPrinter::genStringPreFrameIMPL ( size_t  frameNum)
protectedvirtual

Generate string for the frame info prefix.

Default implementation.

Reimplemented in tracer::SystemInfoPrinter.

Definition at line 68 of file AbstractPrinter.cpp.

◆ printToFile()

void tracer::AbstractPrinter::printToFile ( std::string  file,
bool  append = true 
)

Prints the stack trace to a file.

Parameters
fileThe file to print to
appendWhether to append the stack trace to the file or not
Note
The contents of file will be removed when append is false.

Definition at line 115 of file AbstractPrinter.cpp.

+ Here is the caller graph for this function:

◆ setTrace()

void tracer::AbstractPrinter::setTrace ( tracer::Tracer t)

Sets the trace to print.

Parameters
tThe trace to print
Warning
This function MUST be called before a trace string can be generated!

Definition at line 145 of file AbstractPrinter.cpp.

+ Here is the caller graph for this function:

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