#ifndef __JLANG__JTEMPLATEREADER__
#define __JLANG__JTEMPLATEREADER__
#include "JLang/JNullType.hh"
#include "JLang/JTypeList.hh"
#include "JLang/JType.hh"
/**
* \author mdejong
*/
namespace JLANG {}
namespace JPP { using namespace JLANG; }
namespace JLANG {
/**
* Template definition of auxiliary base class for composite data types which derive
* from one or more base classes for which the redirect operator << is defined.
* The various specialisations of this class implement the redirect operator <<
* for the derived class.
*/
template
struct JTemplateReader;
/**
* Specialisation of class JTemplateReader for general purpose write methods.
*/
template
struct JTemplateReader
{
protected:
/**
* Write method for single data types.
*
* \param in reader
* \param object object
* \param type type
* \return reader
*/
template
static inline JReader_t& read(JReader_t& in,
JClass_t& object,
const JType & type)
{
return in >> object;
}
/**
* Read method for composite data types.
*
* \param in reader
* \param object object
* \param type type
* \return reader
*/
template
static inline JReader_t& read(JReader_t& in,
JClass_t& object,
const JType >& type)
{
in >> static_cast(object);
return read(in, object, JType());
}
/**
* Read method for composite data types.
*
* \param in reader
* \param object object
* \param type type
* \return reader
*/
template
static inline JReader_t& read(JReader_t& in,
JClass_t& object,
const JType >& type)
{
return in >> static_cast(object);
}
};
/**
* Specialisation of class JTemplateReader for composite data type.
*
* This class uses in-class friend operators (see Barton-Nackman trick).
*/
template
struct JTemplateReader > :
public JTemplateReader
{
/**
* Read operator.
*
* \param in reader
* \param object object
* \return true if first object is less than second object; else false
*/
friend JReader_t& operator>>(JReader_t& in, JClass_t& object)
{
return JTemplateReader::read(in, object, JType< JTypeList >());
}
};
}
#endif