#ifndef __JEEP__JCONTAINER__ #define __JEEP__JCONTAINER__ #include #include #include #include #include "JSystem/JStat.hh" #include "JLang/JObjectStreamIO.hh" #include "JLang/JStringStream.hh" #include "Jeep/JComment.hh" #include "Jeep/JStreamToolkit.hh" /** * \file * * Container I/O. * \author mdejong */ namespace JEEP {} namespace JPP { using namespace JEEP; } namespace JEEP { using JLANG::JObjectStreamIO; /** * Auxiliary wrapper for I/O of container with optional comment (see JComment). * * When used in conjunction with the command line parser JPARSER::JParser, \n * the value at the corresponding option can contain data or be the name of a file.\n * The I/O of the actual container is handled via the auxiliary methods that are part of JStreamToolkit.hh. */ template struct JContainer : public JContainer_t, public JObjectStreamIO< JContainer > { typedef JContainer_t container_type; /** * Read container from input. * * \param in input stream * \param container container * \return input stream */ friend inline std::istream& operator>>(std::istream& in, JContainer& container) { using namespace JPP; JStringStream is(in); if (getFileStatus(is.str().c_str())) { is.load(); } is >> container.comment; readObject(is, static_cast(container)); return in; } /** * Write container to output. * * \param out output stream * \param container container * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JContainer& container) { using namespace std; using namespace JPP; out << container.comment; writeObject(out, "", static_cast(container), '\n'); return out; } JComment comment; }; } #endif