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
8
BEGIN_MOOTOOLS_NAMESPACE
9
10
template
<
class
TYPE>
11
void
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;
19
TYPE
*
pData
=
pElements
;
20
while
(
nElementsLeft
> 0)
21
{
22
int
nElementsToWrite
= __min(
nElementsLeft
,
INT_MAX
/(
int
)
sizeof
(
TYPE
));
23
ar
.Write(
pData
,
nElementsToWrite
*
sizeof
(
TYPE
));
24
nElementsLeft
-=
nElementsToWrite
;
25
pData
+=
nElementsToWrite
;
26
}
27
}
28
else
29
{
30
int
nElementsLeft
= elementCount;
31
TYPE
*
pData
=
pElements
;
32
while
(
nElementsLeft
> 0)
33
{
34
int
nElementsToRead
= __min(
nElementsLeft
,
INT_MAX
/(
int
)
sizeof
(
TYPE
));
35
ar
.EnsureRead(
pData
,
nElementsToRead
*
sizeof
(
TYPE
));
36
nElementsLeft
-=
nElementsToRead
;
37
pData
+=
nElementsToRead
;
38
}
39
}
40
}
41
42
#ifndef MOOTOOLS_NO_ARCHIVE_SUPPORT
43
template
<
class
TYPE,
class
ARG_TYPE>
44
void
CXArray<TYPE, ARG_TYPE>::Serialize
(
CXArchive
&
ar
)
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
62
END_MOOTOOLS_NAMESPACE
63
64
#endif
// !defined(CXTEMPLATESERIALIZE_INCLUDE_H)
C3DTPoint
The class defines an x, y, z 3D point which can use int, float or double.
Definition
3DPoint.h:27
CXArchive
Definition
XArchive.h:17
CXArray
CXArray is an array of simple data information which does not requires to call a constructor / destru...
Definition
XTemplate.h:34
VS2022-PolygonCruncherSDK-Full-IO
SDK
Includes
XTemplateSerialize.h
Generated by
1.9.8