#include <Formatter.h>
Inheritance diagram for oasys::Formatter:
The modification implements a special control code combination of '*p' that triggers a call to Formatter::format(), called on the object pointer passed in the vararg list.
For example:
class FormatterTest : public Formatter { public: virtual int format(char* buf, size_t sz) { return snprintf(buf, sz, "FormatterTest"); } }; FormatterTest f; char buf[256]; snprintf(buf, sizeof(buf), "pointer %p, format *%p\n"); // buf contains "pointer 0xabcd1234, format FormatterTest\n"
Definition at line 74 of file Formatter.h.
Public Member Functions | |
virtual int | format (char *buf, size_t sz) const =0 |
Virtual callback, called from this vsnprintf implementation whenever it encounters a format string of the form "*%p". | |
int | debug_dump () |
Print out to a statically allocated buffer which can be called from gdb. | |
virtual | ~Formatter () |
Formatter () | |
Formatter (const Formatter &) | |
Static Public Member Functions | |
static void | assert_valid (const Formatter *obj) |
Assertion check to make sure that obj is a valid formatter. | |
Public Attributes | |
unsigned int | format_magic_ |
virtual oasys::Formatter::~Formatter | ( | ) | [inline, virtual] |
Definition at line 106 of file Formatter.h.
oasys::Formatter::Formatter | ( | ) | [inline] |
Definition at line 110 of file Formatter.h.
oasys::Formatter::Formatter | ( | const Formatter & | ) | [inline] |
Definition at line 111 of file Formatter.h.
virtual int oasys::Formatter::format | ( | char * | buf, | |
size_t | sz | |||
) | const [pure virtual] |
Virtual callback, called from this vsnprintf implementation whenever it encounters a format string of the form "*%p".
The output routine must not write more than sz bytes and is not null terminated.
Implemented in oasys::IntShim, oasys::UIntShim, oasys::StringShim, oasys::NullStringShim, oasys::ByteBufShim, oasys::RefCountedObject, oasys::SparseBitmap< _inttype_t >, dtn::Bundle, dtn::Contact, dtn::Link, and dtn::RouteEntry.
void oasys::Formatter::assert_valid | ( | const Formatter * | obj | ) | [inline, static] |
Assertion check to make sure that obj is a valid formatter.
This basically just makes sure that in any multiple inheritance situation where each base class has virtual functions, Formatter _must_ be the first class in the inheritance chain.
Definition at line 124 of file Formatter.h.
References oasys::__log_assert(), FORMAT_MAGIC, and format_magic_.
int oasys::Formatter::debug_dump | ( | ) |
Print out to a statically allocated buffer which can be called from gdb.
Note: must not be inlined in order for gdb to be able to execute this function.
unsigned int oasys::Formatter::format_magic_ |