Cuberite
A lightweight, fast and extensible game server for Minecraft
SettingsRepositoryInterface.h
Go to the documentation of this file.
1 
2 #pragma once
3 
5 {
6 public:
7 
8  enum errors
9  {
10  noID = -1,
11  };
12 
14  virtual ~cSettingsRepositoryInterface() = default;
16 
18  virtual bool KeyExists(const AString keyname) const = 0;
19 
21  virtual bool HasValue(const AString & a_KeyName, const AString & a_ValueName) const = 0;
22 
24  virtual int AddKeyName(const AString & keyname) = 0;
25 
27  virtual bool AddKeyComment(const AString & keyname, const AString & comment) = 0;
28 
30  virtual AString GetKeyComment(const AString & keyname, const int commentID) const = 0;
31 
33  virtual bool DeleteKeyComment(const AString & keyname, const int commentID) = 0;
34 
37  virtual void AddValue (const AString & a_KeyName, const AString & a_ValueName, const AString & a_Value) = 0;
38 
40  virtual std::vector<std::pair<AString, AString>> GetValues(AString a_keyName) = 0;
41 
43  virtual AString GetValue (const AString & keyname, const AString & valuename, const AString & defValue = "") const = 0;
44 
46  virtual AString GetValueSet (const AString & keyname, const AString & valuename, const AString & defValue = "") = 0;
47  virtual int GetValueSetI(const AString & keyname, const AString & valuename, const int defValue = 0) = 0;
48  virtual Int64 GetValueSetI(const AString & keyname, const AString & valuename, const Int64 defValue = 0) = 0;
49  virtual bool GetValueSetB(const AString & keyname, const AString & valuename, const bool defValue = false) = 0;
50 
54  virtual bool SetValue (const AString & a_KeyName, const AString & a_ValueName, const AString & a_Value, const bool a_CreateIfNotExists = true) = 0;
55  virtual bool SetValueI(const AString & a_KeyName, const AString & a_ValueName, const int a_Value, const bool a_CreateIfNotExists = true) = 0;
56 
58  virtual bool DeleteValue(const AString & keyname, const AString & valuename) = 0;
59 
60 
62  virtual bool Flush() = 0;
63 };
signed long long Int64
Definition: Globals.h:151
std::string AString
Definition: StringUtils.h:11
virtual bool DeleteValue(const AString &keyname, const AString &valuename)=0
Deletes the specified key, value pair.
DISALLOW_COPY_AND_ASSIGN(cSettingsRepositoryInterface)
virtual bool GetValueSetB(const AString &keyname, const AString &valuename, const bool defValue=false)=0
virtual int AddKeyName(const AString &keyname)=0
Add a key name.
virtual AString GetValueSet(const AString &keyname, const AString &valuename, const AString &defValue="")=0
Gets the value; if not found, write the default to the repository.
virtual bool AddKeyComment(const AString &keyname, const AString &comment)=0
Add a key comment, will always fail if the repository does not support comments.
virtual bool DeleteKeyComment(const AString &keyname, const int commentID)=0
Delete a key comment, will always fail if the repository does not support comments.
virtual std::vector< std::pair< AString, AString > > GetValues(AString a_keyName)=0
returns a vector containing a name, value pair for each value under the key
virtual Int64 GetValueSetI(const AString &keyname, const AString &valuename, const Int64 defValue=0)=0
virtual bool KeyExists(const AString keyname) const =0
Returns true iff the specified key exists.
virtual AString GetValue(const AString &keyname, const AString &valuename, const AString &defValue="") const =0
Get the value at the specified key and value, returns defValue on failure.
virtual void AddValue(const AString &a_KeyName, const AString &a_ValueName, const AString &a_Value)=0
Adds a new value to the specified key.
virtual ~cSettingsRepositoryInterface()=default
virtual int GetValueSetI(const AString &keyname, const AString &valuename, const int defValue=0)=0
virtual AString GetKeyComment(const AString &keyname, const int commentID) const =0
Return a key comment, returns "" for repositories that do not return comments.
virtual bool SetValue(const AString &a_KeyName, const AString &a_ValueName, const AString &a_Value, const bool a_CreateIfNotExists=true)=0
Overwrites the value of the key, value pair Specify the optional parameter as false if you do not wan...
virtual bool Flush()=0
Writes the changes to the backing store, if the repository has one.
virtual bool HasValue(const AString &a_KeyName, const AString &a_ValueName) const =0
Returns true iff the specified value exists.
virtual bool SetValueI(const AString &a_KeyName, const AString &a_ValueName, const int a_Value, const bool a_CreateIfNotExists=true)=0