Jpp  16.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
JLANG::JRedirectStream Class Reference

This class can be used to temporarily redirect one output (input) stream to another output (input) stream. More...

#include <JRedirectStream.hh>

Inheritance diagram for JLANG::JRedirectStream:
JLANG::JAbstractObjectStatus

Public Member Functions

 JRedirectStream (std::ostream &from, std::ostream &to)
 Constructor. More...
 
 JRedirectStream (std::istream &from, std::istream &to)
 Constructor. More...
 
 ~JRedirectStream ()
 Destructor. More...
 
virtual bool getStatus () const override
 Get status of object. More...
 
 operator bool () const
 Type conversion operator. More...
 
bool operator! () const
 Negated status of this object. More...
 

Private Attributes

std::ios & ios
 
std::streambuf * p
 

Detailed Description

This class can be used to temporarily redirect one output (input) stream to another output (input) stream.

The destructor restores the internal buffer of the first output (input) stream.

Definition at line 24 of file JRedirectStream.hh.

Constructor & Destructor Documentation

JLANG::JRedirectStream::JRedirectStream ( std::ostream &  from,
std::ostream &  to 
)
inline

Constructor.

The output stream from is redirected to output stream to.

Parameters
fromoutput stream
tooutput stream

Definition at line 35 of file JRedirectStream.hh.

36  :
37  ios(from)
38  {
39  p = ios.rdbuf();
40 
41  ios.rdbuf(to.rdbuf());
42  }
JLANG::JRedirectStream::JRedirectStream ( std::istream &  from,
std::istream &  to 
)
inline

Constructor.

The input stream from is redirected to input stream to.

Parameters
frominput stream
toinput stream

Definition at line 52 of file JRedirectStream.hh.

53  :
54  ios(from)
55  {
56  p = ios.rdbuf();
57 
58  ios.rdbuf(to.rdbuf());
59  }
JLANG::JRedirectStream::~JRedirectStream ( )
inline

Destructor.

Restore internal buffer.

Definition at line 66 of file JRedirectStream.hh.

67  {
68  ios.rdbuf(p);
69  }

Member Function Documentation

virtual bool JLANG::JRedirectStream::getStatus ( ) const
inlineoverridevirtual

Get status of object.

Returns
true

Implements JLANG::JAbstractObjectStatus.

Definition at line 77 of file JRedirectStream.hh.

78  {
79  return true;
80  }
JLANG::JAbstractObjectStatus::operator bool ( ) const
inlineinherited

Type conversion operator.

Returns
status of this object

Definition at line 33 of file JAbstractObjectStatus.hh.

34  {
35  return this->getStatus();
36  }
virtual bool getStatus() const =0
Get status of object.
bool JLANG::JAbstractObjectStatus::operator! ( ) const
inlineinherited

Negated status of this object.

Returns
negated status of this object

Definition at line 44 of file JAbstractObjectStatus.hh.

45  {
46  return !(this->getStatus());
47  }
virtual bool getStatus() const =0
Get status of object.

Member Data Documentation

std::ios& JLANG::JRedirectStream::ios
private

Definition at line 83 of file JRedirectStream.hh.

std::streambuf* JLANG::JRedirectStream::p
private

Definition at line 84 of file JRedirectStream.hh.


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