Jpp  18.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTemplateReader.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JTEMPLATEREADER__
2 #define __JLANG__JTEMPLATEREADER__
3 
4 #include "JLang/JNullType.hh"
5 #include "JLang/JTypeList.hh"
6 #include "JLang/JType.hh"
7 
8 
9 /**
10  * \author mdejong
11  */
12 
13 namespace JLANG {}
14 namespace JPP { using namespace JLANG; }
15 
16 namespace JLANG {
17 
18  /**
19  * Template definition of auxiliary base class for composite data types which derive
20  * from one or more base classes for which the redirect operator <tt><<</tt> is defined.
21  * The various specialisations of this class implement the redirect operator <tt><<</tt>
22  * for the derived class.
23  */
24  template<class JReader_t,
25  class JClass_t = JNullType,
26  class JTypelist_t = JNullType>
28 
29 
30  /**
31  * Specialisation of class JTemplateReader for general purpose write methods.
32  */
33  template<class JReader_t>
34  struct JTemplateReader<JReader_t, JNullType, JNullType>
35  {
36  protected:
37  /**
38  * Write method for single data types.
39  *
40  * \param in reader
41  * \param object object
42  * \param type type
43  * \return reader
44  */
45  template<class JClass_t>
46  static inline JReader_t& read(JReader_t& in,
47  JClass_t& object,
48  const JType <JNullType>& type)
49  {
50  return in >> object;
51  }
52 
53 
54  /**
55  * Read method for composite data types.
56  *
57  * \param in reader
58  * \param object object
59  * \param type type
60  * \return reader
61  */
62  template<class JClass_t, class JHead_t, class JTail_t>
63  static inline JReader_t& read(JReader_t& in,
64  JClass_t& object,
65  const JType<JTypeList<JHead_t, JTail_t> >& type)
66  {
67  in >> static_cast<JHead_t&>(object);
68 
69  return read(in, object, JType<JTail_t>());
70  }
71 
72 
73  /**
74  * Read method for composite data types.
75  *
76  * \param in reader
77  * \param object object
78  * \param type type
79  * \return reader
80  */
81  template<class JClass_t, class JHead_t>
82  static inline JReader_t& read(JReader_t& in,
83  JClass_t& object,
85  {
86  return in >> static_cast<JHead_t&>(object);
87  }
88  };
89 
90 
91  /**
92  * Specialisation of class JTemplateReader for composite data type.
93  *
94  * This class uses in-class friend operators (see Barton-Nackman trick).
95  */
96  template<class JReader_t, class JClass_t, class JHead_t, class JTail_t>
97  struct JTemplateReader<JReader_t, JClass_t, JTypeList<JHead_t, JTail_t> > :
98  public JTemplateReader<JReader_t>
99  {
100  /**
101  * Read operator.
102  *
103  * \param in reader
104  * \param object object
105  * \return true if first object is less than second object; else false
106  */
107  friend JReader_t& operator>>(JReader_t& in, JClass_t& object)
108  {
110  }
111  };
112 }
113 
114 #endif
Template definition of auxiliary base class for composite data types which derive from one or more ba...
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter= ' ')
Read test summary.
static JReader_t & read(JReader_t &in, JClass_t &object, const JType< JTypeList< JHead_t, JNullType > > &type)
Read method for composite data types.
Auxiliary class for a type holder.
Definition: JType.hh:19
Type list.
Definition: JTypeList.hh:22
Auxiliary class for no type definition.
Definition: JNullType.hh:19
static JReader_t & read(JReader_t &in, JClass_t &object, const JType< JTypeList< JHead_t, JTail_t > > &type)
Read method for composite data types.
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
static JReader_t & read(JReader_t &in, JClass_t &object, const JType< JNullType > &type)
Write method for single data types.
friend JReader_t & operator>>(JReader_t &in, JClass_t &object)
Read operator.