#ifndef GENERS_VALARRAYIO_HH_ #define GENERS_VALARRAYIO_HH_ #include #include "geners/GenericIO.hh" namespace gs { template struct IOIsContiguous > {enum {value = 1};}; template struct IOIsContiguous > {enum {value = 1};}; template struct IOIsContiguous > {enum {value = 1};}; template struct IOIsContiguous > {enum {value = 1};}; template struct InsertContainerItem > { typedef std::valarray A; static inline void insert(A& obj, const typename A::value_type& item, const std::size_t itemNumber) {obj[itemNumber] = item;} }; template struct InsertContainerItem > { typedef std::valarray A; static inline void insert(A& obj, const typename A::value_type& item, const std::size_t itemNumber) {obj[itemNumber] = item;} }; // Need to specialize behavior in the header because // there is no "clear" method in std::valarray template struct GenericReader, InContainerHeader> { typedef std::valarray Container; inline static bool process(Container& a, Stream& is, State* state, const bool processClassId) { if (processClassId) { static const ClassId current(ClassId::makeId()); ClassId id(is, 1); current.ensureSameName(id); } if (!IOTraits::IsPOD) { ClassId id(is, 1); state->push_back(id); } return true; } }; namespace Private { template < template class Visitor, typename T, typename Arg1, typename Arg2 > struct iterate_const_container,Arg1,Arg2> { static bool process(const std::valarray& v, Arg1& a1, Arg2* p2, const std::size_t len) { bool itemStatus = true; for (std::size_t i=0; i(v[i],a1,p2,false); return itemStatus; } }; template < template class Visitor, typename T, typename Arg1, typename Arg2 > struct iterate_container,Arg1,Arg2> { static bool process(std::valarray& obj, Arg1& a1, Arg2* p2, const std::size_t newSize) { obj.resize(newSize); bool itemStatus = true; for (std::size_t i=0; i,InContainerCycle>::process( obj, a1, p2, i); return itemStatus; } }; } } gs_specialize_template_id_T(std::valarray, 0, 1) #endif // GENERS_VALARRAYIO_HH_