forked from AdrienTD/c47edit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchunk.h
32 lines (25 loc) · 752 Bytes
/
chunk.h
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
// c47edit - Scene editor for HM C47
// Copyright (C) 2018 AdrienTD
// Licensed under the GPL3+.
// See LICENSE file for more details.
#pragma once
#include <cstdint>
#include <string>
#include <vector>
#include "DynArray.h"
struct Chunk
{
using DataBuffer = DynArray<uint8_t>;
uint32_t tag = 0;
std::vector<DataBuffer> multidata;
std::vector<Chunk> subchunks;
DataBuffer maindata;
Chunk() = default;
Chunk(uint32_t tag) : tag(tag) {};
~Chunk();
const Chunk* findSubchunk(uint32_t tag) const;
Chunk* findSubchunk(uint32_t tag) { return (Chunk*)std::as_const(*this).findSubchunk(tag); }
void load(void *bytes);
std::string saveToString();
static Chunk reconstructPackFromRepeat(void *packrep, uint32_t packrepsize, void *repeat);
};