OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
memarchiver.h
1/*
2===========================================================================
3Copyright (C) 2023 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23// DESCRIPTION:
24// In-memory archiver
25
26#include "cg_local.h"
27
28class Vector;
29class str;
30
31typedef enum {
32 MEMARC_WRITING,
33 MEMARC_READING
34} archiverState_e;
35
36class MemArchiver {
37public:
38 MemArchiver();
39 ~MemArchiver();
40
41 void SetupForWriting(size_t initialSize);
42 void SetupForReading(byte* buffer, size_t size);
43 void SetBaseTime(unsigned int time);
44 size_t BufferSize() const;
45 byte* ConfiscateBuffer();
46 bool IsReading() const;
47 bool IsWriting() const;
48 bool FinishedReading() const;
49
50 void ArchiveByte(byte* value);
51 void ArchiveBoolean(qboolean* value);
52 void ArchiveChar(char* value);
53 void ArchiveUChar(unsigned char* value);
54 void ArchiveShort(short* value);
55 void ArchiveInteger(int* value);
56 void ArchiveSize(size_t* value);
57 void ArchiveFloat(float* value);
58 void ArchiveVec3(vec3_t value);
59 void ArchiveVector(Vector* value);
60 void ArchiveString(str* value);
61 void ArchiveTime(int* value);
62 void ArchiveRaw(void* buffer, size_t size);
63 void ArchiveReadRaw(void* buffer, size_t size);
64 void ArchiveWriteRaw(const void* buffer, size_t size);
65
66private:
67 archiverState_e state;
68 byte* buffer;
69 size_t bufferSize;
70 size_t allocatedSize;
71 int svsTime;
72};
Definition vector.h:61
Definition str.h:77