summaryrefslogtreecommitdiff
path: root/Runtime/Serialize/TransferFunctions/StreamedBinaryWrite.cpp
blob: a7699e91e2a85cdc8190efe91afae264cb0fac6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "UnityPrefix.h"
#include "StreamedBinaryWrite.h"
#include "Configuration/UnityConfigure.h"

template <bool kSwapEndianess>
CachedWriter& StreamedBinaryWrite<kSwapEndianess>::Init (int flags, BuildTargetSelection target)
{
	m_Flags = flags;
	m_UserData = NULL;
	m_Target = target;

#if UNITY_EDITOR && CHECK_SERIALIZE_ALIGNMENT
	m_Cache.SetCheckSerializeAlignment(true);
	#endif
	return m_Cache;
}

template <bool kSwapEndianess>
CachedWriter& StreamedBinaryWrite<kSwapEndianess>::Init (const CachedWriter& cachedWriter, int flags, BuildTargetSelection target, const BuildUsageTag& buildUsageTag)
{
	m_Flags = flags;
	m_Target = target;
	m_Cache = cachedWriter;
	m_UserData = NULL;

	#if UNITY_EDITOR
	m_BuildUsageTag = buildUsageTag;
	#endif

#if UNITY_EDITOR && CHECK_SERIALIZE_ALIGNMENT
	m_Cache.SetCheckSerializeAlignment(true);
#endif
	return m_Cache;
}

template <bool kSwapEndianess>
void StreamedBinaryWrite<kSwapEndianess>::Align ()
{
	m_Cache.Align4Write();
}


template <bool kSwapEndianess>
void StreamedBinaryWrite<kSwapEndianess>::TransferTypeless (unsigned* byteSize, const char* /* name*/, TransferMetaFlags/* metaFlag*/)
{
	SInt32 size = *byteSize;
	Transfer (size, "size");
}

// markerID is the id that was given by TransferTypeless.
// byteStart is
// optional temporaryDataHandle: temporaryDataHandle is a handle to the data
// optional copyData: is a pointer to where the data will be written or read from
template <bool kSwapEndianess>
void StreamedBinaryWrite<kSwapEndianess>::TransferTypelessData (unsigned byteSize, void* copyData, int/* metaData*/)
{
	AssertIf(copyData == NULL && byteSize != 0);
	m_Cache.Write (copyData, byteSize);
	Align();
}


template CachedWriter& StreamedBinaryWrite<false>::Init (int flags, BuildTargetSelection target);
template CachedWriter& StreamedBinaryWrite<true>::Init (int flags, BuildTargetSelection target);

template CachedWriter& StreamedBinaryWrite<false>::Init (const CachedWriter& cachedWriter, int flags, BuildTargetSelection target, const BuildUsageTag& buildUsageTag);
template CachedWriter& StreamedBinaryWrite<true>::Init (const CachedWriter& cachedWriter, int flags, BuildTargetSelection target, const BuildUsageTag& buildUsageTag);

template void StreamedBinaryWrite<false>::Align ();
template void StreamedBinaryWrite<true>::Align ();

template void StreamedBinaryWrite<false>::TransferTypeless (unsigned* byteSize, const char*/* name*/, TransferMetaFlags/* metaFlag*/);
template void StreamedBinaryWrite<true>::TransferTypeless (unsigned* byteSize, const char*/* name*/, TransferMetaFlags/* metaFlag*/);

template void StreamedBinaryWrite<false>::TransferTypelessData (unsigned byteSize, void* copyData, int metaData);
template void StreamedBinaryWrite<true>::TransferTypelessData (unsigned byteSize, void* copyData, int metaData);