Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JLANG::JStringStream Class Reference

Wrapper class around STL stringstream class to facilitate optional loading of data from file. More...

#include <JStringStream.hh>

Inheritance diagram for JLANG::JStringStream:
JLANG::JStreamState

Public Member Functions

 JStringStream (std::istream &in)
 Constructor.
 
void load ()
 Load data from file with name corresponding to current contents.
 

Private Attributes

std::ios & __from
 
std::ios & __to
 

Detailed Description

Wrapper class around STL stringstream class to facilitate optional loading of data from file.

Definition at line 22 of file JStringStream.hh.

Constructor & Destructor Documentation

◆ JStringStream()

JLANG::JStringStream::JStringStream ( std::istream & in)
inline

Constructor.

This constructor loads all data from given input stream.

Parameters
ininput stream

Definition at line 34 of file JStringStream.hh.

34 :
35 std::stringstream(),
36 JStreamState(in, static_cast<std::istream&>(*this))
37 {
38 using namespace std;
39
40 istream::sentry sentry(in); // skips white spaces
41
42 if (sentry) {
43 (*this) << in.rdbuf();
44 }
45 }
JStreamState(std::ostream &from, std::ostream &to)
Constructor.

Member Function Documentation

◆ load()

void JLANG::JStringStream::load ( )
inline

Load data from file with name corresponding to current contents.

Note that if the file exists but is empty, the state of the stream is set to fail by C++ standard.

Definition at line 54 of file JStringStream.hh.

55 {
56 using namespace std;
57
58 ifstream in(this->str().c_str());
59
60 if (in) {
61
62 this->str(""); // reset
63
64 (*this) << in.rdbuf(); // copy
65
66 in.close();
67 }
68 }

Member Data Documentation

◆ __from

std::ios& JLANG::JStreamState::__from
privateinherited

Definition at line 67 of file JStreamState.hh.

◆ __to

std::ios& JLANG::JStreamState::__to
privateinherited

Definition at line 68 of file JStreamState.hh.


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