CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::StringDatabase Class Referenceabstract

The interface for all databases. You can derive own databases from it. More...

#include <CeresEngine/Foundation/StringID.hpp>

Inheritance diagram for CeresEngine::StringDatabase:
CeresEngine::DummyStringDatabase CeresEngine::MapStringDatabase

Public Member Functions

 StringDatabase (const StringDatabase &)=delete
 
 StringDatabase (StringDatabase &&)=delete
 
virtual ~StringDatabase ()=default
 
virtual StringID::Status insert (StringID::Hash hash, StringView string)=0
 Inserts a new hash-string-pair with prefix (optional) into the internal database.
 
virtual StringID::Status insertPrefix (StringID::Hash hash, StringID::Hash prefix, StringView string)
 Inserts a hash-string-pair with given prefix into the internal database.
 
virtual StringView lookup (StringID::Hash hash) const noexcept=0
 Returns the string stored with a given hash.
 

Static Public Member Functions

static StringDatabasegetDefault () noexcept
 

Protected Member Functions

 StringDatabase ()=default
 

Detailed Description

The interface for all databases. You can derive own databases from it.

Constructor & Destructor Documentation

◆ StringDatabase() [1/3]

CeresEngine::StringDatabase::StringDatabase ( const StringDatabase )
delete
Note
Databases are not copy- or moveable.

◆ StringDatabase() [2/3]

CeresEngine::StringDatabase::StringDatabase ( StringDatabase &&  )
delete

◆ ~StringDatabase()

virtual CeresEngine::StringDatabase::~StringDatabase ( )
virtualdefault

◆ StringDatabase() [3/3]

CeresEngine::StringDatabase::StringDatabase ( )
protecteddefault

Member Function Documentation

◆ getDefault()

static StringDatabase & CeresEngine::StringDatabase::getDefault ( )
staticnoexcept
Returns
The default string ID database.

◆ insert()

virtual StringID::Status CeresEngine::StringDatabase::insert ( StringID::Hash  hash,
StringView  string 
)
pure virtual

Inserts a new hash-string-pair with prefix (optional) into the internal database.

Note
The string must be copied prior to storing, it may not stay valid.
Parameters
hashThe hash of the string.
stringThe string which does not need to be null-terminated.
Returns
The status of the insertion.

Implemented in CeresEngine::MapStringDatabase, and CeresEngine::DummyStringDatabase.

◆ insertPrefix()

virtual StringID::Status CeresEngine::StringDatabase::insertPrefix ( StringID::Hash  hash,
StringID::Hash  prefix,
StringView  string 
)
virtual

Inserts a hash-string-pair with given prefix into the internal database.

Note
The default implementation performs a lookup of the prefix string and appends it, then it calls insert. Override it if you can do it more efficiently.
Parameters
hashThe hash of the string plus prefix.
prefixThe hash of the prefix-string.
stringThe suffix which does not need to be null-terminated.
Returns
The status of the insertion.

Reimplemented in CeresEngine::MapStringDatabase, and CeresEngine::DummyStringDatabase.

◆ lookup()

virtual StringView CeresEngine::StringDatabase::lookup ( StringID::Hash  hash) const
pure virtualnoexcept

Returns the string stored with a given hash.

Note
It is guaranteed that the hash value has been inserted before.
Returns
A null-terminated string belonging to the hash code or an error message if the database does not store anything. The return value must stay valid as long as the database exists.

Implemented in CeresEngine::MapStringDatabase, and CeresEngine::DummyStringDatabase.


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