]> git.localhorst.tv Git - blank.git/blob - src/io/WorldSave.hpp
unified location handling
[blank.git] / src / io / WorldSave.hpp
1 #ifndef BLANK_IO_WORLDSAVE_HPP_
2 #define BLANK_IO_WORLDSAVE_HPP_
3
4 #include "../world/Chunk.hpp"
5 #include "../world/Generator.hpp"
6 #include "../world/World.hpp"
7
8 #include <memory>
9 #include <string>
10
11
12 namespace blank {
13
14 class Player;
15
16 class WorldSave {
17
18 public:
19         explicit WorldSave(const std::string &path);
20
21 public:
22         // whole save
23         bool Exists() const noexcept;
24         void Read(World::Config &) const;
25         void Write(const World::Config &) const;
26         void Read(Generator::Config &) const;
27         void Write(const Generator::Config &) const;
28
29         // player
30         bool Exists(const Player &) const;
31         void Read(Player &) const;
32         void Write(const Player &) const;
33         std::string PlayerPath(const Player &) const;
34
35         // single chunk
36         bool Exists(const ExactLocation::Coarse &) const noexcept;
37         void Read(Chunk &) const;
38         void Write(Chunk &) const;
39         const char *ChunkPath(const ExactLocation::Coarse &) const;
40
41 private:
42         std::string root_path;
43         std::string world_conf_path;
44         std::string gen_conf_path;
45         std::string player_path;
46         std::string chunk_path;
47         std::size_t chunk_bufsiz;
48         std::unique_ptr<char[]> chunk_buf;
49
50 };
51
52 }
53
54 #endif