Program Listing for File Anonymizer.hpp

Return to documentation for file (src/rdf4cpp/util/Anonymizer.hpp)

#ifndef RDF4CPP_ANONYMIZER_HPP
#define RDF4CPP_ANONYMIZER_HPP

#include <rdf4cpp/Quad.hpp>
#include <rdf4cpp/Statement.hpp>
#include <rdf4cpp/storage/NodeStorage.hpp>

#include <dice/sparse-map/sparse_map.hpp>

#include <random>
#include <span>

namespace rdf4cpp::util {

struct Anonymizer {
private:
    std::uniform_int_distribution<uint64_t> dist_;

    storage::DynNodeStoragePtr node_storage_;
    dice::sparse_map::sparse_map<storage::identifier::NodeBackendHandle, storage::identifier::NodeBackendID> lookup_;

    void gen_random_id(std::span<char> output);

public:
    explicit Anonymizer(storage::DynNodeStoragePtr node_storage = storage::default_node_storage);

    [[nodiscard]] storage::DynNodeStoragePtr node_storage() const noexcept;

    [[nodiscard]] IRI anonymize(Node const &non_anon);

    [[nodiscard]] Statement anonymize(Statement const &non_anon);

    [[nodiscard]] Quad anonymize(Quad const &non_anon);
};

} // namespace rdf4cpp::util

#endif // RDF4CPP_ANONYMIZER_HPP