OpenMoHAA 0.82.1
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
37{
38public:
39 MemArchiver();
40 ~MemArchiver();
41
42 void SetupForWriting(size_t initialSize);
43 void SetupForReading(byte *buffer, size_t size);
44 void SetBaseTime(unsigned int time);
45 size_t BufferSize() const;
46 byte *ConfiscateBuffer();
47 bool IsReading() const;
48 bool IsWriting() const;
49 bool FinishedReading() const;
50
51 void ArchiveByte(byte *value);
52 void ArchiveBoolean(qboolean *value);
53 void ArchiveChar(char *value);
54 void ArchiveUChar(unsigned char *value);
55 void ArchiveShort(short *value);
56 void ArchiveInteger(int *value);
57 void ArchiveSize(size_t *value);
58 void ArchiveFloat(float *value);
59 void ArchiveVec3(vec3_t value);
60 void ArchiveVector(Vector *value);
61 void ArchiveString(str *value);
62 void ArchiveTime(int *value);
63 void ArchiveRaw(void *buffer, size_t size);
64 void ArchiveReadRaw(void *buffer, size_t size);
65 void ArchiveWriteRaw(const void *buffer, size_t size);
66
67private:
68 archiverState_e state;
69 byte *buffer;
70 size_t bufferSize;
71 size_t allocatedSize;
72 int svsTime;
73};
Definition vector.h:61
Definition str.h:77