blob: 8faf90af25289d269db80a684bef5a7f92d9e94f (
plain) (
blame)
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
|
// Copyright Epic Games, Inc. All Rights Reserved.
#include <stdarg.h>
#include <zencore/memory.h>
#include <zencore/stream.h>
#include <zencore/testing.h>
#include <algorithm>
#include <stdexcept>
namespace zen {
void
BinaryWriter::Write(const void* data, size_t ByteCount, uint64_t Offset)
{
RwLock::ExclusiveLockScope _(m_Lock);
const size_t NeedEnd = Offset + ByteCount;
if (NeedEnd > m_Buffer.size())
{
m_Buffer.resize(NeedEnd);
}
memcpy(m_Buffer.data() + Offset, data, ByteCount);
}
void
BinaryWriter::Reset()
{
RwLock::ExclusiveLockScope _(m_Lock);
m_Buffer.clear();
m_Offset = 0;
}
//////////////////////////////////////////////////////////////////////////
//
// Testing related code follows...
//
#if ZEN_WITH_TESTS
void
stream_forcelink()
{
}
#endif
} // namespace zen
|