ReFRACtor
|
This is a Mixin for classes that can be printed. More...
#include <printable.h>
Public Member Functions | |
std::string | print_to_string () const |
Print to string. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &Os, const T &P) |
Print to stream. More... | |
This is a Mixin for classes that can be printed.
There are two different functions we want to use for printing. For normal C++ use, we want the usual "<<" notation, e.g., cout << foo. For use with languages such as Ruby that don't have a native stream type, we want to "print_to_string()", which returns a string that Ruby can directly work with.
We implement both of these functions in terms of a third function, "print(ostream& Os)".
Classes T that want to be printable in both C++ and other languages should derive from Printable<T>, and then define print(ostream& Os).
Definition at line 24 of file printable.h.
|
inline |
Print to string.
This is primarily useful for SWIG wrappers to this class, e.g. a to_s method in ruby.
Definition at line 31 of file printable.h.
|
friend |
Print to stream.
Definition at line 52 of file printable.h.