Jpp
pmt_effective_area_update
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JLang
JRedirectString.hh
Go to the documentation of this file.
1
#ifndef __JLANG__JREDIRECTSTRING__
2
#define __JLANG__JREDIRECTSTRING__
3
4
#include <istream>
5
#include <ostream>
6
#include <string>
7
#include <sstream>
8
9
#include "
JLang/JAbstractObjectStatus.hh
"
10
11
12
/**
13
* \author mdejong
14
*/
15
16
namespace
JLANG {}
17
namespace
JPP {
using namespace
JLANG; }
18
19
namespace
JLANG {
20
21
22
/**
23
* This class can be used to temporarily redirect an input stream to an input string.
24
* The destructor restores the internal buffer of the input stream.
25
*/
26
class
JRedirectString
:
27
public
JAbstractObjectStatus
28
{
29
public
:
30
/**
31
* Constructor.
32
* The input stream is redirected to the given input string.
33
*
34
* \param is input stream
35
* \param buffer input string
36
*/
37
JRedirectString
(std::istream&
is
,
const
std::string& buffer) :
38
ios
(is)
39
{
40
p
=
ios
.rdbuf(
new
std::stringbuf(buffer));
41
}
42
43
44
/**
45
* Destructor.
46
* Restore internal buffer and delete temporary buffer.
47
*/
48
~JRedirectString
()
49
{
50
delete
ios
.rdbuf(
p
);
51
}
52
53
54
/**
55
* Get status of object.
56
*
57
* \return true
58
*/
59
virtual
bool
getStatus
()
const override
60
{
61
return
true
;
62
}
63
64
private
:
65
std::ios&
ios
;
66
std::streambuf*
p
;
67
};
68
}
69
70
#endif
JLANG::JRedirectString::p
std::streambuf * p
Definition:
JRedirectString.hh:66
is
is
Definition:
JDAQCHSM.chsm:167
JLANG::JRedirectString::JRedirectString
JRedirectString(std::istream &is, const std::string &buffer)
Constructor.
Definition:
JRedirectString.hh:37
JLANG::JRedirectString::ios
std::ios & ios
Definition:
JRedirectString.hh:65
JLANG::JRedirectString::~JRedirectString
~JRedirectString()
Destructor.
Definition:
JRedirectString.hh:48
JLANG::JAbstractObjectStatus
Interface for status of object.
Definition:
JAbstractObjectStatus.hh:19
JLANG::JRedirectString
This class can be used to temporarily redirect an input stream to an input string.
Definition:
JRedirectString.hh:26
JAbstractObjectStatus.hh
JLANG::JRedirectString::getStatus
virtual bool getStatus() const override
Get status of object.
Definition:
JRedirectString.hh:59
Generated by
1.8.5