Jpp  18.6.0-rc.1
the software that should make you happy
 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  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.
Definition: JStreamState.hh:32
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48

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 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  }
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48

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