ReFRACtor
FullPhysics::Printable< T > Class Template Reference

This is a Mixin for classes that can be printed. More...

#include <printable.h>

+ Inheritance diagram for FullPhysics::Printable< T >:
+ Collaboration diagram for FullPhysics::Printable< T >:

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...
 

Detailed Description

template<class T>
class FullPhysics::Printable< T >

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.

Member Function Documentation

◆ print_to_string()

template<class T>
std::string FullPhysics::Printable< T >::print_to_string ( ) const
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.

Friends And Related Function Documentation

◆ operator<<

template<class T>
std::ostream& operator<< ( std::ostream &  Os,
const T &  P 
)
friend

Print to stream.

Definition at line 52 of file printable.h.


The documentation for this class was generated from the following file:

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:13