owlcpp  v0.3.3~
C++ library for working with OWL ontologies
 All Classes Namespaces Files Functions Macros Pages
map_node_literal_crtpb.hpp
Go to the documentation of this file.
1 
6 #ifndef MAP_NODE_LITERAL_CRTPB_HPP_
7 #define MAP_NODE_LITERAL_CRTPB_HPP_
8 #include "boost/assert.hpp"
9 #include "boost/foreach.hpp"
10 
11 #include "owlcpp/detail/map_traits.hpp"
13 
14 namespace owlcpp{
15 
19 template<class Super> class Map_node_literal_crtpb {
20  typedef detail::Map_traits<Super> traits;
21  typedef typename traits::map_node_type map_node_type;
22 
23  map_node_type const& _map_node() const {
24  return static_cast<Super const&>(*this).map_node_;
25  }
26 
27  map_node_type& _map_node() {
28  return static_cast<Super&>(*this).map_node_;
29  }
30 
31 public:
32 
39  std::string const& value,
40  std::string const& dt_iri,
41  std::string const& lang = ""
42  ) const {
43  Node_id const* dt = static_cast<Super const&>(*this).find_node_iri(dt_iri);
44  if( ! dt ) return 0;
45  return _map_node().find_literal(value, *dt, lang);
46  }
47 
48 
60  std::string const& value,
61  const Node_id dt_id,
62  std::string const& lang = ""
63  ) {
64  BOOST_CONCEPT_ASSERT((Iri_node_store<Super>));
65  BOOST_ASSERT(
66  static_cast<Super const&>(*this).find(dt_id) &&
67  "invalid datatype ID"
68  );
69  return _map_node().insert_literal(value, dt_id, lang);
70  }
71 
83  std::string const& value,
84  std::string const& dt_iri,
85  std::string const& lang = ""
86  ) {
87  BOOST_CONCEPT_ASSERT((Ns_iri_node_store<Super>));
88  const Node_id dt_id = static_cast<Super&>(*this).insert_node_iri(dt_iri);
89  return insert_literal(value, dt_id, lang);
90  }
91 };
92 
93 }//namespace owlcpp
94 #endif /* MAP_NODE_LITERAL_CRTPB_HPP_ */