NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
collection.hpp
Go to the documentation of this file.
1
12#pragma once
13
14#include <map>
15
17#include "NNL/common/io.hpp"
18namespace nnl {
25
30namespace collection {
36
48using Collection = std::vector<Buffer>;
59using CollectionView = std::vector<BufferView>;
60
73bool IsOfType(BufferView buffer);
74
75bool IsOfType(const std::filesystem::path& path);
76
77bool IsOfType(Reader& f);
78
94
95Collection Import(const std::filesystem::path& path);
96
109
111
121[[nodiscard]] Buffer Export(const Collection& asset_collection);
122
123void Export(const Collection& asset_collection, const std::filesystem::path& path);
124
125void Export(const Collection& asset_collection, Writer& f);
126
127[[nodiscard]] Buffer Export(const CollectionView& asset_collection);
128
129void Export(const CollectionView& asset_collection, const std::filesystem::path& path);
130
131void Export(const CollectionView& asset_collection, Writer& f);
133namespace raw {
134
135NNL_PACK(struct RFileRecord { u32 offset = 0; });
136
137static_assert(sizeof(RFileRecord) == 0x4);
138
139template <typename TData = Buffer>
140struct RCollection {
141 u32 num_entries = 0;
142 std::vector<RFileRecord> file_records;
143 // Maps of offsets (used in the structures above) to their data:
144 std::map<u32, TData> file_buffers;
145};
146
147RCollection<Buffer> Parse(Reader& f);
148
149RCollection<BufferView> ParseView(BufferView f);
150
151Collection Convert(RCollection<Buffer>&& rasset_collection);
152
153CollectionView Convert(RCollection<BufferView>&& rasset_collection);
154
155} // namespace raw
156
157} // namespace collection
158
160} // namespace nnl
Contains macros and definitions for fixed-width types.
CollectionView ImportView(BufferView buffer)
Parses a binary file and converts it into a CollectionView object.
std::vector< BufferView > CollectionView
A non-owning view of an asset collection.
Definition collection.hpp:59
Collection Import(BufferView buffer)
Parses a binary file and converts it into a Collection object.
bool IsOfType(BufferView buffer)
Tests if the provided file is an asset collection.
Buffer Export(const Collection &asset_collection)
Converts an asset collection to a binary file representation.
std::vector< Buffer > Collection
A container for related but distinct assets.
Definition collection.hpp:48
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 containers of distinct but related assets.
Definition collection.hpp:30
Definition exception.hpp:56