xdrpp
RFC4506 XDR compiler and message library
Namespaces | Macros | Functions
printer.h File Reference

Support for pretty-printing XDR data types. More...

#include <sstream>
#include <xdrpp/types.h>
Include dependency graph for printer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 xdr
 Most of the xdrpp library is encapsulated in the xdr namespace.
 

Macros

#define ENABLE_IF(expr)   typename std::enable_if<expr>::type
 Poor man's version of C++14 enable_if_t.
 

Functions

std::string xdr::escape_string (const std::string &s)
 Use hex escapes for non-printable characters, and prefix backslashes and quotes with backslash. More...
 
std::string xdr::hexdump (const void *data, size_t len)
 Turn a string into a double-length sequence of hex nibbles.
 
template<typename T >
std::string xdr::xdr_to_string (const T &t, const char *name=nullptr, int indent=0)
 Return a std::string containing a pretty-printed version an XDR data type. More...
 
template<typename T >
std::enable_if< xdr_traits< T >::valid, std::ostream & >::type xdr::operator<< (std::ostream &os, const T &t)
 Print an arbitrary XDR structure to a std::ostream. More...
 

Detailed Description

Support for pretty-printing XDR data types.

Function xdr::xdr_to_string converts an arbitrary XDR data type to a string. In addition, if you say using xdr::operator<<;, you can use the standard operator<< to print XDR types.

You can customize how a particular user-defined type T gets printed by defining a function std::string xdr_printer(const T&) in the same namespace as T.

Definition in file printer.h.