Jpp  17.1.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JStringStream.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JSTRINGSTREAM__
2 #define __JLANG__JSTRINGSTREAM__
3 
4 #include <sstream>
5 #include <fstream>
6 
7 #include "JLang/JStreamState.hh"
8 
9 
10 /**
11  * \author mdejong
12  */
13 
14 namespace JLANG {}
15 namespace JPP { using namespace JLANG; }
16 
17 namespace JLANG {
18 
19  /**
20  * Wrapper class around STL stringstream class to facilitate optional loading of data from file.
21  */
22  class JStringStream :
23  public std::stringstream,
24  public JStreamState
25  {
26  public:
27  /**
28  * Constructor.
29  *
30  * This constructor loads all data from given input stream.
31  *
32  * \param in input stream
33  */
34  JStringStream(std::istream& in) :
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  }
46 
47 
48  /**
49  * Load data from file with name corresponding to current contents.
50  *
51  * Note that if the file exists but is empty,
52  * the state of the stream is set to fail by C++ standard.
53  */
54  void load()
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  }
69  };
70 }
71 
72 #endif
void load()
Load data from file with name corresponding to current contents.
This class can be used to temporarily exchange the states between streams.
Definition: JStreamState.hh:23
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison nIn this
JStringStream(std::istream &in)
Constructor.
Wrapper class around STL stringstream class to facilitate optional loading of data from file...
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] 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:46