18 #ifndef INCLUDE_SF_VECTOR_HPP 19 #define INCLUDE_SF_VECTOR_HPP 21 #include <type_traits> 25 #include <SF/SerializeStl.hpp> 31 template<
typename T,
typename A>
32 inline void serializeVector(
34 std::vector<T,A> & vec,
37 serializeStlContainer<PushBackSemantics, ReserveSemantics>(ar, vec);
40 template<
typename T,
typename A>
41 inline void serializeVector(
43 std::vector<T,A> & vec,
46 serializeVectorFast(ar, vec);
49 template<
typename T,
typename A>
50 inline void serialize(
52 std::vector<T,A> & vec)
58 const bool IsBool = std::is_same<T, bool>::value;
59 static_assert( !IsBool,
"This serialization function cannot be used for vector<bool>." );
61 typedef typename std::is_fundamental<T>::type type;
62 serializeVector(ar, vec, (type *) 0);
66 RCF_EXPORT
void serialize(
SF::Archive & ar, std::vector<bool> & bits);
71 virtual ~I_VecWrapper() {}
73 virtual void resize(std::size_t newSize) = 0;
74 virtual std::uint32_t size() = 0;
75 virtual char * addressOfElement(std::size_t idx) = 0;
76 virtual std::uint32_t sizeofElement() = 0;
79 template<
typename Vec>
80 class VecWrapper :
public I_VecWrapper
83 VecWrapper(Vec & vec) : mVec(vec)
87 void resize(std::size_t newSize)
94 return static_cast<std::uint32_t
>(mVec.size());
97 char * addressOfElement(std::size_t idx)
99 return reinterpret_cast<char *
>( &mVec[idx] );
102 std::uint32_t sizeofElement()
104 typedef typename Vec::value_type ValueType;
105 return sizeof(ValueType);
112 RCF_EXPORT
void serializeVectorFastImpl(
116 template<
typename T,
typename A>
117 inline void serializeVectorFast(
119 std::vector<T,A> & vec)
121 VecWrapper< std::vector<T,A> > vecWrapper(vec);
122 serializeVectorFastImpl(ar, vecWrapper);
127 #endif // ! INCLUDE_SF_VECTOR_HPP Represents an archive, in which serialized objects are stored.
Definition: Archive.hpp:31
Definition: ByteBuffer.hpp:188