19 #ifndef INCLUDE_SF_SERIALIZESTL_HPP 20 #define INCLUDE_SF_SERIALIZESTL_HPP 22 #include <SF/Archive.hpp> 26 class PushBackSemantics
29 template<
typename Container,
typename Value>
30 void add(Container &container,
const Value &value)
32 container.push_back(value);
39 template<
typename Container,
typename Value>
40 void add(Container &container,
const Value &value)
42 container.insert(value);
46 class ReserveSemantics
49 template<
typename Container>
50 void reserve(Container &container, std::size_t newSize)
52 container.reserve(newSize);
56 class NoReserveSemantics
59 template<
typename Container>
60 void reserve(Container &container, std::size_t newSize)
62 RCF_UNUSED_VARIABLE(container);
63 RCF_UNUSED_VARIABLE(newSize);
67 template<
typename AddFunc,
typename ReserveFunc,
typename StlContainer>
68 void serializeStlContainer(Archive &ar, StlContainer &t)
71 typedef typename StlContainer::iterator Iterator;
72 typedef typename StlContainer::value_type Value;
77 unsigned int count = 0;
80 std::size_t minSerializedLength =
sizeof(Value);
81 if (ar.verifyAgainstArchiveSize(count*minSerializedLength))
83 ReserveFunc().reserve(t, count);
86 for (
unsigned int i=0; i<count; i++)
90 AddFunc().add(t, value);
93 else if (ar.isWrite())
95 unsigned int count =
static_cast<unsigned int>(t.size());
97 Iterator it = t.begin();
98 for (
unsigned int i=0; i<count; i++)
108 #endif // ! INCLUDE_SF_SERIALIZESTL_HPP Definition: ByteBuffer.hpp:189