Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
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
12namespace JLANG {}
13namespace JPP { using namespace JLANG; }
14
15namespace 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 */
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 */
62 {
63 __from.setstate(__to.rdstate());
64 }
65
66 private:
67 std::ios& __from;
68 std::ios& __to;
69
74 };
75}
76
77#endif
This class can be used to temporarily exchange the states between streams.
JStreamState(JStreamState &&)
JStreamState(std::istream &from, std::istream &to)
Constructor.
JStreamState & operator=(const JStreamState &)
~JStreamState()
Destructor.
JStreamState(const JStreamState &)
JStreamState & operator=(JStreamState &&)
JStreamState(std::ostream &from, std::ostream &to)
Constructor.
Auxiliary classes and methods for language specific functionality.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).