BPPrint
General object hashing library for C++
Classes | Functions
bpprint::detail Namespace Reference

Classes

struct  FormatInfo
 Information about a single format specification. More...
 
struct  PFTypeMap
 
struct  ValidPrintfArg
 
struct  ValidPrintfArg< char * >
 
struct  ValidPrintfArg< const char * >
 
struct  ValidPrintfArg< std::string >
 
struct  ValidPrintfArg< T * >
 

Functions

bool get_next_format_ (FormatInfo &fi, const std::string &str)
 Get the next format specification. More...
 
void format_ (std::ostream &os, FormatInfo &fi, const std::string &str)
 Format a string into an ostream. More...
 
template<typename T , typename... Targs>
void format_ (std::ostream &os, FormatInfo &fi, const std::string &str, T arg, Targs...args)
 Format a string into an ostream. More...
 
template<typename T >
void handle_fmt_single_ (std::string &fmt, T subst)
 Handles substitution of a single specifier. More...
 
template<typename T >
void handle_fmt_ (std::string &fmt, const char *length, char spec, T subst)
 Prepare and check a decomposed format. More...
 
void handle_fmt_ (std::string &fmt, const char *length, char spec, const char *subst)
 Prepare and check a decomposed format. More...
 
void handle_fmt_ (std::string &fmt, const char *length, char spec, char *subst)
 Prepare and check a decomposed format. More...
 
void handle_fmt_ (std::string &fmt, const char *length, char spec, const std::string &subst)
 Prepare and check a decomposed format. More...
 
template<typename T >
void handle_fmt_ (std::string &fmt, const char *length, char spec, T *subst)
 Prepare and check a decomposed format. More...
 

Function Documentation

template<typename T , typename... Targs>
void bpprint::detail::format_ ( std::ostream &  os,
FormatInfo fi,
const std::string &  str,
arg,
Targs...  args 
)

Format a string into an ostream.

This will only format the first specification found in str, using arg as the substitution

Exceptions
std::runtime_errorif the correct number of arguments is not given or if the format string is badly formed
Parameters
[in]osThe ostream to output to
[in]fiThe format information struct to use
[in]strString (possibly with format string specification)
[in]argSubstitution for the first format specification found
[in]argsAdditional arguments for later format specifications

Definition at line 83 of file Format.hpp.

Here is the call graph for this function:

void bpprint::detail::format_ ( std::ostream &  os,
FormatInfo fi,
const std::string &  str 
)

Format a string into an ostream.

Used to terminate the variadic template

Exceptions
std::runtime_errorif the string contains a format specification (meaning it is expecting an argument)
Parameters
[in]osThe ostream used to build the string
[in]fiFormat info to use as a workspace
[in]strString (possibly with format string specification)

Definition at line 144 of file Format.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool bpprint::detail::get_next_format_ ( FormatInfo fi,
const std::string &  str 
)

Get the next format specification.

If the function returns true, the members of fi are filled in.

If the function returns false, the prefix member contains the entire string but with some processing (such as replacing %% with %).

Exceptions
std::runtime_errorif the format string is badly formatted
Parameters
[out]fiInformation about the specification
[in]strThe string to search
Returns
True if a format specification was found, otherwise false

Definition at line 10 of file Format.cpp.

Here is the caller graph for this function:

template<typename T >
void bpprint::detail::handle_fmt_ ( std::string &  fmt,
const char *  length,
char  spec,
T *  subst 
)

Prepare and check a decomposed format.

Overload for pointers, which are always passwd as void *

Definition at line 36 of file Printf_wrap.hpp.

Here is the call graph for this function:

template<typename T >
void bpprint::detail::handle_fmt_ ( std::string &  fmt,
const char *  length,
char  spec,
subst 
)

Prepare and check a decomposed format.

This checks the type against the type specifier in the format string (that has been decomposed into its pieces).

Exceptions
std::runtime_errorIf there is a problem with the substitution, such as if the type specification or length specification does not match the data type passed in.
Template Parameters
TThe type of data to substitute with
Parameters
[in]fmtThe format specifier without the length or type specifiers
[in]lengthThe length specifier
[in]specThe type specifier
[in]substWhat to put in place of the specifier

Definition at line 104 of file Printf_wrap.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void bpprint::detail::handle_fmt_ ( std::string &  fmt,
const char *  length,
char  spec,
const char *  subst 
)

Prepare and check a decomposed format.

Overload for char *, since we may not always want it to be used as a string (ie, p)

Definition at line 157 of file Printf_wrap.cpp.

void bpprint::detail::handle_fmt_ ( std::string &  fmt,
const char *  length,
char  spec,
char *  subst 
)

Prepare and check a decomposed format.

Overload for char *, since we may not always want it to be used as a string (ie, p)

Definition at line 169 of file Printf_wrap.cpp.

Here is the call graph for this function:

void bpprint::detail::handle_fmt_ ( std::string &  fmt,
const char *  length,
char  spec,
const std::string &  subst 
)

Prepare and check a decomposed format.

Overload for std::string, so we can pass it to s

Definition at line 177 of file Printf_wrap.cpp.

Here is the call graph for this function:

template<typename T >
void bpprint::detail::handle_fmt_single_ ( std::string &  fmt,
subst 
)

Handles substitution of a single specifier.

This takes a string containing a single format specifier and substitutes in the value. By this point, the type should already have been checked against the type specifier of the format.

Exceptions
std::runtime_errorIf there is a problem with the substitution
Template Parameters
TThe type of data to substitute with
Parameters
[in,out]fmtString with a single format specifier. Will be replaced with the formatted string
[in]substWhat to put in place of the specifier

Definition at line 67 of file Printf_wrap.cpp.

Here is the caller graph for this function: