Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
database.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include <string>
8#include <string_view>
9#include <vector>
10#include "irr_v3d.h"
11#include "irrlichttypes.h"
12#include "util/string.h"
13
15{
16public:
17 virtual void beginSave() = 0;
18 virtual void endSave() = 0;
19 virtual bool initialized() const { return true; }
20};
21
22class MapDatabase : public Database
23{
24public:
25 virtual ~MapDatabase() = default;
26
27 virtual bool saveBlock(const v3s16 &pos, std::string_view data) = 0;
28 virtual void loadBlock(const v3s16 &pos, std::string *block) = 0;
29 virtual bool deleteBlock(const v3s16 &pos) = 0;
30
31 static s64 getBlockAsInteger(const v3s16 &pos);
32 static v3s16 getIntegerAsBlock(s64 i);
33
34 virtual void listAllLoadableBlocks(std::vector<v3s16> &dst) = 0;
35};
36
37class PlayerSAO;
38class RemotePlayer;
39
41{
42public:
43 virtual ~PlayerDatabase() = default;
44
45 virtual void savePlayer(RemotePlayer *player) = 0;
46 virtual bool loadPlayer(RemotePlayer *player, PlayerSAO *sao) = 0;
47 virtual bool removePlayer(const std::string &name) = 0;
48 virtual void listPlayers(std::vector<std::string> &res) = 0;
49};
50
52{
53 u64 id;
54 std::string name;
55 std::string password;
56 std::vector<std::string> privileges;
58};
59
61{
62public:
63 virtual ~AuthDatabase() = default;
64
65 virtual bool getAuth(const std::string &name, AuthEntry &res) = 0;
66 virtual bool saveAuth(const AuthEntry &authEntry) = 0;
67 virtual bool createAuth(AuthEntry &authEntry) = 0;
68 virtual bool deleteAuth(const std::string &name) = 0;
69 virtual void listNames(std::vector<std::string> &res) = 0;
70 virtual void reload() = 0;
71};
72
74{
75public:
76 virtual ~ModStorageDatabase() = default;
77
78 virtual void getModEntries(const std::string &modname, StringMap *storage) = 0;
79 virtual void getModKeys(const std::string &modname, std::vector<std::string> *storage) = 0;
80 virtual bool hasModEntry(const std::string &modname, const std::string &key) = 0;
81 virtual bool getModEntry(const std::string &modname,
82 const std::string &key, std::string *value) = 0;
83 virtual bool setModEntry(const std::string &modname,
84 const std::string &key, std::string_view value) = 0;
85 virtual bool removeModEntry(const std::string &modname, const std::string &key) = 0;
86 virtual bool removeModEntries(const std::string &modname) = 0;
87 virtual void listMods(std::vector<std::string> *res) = 0;
88};
Definition database.h:61
virtual void listNames(std::vector< std::string > &res)=0
virtual bool saveAuth(const AuthEntry &authEntry)=0
virtual bool createAuth(AuthEntry &authEntry)=0
virtual ~AuthDatabase()=default
virtual bool getAuth(const std::string &name, AuthEntry &res)=0
virtual void reload()=0
virtual bool deleteAuth(const std::string &name)=0
Definition database.h:15
virtual void endSave()=0
virtual void beginSave()=0
virtual bool initialized() const
Definition database.h:19
Definition database.h:23
virtual ~MapDatabase()=default
virtual bool saveBlock(const v3s16 &pos, std::string_view data)=0
static v3s16 getIntegerAsBlock(s64 i)
Definition database.cpp:44
static s64 getBlockAsInteger(const v3s16 &pos)
Definition database.cpp:36
virtual void listAllLoadableBlocks(std::vector< v3s16 > &dst)=0
virtual bool deleteBlock(const v3s16 &pos)=0
virtual void loadBlock(const v3s16 &pos, std::string *block)=0
Definition database.h:74
virtual void getModEntries(const std::string &modname, StringMap *storage)=0
virtual void listMods(std::vector< std::string > *res)=0
virtual bool hasModEntry(const std::string &modname, const std::string &key)=0
virtual bool setModEntry(const std::string &modname, const std::string &key, std::string_view value)=0
virtual ~ModStorageDatabase()=default
virtual bool removeModEntry(const std::string &modname, const std::string &key)=0
virtual bool getModEntry(const std::string &modname, const std::string &key, std::string *value)=0
virtual void getModKeys(const std::string &modname, std::vector< std::string > *storage)=0
virtual bool removeModEntries(const std::string &modname)=0
Definition database.h:41
virtual bool removePlayer(const std::string &name)=0
virtual void listPlayers(std::vector< std::string > &res)=0
virtual ~PlayerDatabase()=default
virtual bool loadPlayer(RemotePlayer *player, PlayerSAO *sao)=0
virtual void savePlayer(RemotePlayer *player)=0
Definition player_sao.h:56
Definition remoteplayer.h:26
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
std::unordered_map< std::string, std::string > StringMap
Definition string.h:65
Definition database.h:52
u64 id
Definition database.h:53
std::vector< std::string > privileges
Definition database.h:56
std::string name
Definition database.h:54
std::string password
Definition database.h:55
s64 last_login
Definition database.h:57