NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
dig_entry.hpp
Go to the documentation of this file.
1
11#pragma once
12
13#include <map>
14#include <vector>
15
17#include "NNL/common/io.hpp"
18namespace nnl {
26
31namespace dig_entry {
32
38
48using DigEntry = std::vector<Buffer>;
59using DigEntryView = std::vector<BufferView>;
75bool IsOfType(BufferView buffer);
76
77bool IsOfType(const std::filesystem::path& path);
78
79bool IsOfType(Reader& f);
98
99DigEntry Import(const std::filesystem::path& path);
100
118
128[[nodiscard]] Buffer Export(const DigEntry& dig_entry);
129
130void Export(const DigEntry& dig_entry, const std::filesystem::path& path);
131
132void Export(const DigEntry& dig_entry, Writer& f);
133
134[[nodiscard]] Buffer Export(const DigEntryView& dig_entry);
135
136void Export(const DigEntryView& dig_entry, const std::filesystem::path& path);
137
138void Export(const DigEntryView& dig_entry, Writer& f);
140
141namespace raw {
142NNL_PACK(struct RFileRecord {
143 u32 id = 0;
144 u32 size = 0;
145 u32 offset = 0;
146 u32 reserved = 0; // always 0
147});
148
149static_assert(sizeof(RFileRecord) == 0x10);
150
151template <typename TData = Buffer>
152struct RDigEntry {
153 std::vector<RFileRecord> file_records;
154
155 // Maps of offsets (used in the structures above) to their data:
156 std::map<u32, TData> file_buffers;
157};
158
159RDigEntry<Buffer> Parse(Reader& f);
160
161RDigEntry<BufferView> ParseView(BufferView f);
162
163DigEntry Convert(RDigEntry<Buffer>&& cfcdig);
164
165DigEntryView Convert(RDigEntry<BufferView>&& cfcdig);
166
167} // namespace raw
168} // namespace dig_entry
169
170} // namespace nnl
Contains macros and definitions for fixed-width types.
DigEntryView ImportView(BufferView buffer)
Parses a binary file and converts it into DigEntryView.
bool IsOfType(BufferView buffer)
Tests if the provided file is a dig entry archive.
DigEntry Import(BufferView buffer)
Parses a binary file and converts it into a DigEntry object.
std::vector< Buffer > DigEntry
A nested archive within a top-level Dig archive.
Definition dig_entry.hpp:48
std::vector< BufferView > DigEntryView
A non-owning view of a dig entry archive.
Definition dig_entry.hpp:59
Buffer Export(const DigEntry &dig_entry)
Converts a dig entry archive to a binary file representation.
std::uint32_t u32
32-bit unsigned integer
Definition fixed_type.hpp:60
#define NNL_PACK(...)
A structure packing directive.
Definition fixed_type.hpp:41
Reader implementation for read-only memory buffers.
Definition io.hpp:598
Abstract class for writing data.
Definition io.hpp:136
Abstract class for reading data.
Definition io.hpp:78
std::vector< u8 > Buffer
A type alias for std::vector<u8> that denotes a raw, contiguous memory region that may be interpreted...
Definition io.hpp:40
Provides classes for reading and writing binary data to and from various sources.
Provides structures and functions to manage entries of a dig archive.
Definition dig_entry.hpp:31
Definition exception.hpp:56