knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
PrefixRegistry.h
Go to the documentation of this file.
1 /*
2  * This file is part of KnowRob, please consult
3  * https://github.com/knowrob/knowrob for license details.
4  */
5 
6 #ifndef KNOWROB_PREFIX_REGISTRY_H
7 #define KNOWROB_PREFIX_REGISTRY_H
8 
9 #include <string>
10 #include <map>
11 #include <functional>
12 #include <optional>
13 
14 namespace knowrob {
15  using OptionalStringRef = std::optional<std::reference_wrapper<const std::string>>;
16 
20  class PrefixRegistry {
21  public:
25  static PrefixRegistry &get();
26 
33  static void registerPrefix(std::string_view prefix, std::string_view uri);
34 
40  static OptionalStringRef uriToAlias(std::string_view uri);
41 
47  static OptionalStringRef aliasToUri(std::string_view alias);
48 
55  static std::optional<std::string> createIRI(std::string_view alias, std::string_view entityName);
56 
61  static std::vector<std::string_view> getAliasesWithPrefix(std::string_view prefix);
62 
66  using Iterator = std::map<std::string, std::string>::iterator;
67 
71  Iterator begin() { return uriToAlias_.begin(); }
72 
76  Iterator end() { return uriToAlias_.end(); }
77 
78  private:
79  std::map<std::string, std::string, std::less<>> uriToAlias_;
80  std::map<std::string, std::string, std::less<>> aliasToURI_;
81 
83 
84  void registerPrefix_(std::string_view prefix, std::string_view uri);
85  };
86 }
87 
88 
89 #endif //KNOWROB_PREFIX_REGISTRY_H
std::map< std::string, std::string >::iterator Iterator
static void registerPrefix(std::string_view prefix, std::string_view uri)
static std::optional< std::string > createIRI(std::string_view alias, std::string_view entityName)
static OptionalStringRef aliasToUri(std::string_view alias)
static std::vector< std::string_view > getAliasesWithPrefix(std::string_view prefix)
static PrefixRegistry & get()
static OptionalStringRef uriToAlias(std::string_view uri)
constexpr std::string_view prefix
Definition: owl.h:14
std::optional< std::reference_wrapper< const std::string > > OptionalStringRef