Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
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. More...
 
void load ()
 Load data from file with name corresponding to current contents. More...
 

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

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  (*this) << in.rdbuf();
39  }
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
JStreamState(std::ostream &from, std::ostream &to)
Constructor.
Definition: JStreamState.hh:32

Member Function Documentation

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 48 of file JStringStream.hh.

49  {
50  using namespace std;
51 
52  ifstream in(this->str().c_str());
53 
54  if (in) {
55 
56  this->str(""); // reset
57 
58  (*this) << in.rdbuf(); // copy
59 
60  in.close();
61  }
62  }
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45

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