NeoFOAM
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
Public Member Functions | List of all members
NeoFOAM::Document Class Reference

A class representing a document in a database. More...

#include <document.hpp>

Inheritance diagram for NeoFOAM::Document:
NeoFOAM::Dictionary

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.
 
- Public Member Functions inherited from NeoFOAM::Dictionary
 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.
 
DictionarysubDict (const std::string &key)
 Retrieves a sub-dictionary associated with the given key.
 
const DictionarysubDict (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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Document() [1/2]

NeoFOAM::Document::Document ( )

Constructs a Document with a unique ID.

◆ Document() [2/2]

NeoFOAM::Document::Document ( const Dictionary dict,
DocumentValidator  validator = hasId 
)

Constructs a Document with the given Dictionary and validator.

Parameters
dictThe Dictionary object to construct the Document from.
validatorThe validator function to use for validating the Document.

Member Function Documentation

◆ id()

std::string NeoFOAM::Document::id ( ) const
inline

Retrieves the ID of the Document.

Returns
std::string The ID of the Document.

Definition at line 82 of file document.hpp.

◆ validate()

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.

Returns
true if the Document is valid, false otherwise.

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