Program Listing for File Namespace.hpp

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

#ifndef RDF4CPP_NAMESPACE_HPP
#define RDF4CPP_NAMESPACE_HPP

#include <rdf4cpp/IRI.hpp>

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

#include <string>
#include <string_view>

namespace rdf4cpp {

struct Namespace {
protected:
    std::string namespace_iri_;

    storage::DynNodeStoragePtr node_storage_;

    // TODO: a faster, less memory efficient map would be better.
    mutable dice::sparse_map::sparse_map<std::string, storage::identifier::NodeBackendID,
                                         dice::hash::DiceHashwyhash<std::string_view>, std::equal_to<>> cache_;

public:
    explicit Namespace(std::string_view namespace_iri,
                       storage::DynNodeStoragePtr node_storage = storage::default_node_storage);

    std::string_view name_space() const noexcept;

    storage::DynNodeStoragePtr node_storage() const;

    virtual IRI operator+(std::string_view suffix) const;

    virtual void clear() const;
};
}  // namespace rdf4cpp

#endif  //RDF4CPP_NAMESPACE_HPP