1#ifndef _DITTO_DOCUMENT_ID_
2#define _DITTO_DOCUMENT_ID_
4#include "DocumentIdPath.hpp"
12#include "dittoffi.hpp"
22 friend class Collection;
23 friend class Document;
24 friend class DocumentOperator;
25 friend class PendingIDSpecificOperation;
26 friend class QueryOperator;
27 friend class ScopedWriteTransaction;
28 friend struct DocumentIdHasher;
29 friend class QueryResult;
31 DocumentId() =
default;
57 explicit DocumentId(nlohmann::json id_value);
59 bool operator==(
const DocumentId &rhs)
const;
60 bool operator!=(
const DocumentId &rhs)
const;
96 nlohmann::json
value()
const;
113 std::vector<uint8_t> id_bytes;
115 std::string formatted_for_query_string(
116 StringPrimitiveFormat_t string_primitive_format)
const;
118 explicit DocumentId(CDocument_t *doc_ptr);
119 explicit DocumentId(slice_boxed_uint8_t);
120 explicit DocumentId(std::vector<uint8_t> id_bytes);
123void to_json(nlohmann::json &j,
const DocumentId &d_id);
125std::vector<uint8_t> validate_id_cbor(nlohmann::json &input_val);
129struct DocumentIdHasher {
130 std::size_t operator()(
const DocumentId &k)
const {
133 std::size_t seed = k.id_bytes.size();
134 for (
auto &i : k.id_bytes) {
135 seed ^= i + 0x9e3779b9 + (seed << 6) + (seed >> 2);
Provides an interface to specify a path to a key in a document ID that you can then call a function o...
Definition DocumentIdPath.hpp:22
An identifier for a Document.
Definition DocumentId.hpp:21
DocumentIdPath operator[](std::string key) const
Used to specify a path to a key in the document ID that you can subscript further to access a nested ...
Definition DocumentId.cpp:35
bool empty() const
Returns whether or not the document ID is empty (and therefore invalid).
Definition DocumentId.cpp:43
std::string to_string() const
Returns a stringified representation of a document identifier.
Definition DocumentId.cpp:47
nlohmann::json value() const
Get the underlying value of the document identifier as a native type.
Definition DocumentId.cpp:45