82 std::string
id()
const {
return get<std::string>(
"id"); }
91 static std::string generateID()
93 static std::atomic<int> counter {0};
94 return "doc_" + std::to_string(counter++);
A class representing a dictionary that stores key-value pairs.
A class representing a document in a database.
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.
Document()
Constructs a Document with a unique ID.
bool hasId(Dictionary doc)
Checks if a Dictionary object has an "id" key.
const std::string & name(const NeoFOAM::Document &doc)
Retrieves the name of a Document.
std::function< bool(Dictionary)> DocumentValidator
A type alias for a function that validates a Dictionary object.