#ifndef __JLANG__JSTDOBJECTWRITER__ #define __JLANG__JSTDOBJECTWRITER__ #include "JLang/JObjectWriter.hh" #include "JLang/JSTDObjectOutput.hh" /** * \author mdejong */ namespace JLANG {} namespace JPP { using namespace JLANG; } namespace JLANG { /** * Implementation of object output from STD container. * * This class implements the JObjectOutput interface. */ template class JSTDObjectWriter : public virtual JObjectOutput, public JObjectWriter { public: /** * Default constructor. */ JSTDObjectWriter() {} /** * Constructor. * * \param out output iterator */ template JSTDObjectWriter(const JSTDObjectOutput& out) { this->reset(out.clone()); } /** * Constructor. * * \param buffer output buffer */ template JSTDObjectWriter(JContainer_t& buffer) { this->reset(getObjectOutput(buffer).clone()); } /** * Set output buffer. * * \param buffer output buffer */ template void set(JContainer_t& buffer) { this->reset(getObjectOutput(buffer).clone()); } }; /** * Implementation of object output from STD container for multiple data types. * * This class recursively implements the JLANG::JObjectOutput interface * for all data types by deriving from: * - JSTDObjectWriter; and * - JSTDObjectWriter. */ template struct JSTDObjectWriter< JTypeList > : public virtual JObjectOutput< JTypeList >, public JSTDObjectWriter, public JSTDObjectWriter { using JSTDObjectWriter::put; using JSTDObjectWriter::put; using JSTDObjectWriter::reset; using JSTDObjectWriter::reset; /** * Set output puffer. * * \param buffer output buffer */ template void set(JContainer_t& buffer) { this->reset(getObjectOutput(buffer).clone()); } }; /** * Terminator class of recursive JSTDObjectWriter class. */ template struct JSTDObjectWriter< JTypeList > : public JSTDObjectWriter {}; } #endif