6 #ifndef MAP_STD_NS_CRTPB_HPP_
7 #define MAP_STD_NS_CRTPB_HPP_
8 #include "boost/assert.hpp"
10 #include "owlcpp/detail/map_traits.hpp"
12 #include "owlcpp/terms/detail/max_standard_id.hpp"
21 typedef detail::Map_traits<Super> traits;
22 typedef typename traits::map_std_type map_std_type;
23 typedef typename traits::map_ns_type map_ns_type;
25 map_std_type
const& _map_std()
const {
26 return static_cast<Super const&
>(*this).map_std_;
29 map_ns_type
const& _map_ns()
const {
30 return static_cast<Super const&
>(*this).map_ns_;
33 map_ns_type& _map_ns() {
34 return static_cast<Super&
>(*this).map_ns_;
40 return _map_std().is_standard(nsid) ?
41 _map_std()[nsid] : _map_ns()[nsid];
45 return _map_std().is_standard(nsid) ?
46 _map_std().at(nsid) : _map_ns().at(nsid);
50 return _map_std().is_standard(nsid) ?
51 _map_std().find(nsid) : _map_ns().find(nsid);
59 return _map_std().is_standard(nsid) ?
60 _map_std().prefix(nsid) : _map_ns().prefix(nsid);
68 if(
Ns_id const*
const id = _map_std().find(iri) )
return id;
69 return _map_ns().find(iri);
78 return _map_ns().find_prefix(pref);
82 if(
Ns_id const*
const iid = find(iri) )
return *iid;
83 return _map_ns().insert(iri);
92 typedef typename Super::Err Err;
93 if( nsid < detail::min_ns_id() ) {
94 if( pref.empty() || pref == _map_std().prefix(nsid) )
return;
95 BOOST_THROW_EXCEPTION(
97 <<
typename Err::msg_t(
"cannot re-define standard prefix")
98 <<
typename Err::str1_t(pref)
99 <<
typename Err::str2_t(_map_std().
prefix(nsid))
102 BOOST_ASSERT( _map_ns().find(nsid) );
104 _map_ns().set_prefix(nsid);
107 Ns_id const*
const iid0 = _map_ns().find_prefix(pref);
109 if( *iid0 == nsid )
return;
110 BOOST_THROW_EXCEPTION(
112 <<
typename Err::msg_t(
"prefix reserved for different IRI")
113 <<
typename Err::str1_t(pref)
114 <<
typename Err::str2_t(at(nsid).str())
115 <<
typename Err::str3_t(at(*iid0).str())
118 _map_ns().set_prefix(nsid, pref);