TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Core::Formatter Class Reference

#include <tb_formatter.hpp>

Public Member Functions

 Formatter (const char *formattedMessage,...)
 
 Formatter (const Formatter &other)
 
 Formatter (Formatter &&other)
 
 ~Formatter (void)
 
Formatteroperator= (const Formatter &other)
 
Formatteroperator= (Formatter &&other)
 
const char * c_str (void) const
 

Static Public Member Functions

static Formatter FromArgumentList (const char *formattedMessage, va_list argumentsList)
 

Detailed Description

The Formatter is a very small helper function that will take a printf style formatted string and the additional parameters to build and hold the string in memory until the Formatter object dies.

Constructor & Destructor Documentation

TurtleBrains::Core::Formatter::Formatter ( const char *  formattedMessage,
  ... 
)
explicit

Build a Formatter object from the printf style formatted string and the additional parameters.

Parameters
formattedMessageA string using printf formatter options to specify how to use the additional parameters sent in. Formatter("Hello %s!", "world") for instance.
TurtleBrains::Core::Formatter::Formatter ( const Formatter other)

Constructs a Formatter object by copying another. This will invoke memory allocations to create a buffer for the message.

Parameters
otherThe formatter object to copy from. The contents will be duplicated.
TurtleBrains::Core::Formatter::Formatter ( Formatter &&  other)

Moves one Formatter into another without invoking additional memory allocations.

Parameters
otherThe formatter object to move the buffer from without allocation memory.
TurtleBrains::Core::Formatter::~Formatter ( void  )

Cleans up all the resources used from the Formatter object, which will include freeing memory.

Member Function Documentation

const char* TurtleBrains::Core::Formatter::c_str ( void  ) const

Returns a null-terminated string of the buffer contents, or an empty string if buffer is empty.

static Formatter TurtleBrains::Core::Formatter::FromArgumentList ( const char *  formattedMessage,
va_list  argumentsList 
)
static

Build a Formatter object from the printf style formatted string and the additional parameters supplied by a va_list.

Parameters
formattedMessageA string using printf formatter options to specify how to use the additional parameters sent in.
argumentListA list of the arguments to use to format a message like vasprintf().
Formatter& TurtleBrains::Core::Formatter::operator= ( const Formatter other)

Assigns one Formatter object to that of another one by assignment. This may invoke memory allocations to if required to create the buffer for the message.

Parameters
otherThe formatter object to copy from. The contents will be duplicated.
Formatter& TurtleBrains::Core::Formatter::operator= ( Formatter &&  other)

Moves one Formatter into another without invoking additional memory allocations.

Parameters
otherThe formatter object to move the buffer from without allocation memory.