libMesh
Public Types | Public Member Functions | Private Attributes | List of all members
libMesh::BasicOStreamProxy< charT, traits > Class Template Reference

This class is intended to be reseatable like a pointer-to-ostream for flexibility, but to look like a reference when used to produce less awkward user code. More...

#include <ostream_proxy.h>

Public Types

typedef std::basic_ostream< charT, traits > streamT
 This class is going to be used to proxy for ostream, but other character and traits types are possible. More...
 
typedef std::basic_streambuf< charT, traits > streambufT
 This class is going to be used to proxy for ostream, but other character and traits types are possible. More...
 

Public Member Functions

 BasicOStreamProxy (streamT &target)
 Default constructor. More...
 
 BasicOStreamProxy (BasicOStreamProxy &old)
 Shallow copy constructor. More...
 
BasicOStreamProxyoperator= (streamT &target)
 Reset the internal target to a new target output stream. More...
 
BasicOStreamProxyoperator= (const BasicOStreamProxy &old)
 Reset the target to the same output stream as in old. More...
 
 ~BasicOStreamProxy ()
 Default destructor. More...
 
 operator streamT & ()
 Conversion to ostream &, for when we get passed to a function requesting one. More...
 
 operator const streamT & () const
 Conversion to const ostream &, for when we get passed to a function requesting one. More...
 
template<typename T >
BasicOStreamProxyoperator<< (const T &in)
 Redirect any output to the target. More...
 
BasicOStreamProxyoperator<< (streamT &(*in)(streamT &))
 Redirect any ostream manipulators to the target. More...
 
BasicOStreamProxyoperator<< (std::basic_ios< charT, traits > &(*in)(std::basic_ios< charT, traits > &))
 Redirect any ios manipulators to the target. More...
 
BasicOStreamProxyoperator<< (std::ios_base &(*in)(std::ios_base &))
 Redirect any ios_base manipulators to the target. More...
 
streambufTrdbuf () const
 Get the associated stream buffer. More...
 
streambufTrdbuf (streambufT *sb)
 Set the associated stream buffer. More...
 
BasicOStreamProxyflush ()
 Flush the associated stream buffer. More...
 
std::ios_base::fmtflags flags () const
 Get the associated format flags. More...
 
std::ios_base::fmtflags flags (std::ios_base::fmtflags fmtfl)
 Set/get the associated format flags. More...
 
std::ios_base::fmtflags setf (std::ios_base::fmtflags fmtfl)
 Set the associated flags. More...
 
std::ios_base::fmtflags setf (std::ios_base::fmtflags fmtfl, std::ios_base::fmtflags mask)
 Set the associated flags. More...
 
void unsetf (std::ios_base::fmtflags mask)
 Clear the associated flags. More...
 
std::streamsize precision () const
 Get the associated write precision. More...
 
std::streamsize precision (std::streamsize prec)
 Set the associated write precision. More...
 
void reset (streamT &target)
 Reset the proxy to point to a different target. More...
 
streamTget ()
 Rather than implement every ostream/ios/ios_base function, we'll be lazy and make esoteric uses go through a get() function. More...
 
const streamTget () const
 Rather than implement every ostream/ios/ios_base function, we'll be lazy and make esoteric uses go through a get() function. More...
 

Private Attributes

streamT_target
 The pointer to the "real" ostream we send everything to. More...
 

Detailed Description

template<typename charT = char, typename traits = std::char_traits<charT>>
class libMesh::BasicOStreamProxy< charT, traits >

This class is intended to be reseatable like a pointer-to-ostream for flexibility, but to look like a reference when used to produce less awkward user code.

It is up to the user to ensure that the target ostream remains valid.

Author
Roy Stogner
Date
2010

Definition at line 42 of file ostream_proxy.h.

Member Typedef Documentation

template<typename charT = char, typename traits = std::char_traits<charT>>
typedef std::basic_streambuf<charT,traits> libMesh::BasicOStreamProxy< charT, traits >::streambufT

This class is going to be used to proxy for ostream, but other character and traits types are possible.

Definition at line 55 of file ostream_proxy.h.

template<typename charT = char, typename traits = std::char_traits<charT>>
typedef std::basic_ostream<charT,traits> libMesh::BasicOStreamProxy< charT, traits >::streamT

This class is going to be used to proxy for ostream, but other character and traits types are possible.

Definition at line 49 of file ostream_proxy.h.

Constructor & Destructor Documentation

template<typename charT = char, typename traits = std::char_traits<charT>>
libMesh::BasicOStreamProxy< charT, traits >::BasicOStreamProxy ( streamT target)

Default constructor.

Takes a reference to the target ostream to which we pass output. The user is responsible for ensuring that this target exists for as long as the proxy does.

Definition at line 62 of file ostream_proxy.h.

62 : _target(&target) {}
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
libMesh::BasicOStreamProxy< charT, traits >::BasicOStreamProxy ( BasicOStreamProxy< charT, traits > &  old)

Shallow copy constructor.

Output in the new object is passed to the same target ostream as in the old object. The user is responsible for ensuring that this target exists for as long as the proxies do.

Definition at line 70 of file ostream_proxy.h.

70 : _target(old._target) {}
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
libMesh::BasicOStreamProxy< charT, traits >::~BasicOStreamProxy ( )

Default destructor.

Definition at line 93 of file ostream_proxy.h.

93 {}

Member Function Documentation

template<typename charT = char, typename traits = std::char_traits<charT>>
std::ios_base::fmtflags libMesh::BasicOStreamProxy< charT, traits >::flags ( ) const

Get the associated format flags.

Definition at line 158 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

Referenced by main().

159  { return _target->flags(); }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
std::ios_base::fmtflags libMesh::BasicOStreamProxy< charT, traits >::flags ( std::ios_base::fmtflags  fmtfl)

Set/get the associated format flags.

Definition at line 164 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

165  { return _target->flags(fmtfl); }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
BasicOStreamProxy& libMesh::BasicOStreamProxy< charT, traits >::flush ( )

Flush the associated stream buffer.

Definition at line 153 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

Referenced by assemble_ellipticdg(), and libMesh::PltLoader::read_data().

153 { _target->flush(); return *this; }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
streamT* libMesh::BasicOStreamProxy< charT, traits >::get ( )

Rather than implement every ostream/ios/ios_base function, we'll be lazy and make esoteric uses go through a get() function.

Definition at line 213 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

Referenced by libMesh::LibMeshInit::LibMeshInit().

213  {
214  return _target;
215  }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
const streamT* libMesh::BasicOStreamProxy< charT, traits >::get ( ) const

Rather than implement every ostream/ios/ios_base function, we'll be lazy and make esoteric uses go through a get() function.

Definition at line 221 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

221  {
222  return _target;
223  }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
libMesh::BasicOStreamProxy< charT, traits >::operator const streamT & ( ) const

Conversion to const ostream &, for when we get passed to a function requesting one.

Definition at line 109 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

109 { return *_target; }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
libMesh::BasicOStreamProxy< charT, traits >::operator streamT & ( )

Conversion to ostream &, for when we get passed to a function requesting one.

Definition at line 103 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

103 { return *_target; }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
template<typename T >
BasicOStreamProxy& libMesh::BasicOStreamProxy< charT, traits >::operator<< ( const T &  in)

Redirect any output to the target.

Definition at line 115 of file ostream_proxy.h.

115  {
116  (*_target) << in; return *this;
117  }
template<typename charT = char, typename traits = std::char_traits<charT>>
BasicOStreamProxy& libMesh::BasicOStreamProxy< charT, traits >::operator<< ( streamT &(*)(streamT &)  in)

Redirect any ostream manipulators to the target.

Definition at line 122 of file ostream_proxy.h.

122  {
123  (*_target) << in; return *this;
124  }
template<typename charT = char, typename traits = std::char_traits<charT>>
BasicOStreamProxy& libMesh::BasicOStreamProxy< charT, traits >::operator<< ( std::basic_ios< charT, traits > &(*)(std::basic_ios< charT, traits > &)  in)

Redirect any ios manipulators to the target.

Definition at line 129 of file ostream_proxy.h.

129  {
130  (*_target) << in; return *this;
131  }
template<typename charT = char, typename traits = std::char_traits<charT>>
BasicOStreamProxy& libMesh::BasicOStreamProxy< charT, traits >::operator<< ( std::ios_base &(*)(std::ios_base &)  in)

Redirect any ios_base manipulators to the target.

Definition at line 136 of file ostream_proxy.h.

136  {
137  (*_target) << in; return *this;
138  }
template<typename charT = char, typename traits = std::char_traits<charT>>
BasicOStreamProxy& libMesh::BasicOStreamProxy< charT, traits >::operator= ( streamT target)

Reset the internal target to a new target output stream.

Definition at line 75 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

76  {
77  _target = &target;
78  return *this;
79  }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
BasicOStreamProxy& libMesh::BasicOStreamProxy< charT, traits >::operator= ( const BasicOStreamProxy< charT, traits > &  old)

Reset the target to the same output stream as in old.

Definition at line 84 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

85  {
86  _target = old._target;
87  return *this;
88  }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
std::streamsize libMesh::BasicOStreamProxy< charT, traits >::precision ( ) const

Get the associated write precision.

Definition at line 189 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

Referenced by libMesh::FEMSystem::assembly(), libMesh::ContinuationSystem::continuation_solve(), main(), and libMesh::ContinuationSystem::update_solution().

190  { return _target->precision(); }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
std::streamsize libMesh::BasicOStreamProxy< charT, traits >::precision ( std::streamsize  prec)

Set the associated write precision.

Definition at line 195 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

196  { return _target->precision(prec); }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
streambufT* libMesh::BasicOStreamProxy< charT, traits >::rdbuf ( ) const

Get the associated stream buffer.

Definition at line 143 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

Referenced by libMesh::LibMeshInit::LibMeshInit(), StreamRedirector::StreamRedirector(), and StreamRedirector::~StreamRedirector().

143 { return _target->rdbuf(); }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
streambufT* libMesh::BasicOStreamProxy< charT, traits >::rdbuf ( streambufT sb)

Set the associated stream buffer.

Definition at line 148 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

148 { return _target->rdbuf(sb); }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
void libMesh::BasicOStreamProxy< charT, traits >::reset ( streamT target)

Reset the proxy to point to a different target.

Note
This does not delete the previous target.

Definition at line 207 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

Referenced by libMesh::LibMeshInit::LibMeshInit().

207 { _target = &target; }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
std::ios_base::fmtflags libMesh::BasicOStreamProxy< charT, traits >::setf ( std::ios_base::fmtflags  fmtfl)

Set the associated flags.

Definition at line 170 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

Referenced by libMesh::ContinuationSystem::continuation_solve(), and libMesh::ContinuationSystem::update_solution().

171  { return _target->setf(fmtfl); }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
std::ios_base::fmtflags libMesh::BasicOStreamProxy< charT, traits >::setf ( std::ios_base::fmtflags  fmtfl,
std::ios_base::fmtflags  mask 
)

Set the associated flags.

Definition at line 176 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

178  { return _target->setf(fmtfl, mask); }
streamT * _target
The pointer to the "real" ostream we send everything to.
template<typename charT = char, typename traits = std::char_traits<charT>>
void libMesh::BasicOStreamProxy< charT, traits >::unsetf ( std::ios_base::fmtflags  mask)

Clear the associated flags.

Definition at line 183 of file ostream_proxy.h.

References libMesh::BasicOStreamProxy< charT, traits >::_target.

Referenced by libMesh::ContinuationSystem::continuation_solve(), and libMesh::ContinuationSystem::update_solution().

184  { _target->unsetf(mask); }
streamT * _target
The pointer to the "real" ostream we send everything to.

Member Data Documentation

template<typename charT = char, typename traits = std::char_traits<charT>>
streamT* libMesh::BasicOStreamProxy< charT, traits >::_target
private

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