BPPrint
General object hashing library for C++
|
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... | |
void bpprint::detail::format_ | ( | std::ostream & | os, |
FormatInfo & | fi, | ||
const std::string & | str, | ||
T | arg, | ||
Targs... | args | ||
) |
Format a string into an ostream.
This will only format the first specification found in str
, using arg
as the substitution
std::runtime_error | if the correct number of arguments is not given or if the format string is badly formed |
[in] | os | The ostream to output to |
[in] | fi | The format information struct to use |
[in] | str | String (possibly with format string specification) |
[in] | arg | Substitution for the first format specification found |
[in] | args | Additional arguments for later format specifications |
Definition at line 83 of file Format.hpp.
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
std::runtime_error | if the string contains a format specification (meaning it is expecting an argument) |
[in] | os | The ostream used to build the string |
[in] | fi | Format info to use as a workspace |
[in] | str | String (possibly with format string specification) |
Definition at line 144 of file Format.cpp.
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 %).
std::runtime_error | if the format string is badly formatted |
[out] | fi | Information about the specification |
[in] | str | The string to search |
Definition at line 10 of file Format.cpp.
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.
void bpprint::detail::handle_fmt_ | ( | std::string & | fmt, |
const char * | length, | ||
char | spec, | ||
T | 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).
std::runtime_error | If there is a problem with the substitution, such as if the type specification or length specification does not match the data type passed in. |
T | The type of data to substitute with |
[in] | fmt | The format specifier without the length or type specifiers |
[in] | length | The length specifier |
[in] | spec | The type specifier |
[in] | subst | What to put in place of the specifier |
Definition at line 104 of file Printf_wrap.cpp.
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.
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.
void bpprint::detail::handle_fmt_single_ | ( | std::string & | fmt, |
T | 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.
std::runtime_error | If there is a problem with the substitution |
T | The type of data to substitute with |
[in,out] | fmt | String with a single format specifier. Will be replaced with the formatted string |
[in] | subst | What to put in place of the specifier |
Definition at line 67 of file Printf_wrap.cpp.