Jpp
software
JLang
JStreamState.hh
Go to the documentation of this file.
1
#ifndef __JLANG__JSTREAMSTATE__
2
#define __JLANG__JSTREAMSTATE__
3
4
#include <istream>
5
#include <ostream>
6
7
8
/**
9
* \author mdejong
10
*/
11
12
namespace
JLANG
{}
13
namespace
JPP
{
using namespace
JLANG
; }
14
15
namespace
JLANG
{
16
17
18
/**
19
* This class can be used to temporarily exchange the states between streams.
20
* The constructor transfers the state from the first stream to the second stream and
21
* the destructor transfers back the state from the second stream to the first stream.
22
*/
23
class
JStreamState
{
24
public
:
25
/**
26
* Constructor.
27
* The stream state of <tt>from</tt> is transfered to stream state of <tt>to</tt>.
28
*
29
* \param from output stream
30
* \param to output stream
31
*/
32
JStreamState
(std::ostream& from,
33
std::ostream& to) :
34
__from
(from),
35
__to
(to)
36
{
37
__to
.setstate(
__from
.rdstate());
38
}
39
40
41
/**
42
* Constructor.
43
* The stream state of <tt>from</tt> is transfered to stream state of <tt>to</tt>.
44
*
45
* \param from input stream
46
* \param to input stream
47
*/
48
JStreamState
(std::istream& from,
49
std::istream& to) :
50
__from
(from),
51
__to
(to)
52
{
53
__to
.setstate(
__from
.rdstate());
54
}
55
56
57
/**
58
* Destructor.
59
* The stream state is transfered back.
60
*/
61
~JStreamState
()
62
{
63
__from
.setstate(
__to
.rdstate());
64
}
65
66
private
:
67
std::ios&
__from
;
68
std::ios&
__to
;
69
};
70
}
71
72
#endif
JLANG::JStreamState
This class can be used to temporarily exchange the states between streams.
Definition:
JStreamState.hh:23
JLANG::JStreamState::~JStreamState
~JStreamState()
Destructor.
Definition:
JStreamState.hh:61
JLANG::JStreamState::__from
std::ios & __from
Definition:
JStreamState.hh:67
JLANG::JStreamState::__to
std::ios & __to
Definition:
JStreamState.hh:68
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition:
JAAnetToolkit.hh:37
JLANG::JStreamState::JStreamState
JStreamState(std::istream &from, std::istream &to)
Constructor.
Definition:
JStreamState.hh:48
JLANG
Auxiliary classes and methods for language specific functionality.
Definition:
JAbstractClass.hh:10
JLANG::JStreamState::JStreamState
JStreamState(std::ostream &from, std::ostream &to)
Constructor.
Definition:
JStreamState.hh:32
Generated by
1.8.16