NeoFOAM
WIP Prototype of a modern OpenFOAM core
|
A class representing a document in a database. More...
#include <document.hpp>
Public Member Functions | |
Document () | |
Constructs a Document with a unique ID. | |
Document (const Dictionary &dict, DocumentValidator validator=hasId) | |
Constructs a Document with the given Dictionary and validator. | |
bool | validate () const |
Validates the Document. | |
std::string | id () const |
Retrieves the ID of the Document. | |
![]() | |
Dictionary ()=default | |
Dictionary (const std::unordered_map< std::string, std::any > &keyValuePairs) | |
Dictionary (const std::initializer_list< std::pair< std::string, std::any > > &initList) | |
void | insert (const std::string &key, const std::any &value) |
Inserts a key-value pair into the dictionary. | |
bool | contains (const std::string &key) const |
Checks if the given key is present in the dictionary. | |
void | remove (const std::string &key) |
Removes an entry from the dictionary based on the specified key. | |
std::any & | operator[] (const std::string &key) |
Accesses the value associated with the given key. | |
const std::any & | operator[] (const std::string &key) const |
Accesses the value associated with the given key. | |
template<typename T > | |
T & | get (const std::string &key) |
Retrieves the value associated with the given key, casting it to the specified type. | |
template<typename T > | |
const T & | get (const std::string &key) const |
Retrieves the value associated with the given key, casting it to the specified type. | |
bool | isDict (const std::string &key) const |
Checks if the value associated with the given key is a dictionary. | |
Dictionary & | subDict (const std::string &key) |
Retrieves a sub-dictionary associated with the given key. | |
const Dictionary & | subDict (const std::string &key) const |
Retrieves a sub-dictionary associated with the given key. | |
std::vector< std::string > | keys () const |
Retrieves the keys of the dictionary. | |
std::unordered_map< std::string, std::any > & | getMap () |
Retrieves the underlying unordered map of the dictionary. | |
const std::unordered_map< std::string, std::any > & | getMap () const |
Retrieves the underlying unordered map of the dictionary. | |
bool | empty () const |
Checks whether the dictionary is empty. | |
A class representing a document in a database.
The Document class represents a document in a database. It is a subclass of the Dictionary class and provides additional functionality for validating the document and retrieving its ID.
Definition at line 50 of file document.hpp.
NeoFOAM::Document::Document | ( | ) |
Constructs a Document with a unique ID.
NeoFOAM::Document::Document | ( | const Dictionary & | dict, |
DocumentValidator | validator = hasId |
||
) |
Constructs a Document with the given Dictionary and validator.
dict | The Dictionary object to construct the Document from. |
validator | The validator function to use for validating the Document. |
|
inline |
Retrieves the ID of the Document.
Definition at line 82 of file document.hpp.
bool NeoFOAM::Document::validate | ( | ) | const |
Validates the Document.
This function validates the Document by calling the validator function with the Document's Dictionary object as an argument.