]> git.localhorst.tv Git - blank.git/blob - src/world/WorldSave.hpp
b08b373f3e6719ee97dbb0ab21951a38e1d4da5b
[blank.git] / src / world / WorldSave.hpp
1 #ifndef BLANK_WORLD_WORLDSAVE_HPP_
2 #define BLANK_WORLD_WORLDSAVE_HPP_
3
4 #include "Chunk.hpp"
5 #include "World.hpp"
6
7 #include <memory>
8 #include <string>
9
10
11 namespace blank {
12
13 class WorldSave {
14
15 public:
16         explicit WorldSave(const std::string &path);
17
18 public:
19         // whole save
20         bool Exists() const noexcept;
21         void Read(World::Config &) const;
22         void Write(const World::Config &) const;
23
24         // single chunk
25         bool Exists(const Chunk::Pos &) const noexcept;
26         void Read(Chunk &) const;
27         void Write(Chunk &) const;
28
29         const char *ChunkPath(const Chunk::Pos &) const;
30
31 private:
32         std::string root_path;
33         std::string conf_path;
34         std::string chunk_path;
35         std::size_t chunk_bufsiz;
36         std::unique_ptr<char[]> chunk_buf;
37
38 };
39
40 }
41
42 #endif