#ifndef __JLANG__JSTDOBJECTREADER__ #define __JLANG__JSTDOBJECTREADER__ #include "JLang/JObjectReader.hh" #include "JLang/JSTDObjectIterator.hh" /** * \author mdejong */ namespace JLANG {} namespace JPP { using namespace JLANG; } namespace JLANG { /** * Implementation of object iteration from STD container. * * This class implements the JLANG::JRewindableObjectIterator interface. */ template struct JSTDObjectReader : public virtual JRewindableObjectIterator, public JRewindableObjectReader { typedef typename JRewindableObjectReader::pointer_type pointer_type; /** * Default constructor. */ JSTDObjectReader() {} /** * Constructor. * * \param buffer input buffer */ template JSTDObjectReader(JContainer_t& buffer) { this->reset(new JSTDObjectIterator(buffer.begin(), buffer.end())); } /** * Set input buffer. * * \param buffer input buffer */ template void set(JContainer_t& buffer) { this->reset(new JSTDObjectIterator(buffer.begin(), buffer.end())); } }; /** * Implementation of object iteration from STD container for multiple data types. * * This class recursively implements the JLANG::JRewindableObjectIterator interface * for all data types by deriving from: * - JSTDObjectReader; and * - JSTDObjectReader. */ template struct JSTDObjectReader< JTypeList > : public virtual JRewindableObjectIterator< JTypeList >, public JSTDObjectReader, public JSTDObjectReader { using JSTDObjectReader::reset; using JSTDObjectReader::reset; /** * Set input buffer. * * \param buffer input buffer */ template void set(JContainer_t& buffer) { this->reset(new JSTDObjectIterator(buffer.begin(), buffer.end())); } /** * Rewind. */ virtual void rewind() override { JSTDObjectReader::rewind(); JSTDObjectReader::rewind(); } }; /** * Terminator class of recursive JSTDObjectReader class. */ template struct JSTDObjectReader< JTypeList > : public JSTDObjectReader {}; /** * Specialisation of object iteration from STD container for constant data. */ template struct JSTDObjectReader : public JRewindableObjectReader { typedef typename JRewindableObjectReader::pointer_type pointer_type; /** * Default constructor. */ JSTDObjectReader() {} /** * Constructor. * * \param buffer input buffer */ template JSTDObjectReader(const JContainer_t& buffer) { this->reset(new JSTDObjectIterator(buffer.begin(), buffer.end())); } /** * Set input buffer. * * \param buffer buffer buffer */ template void set(const JContainer_t& buffer) { this->reset(new JSTDObjectIterator(buffer.begin(), buffer.end())); } }; } #endif