1#ifndef DITTO_DOCUMENT_ID_H
2#define DITTO_DOCUMENT_ID_H
4#include "DocumentIdPath.hpp"
12#include "dittoffi.hpp"
24 friend class Collection;
25 friend class Document;
26 friend class DocumentOperator;
27 friend class PendingIDSpecificOperation;
28 friend class QueryOperator;
29 friend class ScopedWriteTransaction;
30 friend struct DocumentIdHasher;
31 friend class QueryResult;
33 DocumentId() =
default;
61 bool operator==(
const DocumentId &rhs)
const;
62 bool operator!=(
const DocumentId &rhs)
const;
64 DITTO_DISABLE_DEPRECATED_WARNINGS(
"DocumentIdPath is deprecated")
85 DITTO_REENABLE_WARNINGS
119 std::vector<uint8_t> id_bytes;
121 std::
string formatted_for_query_string(
122 StringPrimitiveFormat_t string_primitive_format) const;
124 explicit DocumentId(CDocument_t *doc_ptr);
125 explicit DocumentId(slice_boxed_uint8_t);
126 explicit DocumentId(std::vector<uint8_t> id_bytes);
129void to_json(nlohmann::json &j, const DocumentId &d_id);
131std::vector<uint8_t> validate_id_cbor(nlohmann::json &input_val);
137struct DITTO_DEPRECATED_BECAUSE(
138 "Use DQL (Ditto Query Language) instead. For more information see: "
139 "https://ditto.com/link/legacy-to-dql-guide") DocumentIdHasher {
140 std::size_t operator()(
const DocumentId &k)
const {
143 std::size_t seed = k.id_bytes.size();
144 for (
const auto &i : k.id_bytes) {
146 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:28
Namespace for the Ditto C++ SDK types and functions.
Definition AbstractDocumentPath.hpp:19
bool empty() const
Returns whether or not the document ID is empty (and therefore invalid).
nlohmann::json value() const
Get the underlying value of the document identifier as a native type.
std::string to_string() const
Returns a stringified representation of a document identifier.
DocumentId(nlohmann::json id_value)
Creates a new DocumentId.