Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
XTemplateSerialize.h
1// XTemplateSerialize: specific template serialization
2//
3//////////////////////////////////////////////////////////////////////
4
5#if !defined(CXTEMPLATESERIALIZE_INCLUDE_H)
6#define CXTEMPLATESERIALIZE_INCLUDE_H
7
8BEGIN_MOOTOOLS_NAMESPACE
9
10template<class TYPE>
11void XArraySerialize(CXArchive& ar, TYPE* pElements, int elementCount)
12{
13 XENSURE(elementCount == 0 || pElements != NULL);
14
15 // default is bit-wise read/write
16 if (ar.IsStoring())
17 {
18 int nElementsLeft = elementCount;
20 while (nElementsLeft > 0)
21 {
22 int nElementsToWrite = __min(nElementsLeft, INT_MAX/(int)sizeof(TYPE));
23 ar.Write(pData, nElementsToWrite*sizeof(TYPE));
26 }
27 }
28 else
29 {
30 int nElementsLeft = elementCount;
32 while (nElementsLeft > 0)
33 {
34 int nElementsToRead = __min(nElementsLeft, INT_MAX/(int)sizeof(TYPE));
35 ar.EnsureRead(pData, nElementsToRead*sizeof(TYPE));
38 }
39 }
40}
41
42#ifndef MOOTOOLS_NO_ARCHIVE_SUPPORT
43template<class TYPE, class ARG_TYPE>
45{
46 XASSERT(this);
47
48 CXObject::Serialize(ar);
49 if (ar.IsStoring())
50 {
51 ar.WriteCount(elementCount);
52 }
53 else
54 {
55 int prevBufCount = (int)ar.ReadCount();
56 SetSize(prevBufCount, -1);
57 }
58 XArraySerialize<TYPE>(ar, buffer, elementCount);
59}
60#endif
61
62END_MOOTOOLS_NAMESPACE
63
64#endif // !defined(CXTEMPLATESERIALIZE_INCLUDE_H)
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
Definition XArchive.h:17
CXArray is an array of simple data information which does not requires to call a constructor / destru...
Definition XTemplate.h:34