owlcpp  v0.3.3-86-g20d8c12~
C++ library for working with OWL ontologies
 All Classes Namespaces Files Functions Macros Pages
crtpb_ns_node_iri.hpp
Go to the documentation of this file.
1 
6 #ifndef CRTPB_NS_NODE_IRI_HPP_
7 #define CRTPB_NS_NODE_IRI_HPP_
8 #include "owlcpp/detail/map_traits.hpp"
10 
11 namespace owlcpp{
12 
16 template<class Super> struct Crtpb_ns_node_iri {
17 
24  Node_id insert_node_iri(std::string const& iri) {
25  BOOST_CONCEPT_ASSERT((Ns_store<Super>));
26  BOOST_CONCEPT_ASSERT((Iri_node_store<Super>));
27  Super& super = static_cast<Super&>(*this);
28  std::size_t n;
29  const Ns_id iid = super.insert(remove_fragment(iri, n));
30  try{
31  return super.insert_node_iri( iid, iri.substr(n) );
32  } catch(base_exception&) {
33  typedef typename Super::Err Err;
34  BOOST_THROW_EXCEPTION(
35  Err()
36  << typename Err::msg_t("error inserting IRI")
37  << typename Err::str1_t( iri )
38  << typename Err::nested_t(boost::current_exception())
39  );
40  }
41  }
42 
43  Node_id const* find_node_iri(std::string const& iri) const {
44  BOOST_CONCEPT_ASSERT((Ns_store<Super>));
45  BOOST_CONCEPT_ASSERT((Iri_node_store<Super>));
46  std::size_t n;
47  Super const& super = static_cast<Super const&>(*this);
48  Ns_id const*const ns_id = super.find(remove_fragment(iri, n));
49  if( ! ns_id ) return 0;
50  return super.find_node_iri( *ns_id, iri.substr(n) );
51  }
52 
53 };
54 
55 
56 }//namespace owlcpp
57 #endif /* CRTPB_NS_NODE_IRI_HPP_ */
Node_id insert_node_iri(std::string const &iri)
if not already present, store IRI reference node
Definition: crtpb_ns_node_iri.hpp:24
Definition: ns_id.hpp:15
Ns_iri remove_fragment(std::string const &iri, std::size_t &n)
remove fragment identifier from the rest of IRI string
Definition: ns_iri.hpp:44
Definition: crtpb_ns_node_iri.hpp:16
Definition: exception.hpp:23
Term identifier.
Definition: node_id.hpp:15