Luanti 5.16.0-dev
Loading...
Searching...
No Matches
ModStorageDatabaseFiles Class Reference

#include <database-files.h>

Inheritance diagram for ModStorageDatabaseFiles:
Collaboration diagram for ModStorageDatabaseFiles:

Public Member Functions

 ModStorageDatabaseFiles (const std::string &savedir)
virtual ~ModStorageDatabaseFiles ()=default
virtual void getModEntries (const std::string &modname, StringMap *storage)
virtual void getModKeys (const std::string &modname, std::vector< std::string > *storage)
virtual bool getModEntry (const std::string &modname, const std::string &key, std::string *value)
virtual bool hasModEntry (const std::string &modname, const std::string &key)
virtual bool setModEntry (const std::string &modname, const std::string &key, std::string_view value)
virtual bool removeModEntry (const std::string &modname, const std::string &key)
virtual bool removeModEntries (const std::string &modname)
virtual void listMods (std::vector< std::string > *res)
virtual void beginSave ()
virtual void endSave ()
Public Member Functions inherited from ModStorageDatabase
virtual ~ModStorageDatabase ()=default
Public Member Functions inherited from Database
virtual bool initialized () const
virtual void verifyDatabase ()
 Open and initialize the database if needed.

Private Member Functions

Json::Value * getOrCreateJson (const std::string &modname)

Private Attributes

std::string m_storage_dir
std::unordered_map< std::string, Json::Value > m_mod_storage
std::unordered_set< std::string > m_modified

Constructor & Destructor Documentation

◆ ModStorageDatabaseFiles()

ModStorageDatabaseFiles::ModStorageDatabaseFiles ( const std::string & savedir)

References DIR_DELIM, and m_storage_dir.

◆ ~ModStorageDatabaseFiles()

virtual ModStorageDatabaseFiles::~ModStorageDatabaseFiles ( )
virtualdefault

Member Function Documentation

◆ beginSave()

void ModStorageDatabaseFiles::beginSave ( )
virtual

Implements Database.

◆ endSave()

void ModStorageDatabaseFiles::endSave ( )
virtual

Implements Database.

References fs::CreateAllDirs(), DIR_DELIM, errorstream, fastWriteJson(), fs::IsDir(), m_mod_storage, m_modified, m_storage_dir, and fs::safeWriteToFile().

Here is the call graph for this function:

◆ getModEntries()

void ModStorageDatabaseFiles::getModEntries ( const std::string & modname,
StringMap * storage )
virtual

Implements ModStorageDatabase.

References getOrCreateJson().

Here is the call graph for this function:

◆ getModEntry()

bool ModStorageDatabaseFiles::getModEntry ( const std::string & modname,
const std::string & key,
std::string * value )
virtual

Implements ModStorageDatabase.

References getOrCreateJson().

Here is the call graph for this function:

◆ getModKeys()

void ModStorageDatabaseFiles::getModKeys ( const std::string & modname,
std::vector< std::string > * storage )
virtual

Implements ModStorageDatabase.

References getOrCreateJson().

Here is the call graph for this function:

◆ getOrCreateJson()

Json::Value * ModStorageDatabaseFiles::getOrCreateJson ( const std::string & modname)
private

References DIR_DELIM, errorstream, m_mod_storage, m_storage_dir, open_ifstream(), and fs::PathExists().

Referenced by getModEntries(), getModEntry(), getModKeys(), hasModEntry(), removeModEntries(), removeModEntry(), and setModEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasModEntry()

bool ModStorageDatabaseFiles::hasModEntry ( const std::string & modname,
const std::string & key )
virtual

Implements ModStorageDatabase.

References getOrCreateJson().

Here is the call graph for this function:

◆ listMods()

void ModStorageDatabaseFiles::listMods ( std::vector< std::string > * res)
virtual

Implements ModStorageDatabase.

References fs::GetDirListing(), m_mod_storage, and m_storage_dir.

Here is the call graph for this function:

◆ removeModEntries()

bool ModStorageDatabaseFiles::removeModEntries ( const std::string & modname)
virtual

Implements ModStorageDatabase.

References getOrCreateJson(), and m_modified.

Here is the call graph for this function:

◆ removeModEntry()

bool ModStorageDatabaseFiles::removeModEntry ( const std::string & modname,
const std::string & key )
virtual

Implements ModStorageDatabase.

References getOrCreateJson(), and m_modified.

Here is the call graph for this function:

◆ setModEntry()

bool ModStorageDatabaseFiles::setModEntry ( const std::string & modname,
const std::string & key,
std::string_view value )
virtual

Implements ModStorageDatabase.

References getOrCreateJson(), and m_modified.

Here is the call graph for this function:

Member Data Documentation

◆ m_mod_storage

std::unordered_map<std::string, Json::Value> ModStorageDatabaseFiles::m_mod_storage
private

Referenced by endSave(), getOrCreateJson(), and listMods().

◆ m_modified

std::unordered_set<std::string> ModStorageDatabaseFiles::m_modified
private

◆ m_storage_dir

std::string ModStorageDatabaseFiles::m_storage_dir
private

The documentation for this class was generated from the following files: