Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
database-leveldb.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 "config.h"
8
9#if USE_LEVELDB
10
11#include <memory>
12#include <string>
13#include "database.h"
14#include "leveldb/db.h"
15
17{
18public:
19 Database_LevelDB(const std::string &savedir);
20 ~Database_LevelDB() = default;
21
22 bool saveBlock(const v3s16 &pos, std::string_view data);
23 void loadBlock(const v3s16 &pos, std::string *block);
24 bool deleteBlock(const v3s16 &pos);
25 void listAllLoadableBlocks(std::vector<v3s16> &dst);
26
27 void beginSave() {}
28 void endSave() {}
29
30private:
31 std::unique_ptr<leveldb::DB> m_database;
32};
33
35{
36public:
37 PlayerDatabaseLevelDB(const std::string &savedir);
39
40 void savePlayer(RemotePlayer *player);
41 bool loadPlayer(RemotePlayer *player, PlayerSAO *sao);
42 bool removePlayer(const std::string &name);
43 void listPlayers(std::vector<std::string> &res);
44
45private:
46 std::unique_ptr<leveldb::DB> m_database;
47};
48
50{
51public:
52 AuthDatabaseLevelDB(const std::string &savedir);
53 virtual ~AuthDatabaseLevelDB() = default;
54
55 virtual bool getAuth(const std::string &name, AuthEntry &res);
56 virtual bool saveAuth(const AuthEntry &authEntry);
57 virtual bool createAuth(AuthEntry &authEntry);
58 virtual bool deleteAuth(const std::string &name);
59 virtual void listNames(std::vector<std::string> &res);
60 virtual void reload();
61
62private:
63 std::unique_ptr<leveldb::DB> m_database;
64};
65
66#endif // USE_LEVELDB
Definition database-leveldb.h:50
virtual bool getAuth(const std::string &name, AuthEntry &res)
Definition database-leveldb.cpp:203
virtual bool saveAuth(const AuthEntry &authEntry)
Definition database-leveldb.cpp:239
virtual void reload()
Definition database-leveldb.cpp:279
virtual bool deleteAuth(const std::string &name)
Definition database-leveldb.cpp:264
virtual void listNames(std::vector< std::string > &res)
Definition database-leveldb.cpp:270
virtual ~AuthDatabaseLevelDB()=default
std::unique_ptr< leveldb::DB > m_database
Definition database-leveldb.h:63
virtual bool createAuth(AuthEntry &authEntry)
Definition database-leveldb.cpp:259
AuthDatabaseLevelDB(const std::string &savedir)
Definition database-leveldb.cpp:192
Definition database.h:61
Definition database-leveldb.h:17
void endSave()
Definition database-leveldb.h:28
bool deleteBlock(const v3s16 &pos)
Definition database-leveldb.cpp:64
~Database_LevelDB()=default
Database_LevelDB(const std::string &savedir)
Definition database-leveldb.cpp:30
void loadBlock(const v3s16 &pos, std::string *block)
Definition database-leveldb.cpp:55
bool saveBlock(const v3s16 &pos, std::string_view data)
Definition database-leveldb.cpp:41
std::unique_ptr< leveldb::DB > m_database
Definition database-leveldb.h:31
void beginSave()
Definition database-leveldb.h:27
void listAllLoadableBlocks(std::vector< v3s16 > &dst)
Definition database-leveldb.cpp:77
Definition database.h:23
Definition database-leveldb.h:35
bool removePlayer(const std::string &name)
Definition database-leveldb.cpp:140
void listPlayers(std::vector< std::string > &res)
Definition database-leveldb.cpp:183
std::unique_ptr< leveldb::DB > m_database
Definition database-leveldb.h:46
PlayerDatabaseLevelDB(const std::string &savedir)
Definition database-leveldb.cpp:86
~PlayerDatabaseLevelDB()=default
void savePlayer(RemotePlayer *player)
Definition database-leveldb.cpp:97
bool loadPlayer(RemotePlayer *player, PlayerSAO *sao)
Definition database-leveldb.cpp:146
Definition database.h:41
Definition player_sao.h:56
Definition remoteplayer.h:26
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
Definition database.h:52