Cuberite
A lightweight, fast and extensible game server for Minecraft
Classes | Public Member Functions | Private Attributes | List of all members
cMemorySettingsRepository Class Reference

#include <MemorySettingsRepository.h>

Inheritance diagram for cMemorySettingsRepository:
Inheritance graph
[legend]
Collaboration diagram for cMemorySettingsRepository:
Collaboration graph
[legend]

Classes

struct  sValue
 

Public Member Functions

virtual bool AddKeyComment (const AString &keyname, const AString &comment) override
 Add a key comment, will always fail if the repository does not support comments. More...
 
virtual int AddKeyName (const AString &keyname) override
 Add a key name. More...
 
virtual void AddValue (const AString &a_KeyName, const AString &a_ValueName, const AString &a_Value) override
 Adds a new value to the specified key. More...
 
void AddValue (const AString &a_KeyName, const AString &a_ValueName, const bool a_Value)
 
void AddValue (const AString &a_KeyName, const AString &a_ValueName, const Int64 a_Value)
 
virtual bool DeleteKeyComment (const AString &keyname, const int commentID) override
 Delete a key comment, will always fail if the repository does not support comments. More...
 
virtual bool DeleteValue (const AString &keyname, const AString &valuename) override
 Deletes the specified key, value pair. More...
 
virtual bool Flush () override
 Writes the changes to the backing store, if the repository has one. More...
 
virtual AString GetKeyComment (const AString &keyname, const int commentID) const override
 Return a key comment, returns "" for repositories that do not return comments. More...
 
virtual AString GetValue (const AString &keyname, const AString &valuename, const AString &defValue="") const override
 Get the value at the specified key and value, returns defValue on failure. More...
 
virtual std::vector< std::pair< AString, AString > > GetValues (AString a_keyName) override
 returns a vector containing a name, value pair for each value under the key More...
 
virtual AString GetValueSet (const AString &keyname, const AString &valuename, const AString &defValue="") override
 Gets the value; if not found, write the default to the repository. More...
 
virtual bool GetValueSetB (const AString &keyname, const AString &valuename, const bool defValue=false) override
 
virtual int GetValueSetI (const AString &keyname, const AString &valuename, const int defValue=0) override
 
virtual Int64 GetValueSetI (const AString &keyname, const AString &valuename, const Int64 defValue=0) override
 
virtual bool HasValue (const AString &a_KeyName, const AString &a_ValueName) const override
 Returns true iff the specified value exists. More...
 
virtual bool KeyExists (const AString keyname) const override
 Returns true iff the specified key exists. More...
 
void SetReadOnly ()
 
virtual bool SetValue (const AString &a_KeyName, const AString &a_ValueName, const AString &a_Value, const bool a_CreateIfNotExists=true) override
 Overwrites the value of the key, value pair Specify the optional parameter as false if you do not want the value created if it doesn't exist. More...
 
virtual bool SetValueI (const AString &a_KeyName, const AString &a_ValueName, const int a_Value, const bool a_CreateIfNotExists=true) override
 
- Public Member Functions inherited from cSettingsRepositoryInterface
 cSettingsRepositoryInterface ()=default
 
 DISALLOW_COPY_AND_ASSIGN (cSettingsRepositoryInterface)
 
virtual ~cSettingsRepositoryInterface ()=default
 

Private Attributes

std::unordered_map< AString, std::unordered_multimap< AString, sValue > > m_Map {}
 
bool m_Writable = true
 

Additional Inherited Members

- Public Types inherited from cSettingsRepositoryInterface
enum  errors { noID = -1 }
 

Detailed Description

Definition at line 6 of file MemorySettingsRepository.h.

Member Function Documentation

◆ AddKeyComment()

bool cMemorySettingsRepository::AddKeyComment ( const AString keyname,
const AString comment 
)
overridevirtual

Add a key comment, will always fail if the repository does not support comments.

Implements cSettingsRepositoryInterface.

Definition at line 43 of file MemorySettingsRepository.cpp.

◆ AddKeyName()

int cMemorySettingsRepository::AddKeyName ( const AString keyname)
overridevirtual

Add a key name.

Return value is not required to mean anything

Implements cSettingsRepositoryInterface.

Definition at line 33 of file MemorySettingsRepository.cpp.

◆ AddValue() [1/3]

void cMemorySettingsRepository::AddValue ( const AString a_KeyName,
const AString a_ValueName,
const AString a_Value 
)
overridevirtual

Adds a new value to the specified key.

If a value of the same name already exists, creates another one

Implements cSettingsRepositoryInterface.

Definition at line 70 of file MemorySettingsRepository.cpp.

◆ AddValue() [2/3]

void cMemorySettingsRepository::AddValue ( const AString a_KeyName,
const AString a_ValueName,
const bool  a_Value 
)

Definition at line 94 of file MemorySettingsRepository.cpp.

◆ AddValue() [3/3]

void cMemorySettingsRepository::AddValue ( const AString a_KeyName,
const AString a_ValueName,
const Int64  a_Value 
)

Definition at line 82 of file MemorySettingsRepository.cpp.

◆ DeleteKeyComment()

bool cMemorySettingsRepository::DeleteKeyComment ( const AString keyname,
const int  commentID 
)
overridevirtual

Delete a key comment, will always fail if the repository does not support comments.

Implements cSettingsRepositoryInterface.

Definition at line 61 of file MemorySettingsRepository.cpp.

◆ DeleteValue()

bool cMemorySettingsRepository::DeleteValue ( const AString keyname,
const AString valuename 
)
overridevirtual

Deletes the specified key, value pair.

Implements cSettingsRepositoryInterface.

Definition at line 287 of file MemorySettingsRepository.cpp.

◆ Flush()

bool cMemorySettingsRepository::Flush ( )
overridevirtual

Writes the changes to the backing store, if the repository has one.

Implements cSettingsRepositoryInterface.

Definition at line 311 of file MemorySettingsRepository.cpp.

◆ GetKeyComment()

AString cMemorySettingsRepository::GetKeyComment ( const AString keyname,
const int  commentID 
) const
overridevirtual

Return a key comment, returns "" for repositories that do not return comments.

Implements cSettingsRepositoryInterface.

Definition at line 52 of file MemorySettingsRepository.cpp.

◆ GetValue()

AString cMemorySettingsRepository::GetValue ( const AString keyname,
const AString valuename,
const AString defValue = "" 
) const
overridevirtual

Get the value at the specified key and value, returns defValue on failure.

Implements cSettingsRepositoryInterface.

Definition at line 120 of file MemorySettingsRepository.cpp.

◆ GetValues()

std::vector< std::pair< AString, AString > > cMemorySettingsRepository::GetValues ( AString  a_keyName)
overridevirtual

returns a vector containing a name, value pair for each value under the key

Implements cSettingsRepositoryInterface.

Definition at line 106 of file MemorySettingsRepository.cpp.

◆ GetValueSet()

AString cMemorySettingsRepository::GetValueSet ( const AString keyname,
const AString valuename,
const AString defValue = "" 
)
overridevirtual

Gets the value; if not found, write the default to the repository.

Implements cSettingsRepositoryInterface.

Definition at line 139 of file MemorySettingsRepository.cpp.

◆ GetValueSetB()

bool cMemorySettingsRepository::GetValueSetB ( const AString keyname,
const AString valuename,
const bool  defValue = false 
)
overridevirtual

Implements cSettingsRepositoryInterface.

Definition at line 202 of file MemorySettingsRepository.cpp.

◆ GetValueSetI() [1/2]

int cMemorySettingsRepository::GetValueSetI ( const AString keyname,
const AString valuename,
const int  defValue = 0 
)
overridevirtual

Implements cSettingsRepositoryInterface.

Definition at line 160 of file MemorySettingsRepository.cpp.

◆ GetValueSetI() [2/2]

Int64 cMemorySettingsRepository::GetValueSetI ( const AString keyname,
const AString valuename,
const Int64  defValue = 0 
)
overridevirtual

Implements cSettingsRepositoryInterface.

Definition at line 181 of file MemorySettingsRepository.cpp.

◆ HasValue()

bool cMemorySettingsRepository::HasValue ( const AString a_KeyName,
const AString a_ValueName 
) const
overridevirtual

Returns true iff the specified value exists.

Implements cSettingsRepositoryInterface.

Definition at line 18 of file MemorySettingsRepository.cpp.

◆ KeyExists()

bool cMemorySettingsRepository::KeyExists ( const AString  keyname) const
overridevirtual

Returns true iff the specified key exists.

Implements cSettingsRepositoryInterface.

Definition at line 9 of file MemorySettingsRepository.cpp.

◆ SetReadOnly()

void cMemorySettingsRepository::SetReadOnly ( )
inline

Definition at line 43 of file MemorySettingsRepository.h.

◆ SetValue()

bool cMemorySettingsRepository::SetValue ( const AString a_KeyName,
const AString a_ValueName,
const AString a_Value,
const bool  a_CreateIfNotExists = true 
)
overridevirtual

Overwrites the value of the key, value pair Specify the optional parameter as false if you do not want the value created if it doesn't exist.

Returns true if value set, false otherwise.

Implements cSettingsRepositoryInterface.

Definition at line 223 of file MemorySettingsRepository.cpp.

◆ SetValueI()

bool cMemorySettingsRepository::SetValueI ( const AString a_KeyName,
const AString a_ValueName,
const int  a_Value,
const bool  a_CreateIfNotExists = true 
)
overridevirtual

Implements cSettingsRepositoryInterface.

Definition at line 255 of file MemorySettingsRepository.cpp.

Member Data Documentation

◆ m_Map

std::unordered_map<AString, std::unordered_multimap<AString, sValue> > cMemorySettingsRepository::m_Map {}
private

Definition at line 101 of file MemorySettingsRepository.h.

◆ m_Writable

bool cMemorySettingsRepository::m_Writable = true
private

Definition at line 50 of file MemorySettingsRepository.h.


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