6 #include "knowrob/semweb/PrefixRegistry.h"
7 #include "knowrob/semweb/PrefixProbe.h"
8 #include "knowrob/Logger.h"
12 PrefixRegistry::PrefixRegistry() {
13 registerPrefix_(
"owl",
"http://www.w3.org/2002/07/owl");
14 registerPrefix_(
"rdf",
"http://www.w3.org/1999/02/22-rdf-syntax-ns");
15 registerPrefix_(
"rdfs",
"http://www.w3.org/2000/01/rdf-schema");
16 registerPrefix_(
"xsd",
"http://www.w3.org/2001/XMLSchema");
17 registerPrefix_(
"qudt",
"http://data.nasa.gov/qudt/owl/qudt");
18 registerPrefix_(
"dul",
"http://www.ontologydesignpatterns.org/ont/dul/DUL.owl");
19 registerPrefix_(
"soma",
"http://www.ease-crc.org/ont/SOMA.owl");
20 registerPrefix_(
"knowrob",
"http://knowrob.org/kb/knowrob.owl");
28 static inline bool isDelimiter(
char c) {
29 return c ==
'#' || c ==
'/';
32 void PrefixRegistry::registerPrefix_(std::string_view
prefix, std::string_view uri) {
35 if (!isDelimiter(s_uri[s_uri.size() - 1])) {
39 KB_DEBUG(
"Registering prefix \"{}\" for URI {}", s_prefix, s_uri);
40 uriToAlias_[s_uri] = s_prefix;
41 aliasToURI_[s_prefix] = s_uri;
51 }
else if (isDelimiter(uri[uri.size() - 1])) {
52 auto it =
get().uriToAlias_.find(uri);
56 auto it =
get().uriToAlias_.find(withDelimiter);
65 auto it =
get().aliasToURI_.find(alias);
72 if (uri.has_value()) {
74 os << uri.value().get() << entityName;
83 std::vector<std::string_view> result;
84 for (
auto it = range_it.first; it != range_it.second; ++it) {
85 result.emplace_back(it->first.c_str());
static std::vector< std::string_view > getAliasesWithPrefix(std::string_view prefix)
static void registerPrefix(std::string_view prefix, std::string_view uri)
static OptionalStringRef aliasToUri(std::string_view alias)
static OptionalStringRef uriToAlias(std::string_view uri)
static PrefixRegistry & get()
static std::optional< std::string > createIRI(std::string_view alias, std::string_view entityName)
constexpr std::string_view prefix
std::optional< std::reference_wrapper< const std::string > > OptionalStringRef