#ifndef __JLANG__JSTDOBJECTOUTPUT__ #define __JLANG__JSTDOBJECTOUTPUT__ #include #include "JLang/JObjectOutput.hh" #include "JLang/JObject.hh" #include "JLang/JSTDTypes.hh" /** * \author mdejong */ namespace JLANG {} namespace JPP { using namespace JLANG; } namespace JLANG { /** * Implementation of object output for STD compatible output iterator. * * This class implements the JLANG::JObjectOutput interface for the corresponding data type. */ template class JSTDObjectOutput : public JObjectOutput, public JObject< JSTDObjectOutput > { public: typedef typename JOutputIterator_t::container_type::value_type value_type; /** * Constructor. * * \param out output iterator */ JSTDObjectOutput(const JOutputIterator_t& out) : out(out) {} /** * Object output. * * \param object object * \return true */ virtual bool put(const value_type& object) override { *out = object; ++out; return true; } protected: JOutputIterator_t out; }; /** * Helper method to create STD compatible object output. * * \param buffer output buffer * \return object output */ template inline JSTDObjectOutput > > getObjectOutput(std::vector& buffer) { return JSTDObjectOutput > >(std::back_inserter(buffer)); } /** * Helper method to create STD compatible object output. * * \param buffer output buffer * \return object output */ template inline JSTDObjectOutput > > getObjectOutput(std::list& buffer) { return JSTDObjectOutput > >(std::back_inserter(buffer)); } /** * Helper method to create STD compatible object output. * * \param buffer output buffer * \return object output */ template inline JSTDObjectOutput > > getObjectOutput(std::set& buffer) { return JSTDObjectOutput > >(std::inserter(buffer, buffer.end())); } /** * Helper method to create STD compatible object output. * * \param buffer output buffer * \return object output */ template inline JSTDObjectOutput > > getObjectOutput(std::multiset& buffer) { return JSTDObjectOutput > >(std::inserter(buffer, buffer.end())); } /** * Helper method to create STD compatible object output. * * \param buffer output buffer * \return object output */ template inline JSTDObjectOutput > > getObjectOutput(std::map& buffer) { return JSTDObjectOutput > >(std::inserter(buffer, buffer.end())); } /** * Helper method to create STD compatible object output. * * \param buffer output buffer * \return object output */ template inline JSTDObjectOutput > > getObjectOutput(std::multimap& buffer) { return JSTDObjectOutput > >(std::inserter(buffer, buffer.end())); } } #endif