Jpp
JAbstractIO.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JABSTRACTIO__
2 #define __JLANG__JABSTRACTIO__
3 
4 #include <istream>
5 #include <ostream>
6 
7 
8 /**
9  * \author mdejong
10  */
11 
12 namespace JLANG {}
13 namespace JPP { using namespace JLANG; }
14 
15 namespace JLANG {
16 
17 
18  /**
19  * Interface for ASCII input using standard streams.
20  */
21  class JStreamInput {
22  public:
23  /**
24  * Virtual destructor.
25  */
26  virtual ~JStreamInput()
27  {}
28 
29 
30  /**
31  * Stream input.
32  *
33  * \param in input stream
34  * \return input stream
35  */
36  virtual std::istream& read(std::istream& in) = 0;
37 
38 
39  /**
40  * Read object from input.
41  *
42  * \param in input stream
43  * \param object object
44  * \return input stream
45  */
46  friend inline std::istream& operator>>(std::istream& in, JStreamInput& object)
47  {
48  return object.read(in);
49  }
50  };
51 
52 
53  /**
54  * Interface for ASCII output using standard streams.
55  */
56  class JStreamOutput {
57  public:
58  /**
59  * Virtual destructor.
60  */
61  virtual ~JStreamOutput()
62  {}
63 
64 
65  /**
66  * Stream output.
67  *
68  * \param out output stream
69  * \return output stream
70  */
71  virtual std::ostream& write(std::ostream& out) const = 0;
72 
73 
74  /**
75  * Write object to output.
76  *
77  * \param out output stream
78  * \param object object
79  * \return output stream
80  */
81  friend inline std::ostream& operator<<(std::ostream& out, const JStreamOutput& object)
82  {
83  return object.write(out);
84  }
85  };
86 
87 
88  /**
89  * Interface for ASCII output with prefix and postfix using standard streams.
90  */
92  public:
93  /**
94  * Virtual destructor.
95  */
97  {}
98 
99 
100  /**
101  * Stream output.
102  *
103  * \param out output stream
104  * \param prefix prefix
105  * \param postfix postfix
106  * \return output stream
107  */
108  virtual std::ostream& write(std::ostream& out,
109  const char* prefix,
110  const char postfix) const = 0;
111  };
112 }
113 
114 #endif
JLANG::JStreamSuffixOutput
Interface for ASCII output with prefix and postfix using standard streams.
Definition: JAbstractIO.hh:91
JLANG::JStreamInput::read
virtual std::istream & read(std::istream &in)=0
Stream input.
JLANG::JStreamOutput::operator<<
friend std::ostream & operator<<(std::ostream &out, const JStreamOutput &object)
Write object to output.
Definition: JAbstractIO.hh:81
JLANG::JStreamSuffixOutput::~JStreamSuffixOutput
virtual ~JStreamSuffixOutput()
Virtual destructor.
Definition: JAbstractIO.hh:96
JLANG::JStreamInput
Interface for ASCII input using standard streams.
Definition: JAbstractIO.hh:21
JLANG::JStreamOutput
Interface for ASCII output using standard streams.
Definition: JAbstractIO.hh:56
JLANG::JStreamInput::~JStreamInput
virtual ~JStreamInput()
Virtual destructor.
Definition: JAbstractIO.hh:26
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JLANG::JStreamOutput::write
virtual std::ostream & write(std::ostream &out) const =0
Stream output.
JLANG::JStreamSuffixOutput::write
virtual std::ostream & write(std::ostream &out, const char *prefix, const char postfix) const =0
Stream output.
JLANG
Auxiliary classes and methods for language specific functionality.
Definition: JAbstractClass.hh:10
JLANG::JStreamInput::operator>>
friend std::istream & operator>>(std::istream &in, JStreamInput &object)
Read object from input.
Definition: JAbstractIO.hh:46
JLANG::JStreamOutput::~JStreamOutput
virtual ~JStreamOutput()
Virtual destructor.
Definition: JAbstractIO.hh:61