#ifndef GENERS_COLUMNPACKERHELPER_HH_ #define GENERS_COLUMNPACKERHELPER_HH_ #include #include "geners/GenericIO.hh" #include "geners/IOReferredType.hh" #include "geners/IOIsPOD.hh" #include "geners/ColumnBuffer.hh" namespace gs { template class ColumnPacker; namespace Private { template struct ColumnPackerHelper { typedef typename IOReferredType< typename std::tuple_element::type>::type element_io_type; inline static void podness( std::vector& buf) { ColumnPackerHelper::podness(buf); if (IOIsPOD::value) buf[N-1]->podsize = sizeof(element_io_type); } inline static bool write( ColumnPacker& packer, const Pack& pack) { const bool status = ColumnPackerHelper::write( packer, pack); std::ostream& os = packer.columnOstream(N-1); char* ps = 0; return status && process_const_item( std::get(pack), os, ps, false); } inline static bool readRow( const ColumnPacker& packer, Pack* pack) { if (!ColumnPackerHelper::readRow(packer, pack)) return false; std::vector* iostack = 0; std::istream* is = packer.columnIstream(N-1, &iostack); if (is) return process_item( std::get(*pack), *is, iostack, false); else // It is OK to skip a column on readout return true; } }; template struct ColumnPackerHelper { inline static void podness(std::vector&) {} inline static bool write(ColumnPacker&, const Pack&) {return true;} inline static bool readRow(const ColumnPacker&, Pack*) {return true;} }; } } #endif // GENERS_COLUMNPACKERHELPER_HH_