|
|
@ -37,6 +37,34 @@ inline T& REF(const T& val) |
|
|
|
return const_cast<T&>(val); |
|
|
|
return const_cast<T&>(val); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Get begin pointer of vector (non-const version).
|
|
|
|
|
|
|
|
* @note These functions avoid the undefined case of indexing into an empty |
|
|
|
|
|
|
|
* vector, as well as that of indexing after the end of the vector. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
template <class T, class TAl> |
|
|
|
|
|
|
|
inline T* begin_ptr(std::vector<T,TAl>& v) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return v.empty() ? NULL : &v[0]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** Get begin pointer of vector (const version) */ |
|
|
|
|
|
|
|
template <class T, class TAl> |
|
|
|
|
|
|
|
inline const T* begin_ptr(const std::vector<T,TAl>& v) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return v.empty() ? NULL : &v[0]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** Get end pointer of vector (non-const version) */ |
|
|
|
|
|
|
|
template <class T, class TAl> |
|
|
|
|
|
|
|
inline T* end_ptr(std::vector<T,TAl>& v) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return v.empty() ? NULL : (&v[0] + v.size()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** Get end pointer of vector (const version) */ |
|
|
|
|
|
|
|
template <class T, class TAl> |
|
|
|
|
|
|
|
inline const T* end_ptr(const std::vector<T,TAl>& v) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return v.empty() ? NULL : (&v[0] + v.size()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Templates for serializing to anything that looks like a stream,
|
|
|
|
// Templates for serializing to anything that looks like a stream,
|
|
|
@ -318,6 +346,12 @@ protected: |
|
|
|
char* pend; |
|
|
|
char* pend; |
|
|
|
public: |
|
|
|
public: |
|
|
|
CFlatData(void* pbeginIn, void* pendIn) : pbegin((char*)pbeginIn), pend((char*)pendIn) { } |
|
|
|
CFlatData(void* pbeginIn, void* pendIn) : pbegin((char*)pbeginIn), pend((char*)pendIn) { } |
|
|
|
|
|
|
|
template <class T, class TAl> |
|
|
|
|
|
|
|
explicit CFlatData(std::vector<T,TAl> &v) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pbegin = (char*)begin_ptr(v); |
|
|
|
|
|
|
|
pend = (char*)end_ptr(v); |
|
|
|
|
|
|
|
} |
|
|
|
char* begin() { return pbegin; } |
|
|
|
char* begin() { return pbegin; } |
|
|
|
const char* begin() const { return pbegin; } |
|
|
|
const char* begin() const { return pbegin; } |
|
|
|
char* end() { return pend; } |
|
|
|
char* end() { return pend; } |
|
|
|