18 #ifndef INCLUDE_SF_SERIALIZESTL_HPP 19 #define INCLUDE_SF_SERIALIZESTL_HPP 21 #include <SF/Archive.hpp> 25 class PushBackSemantics
28 template<
typename Container,
typename Value>
29 void add(Container &container,
const Value &value)
31 container.push_back(value);
38 template<
typename Container,
typename Value>
39 void add(Container &container,
const Value &value)
41 container.insert(value);
45 class ReserveSemantics
48 template<
typename Container>
49 void reserve(Container &container, std::size_t newSize)
51 container.reserve(newSize);
55 class NoReserveSemantics
58 template<
typename Container>
59 void reserve(Container &container, std::size_t newSize)
61 RCF_UNUSED_VARIABLE(container);
62 RCF_UNUSED_VARIABLE(newSize);
66 template<
typename AddFunc,
typename ReserveFunc,
typename StlContainer>
67 void serializeStlContainer(Archive &ar, StlContainer &t)
70 typedef typename StlContainer::iterator Iterator;
71 typedef typename StlContainer::value_type Value;
76 unsigned int count = 0;
79 std::size_t minSerializedLength =
sizeof(Value);
80 if (ar.verifyAgainstArchiveSize(count*minSerializedLength))
82 ReserveFunc().reserve(t, count);
85 for (
unsigned int i=0; i<count; i++)
89 AddFunc().add(t, value);
92 else if (ar.isWrite())
94 unsigned int count =
static_cast<unsigned int>(t.size());
96 Iterator it = t.begin();
97 for (
unsigned int i=0; i<count; i++)
107 #endif // ! INCLUDE_SF_SERIALIZESTL_HPP Definition: ByteBuffer.hpp:188