owlcpp  v0.3.3~
C++ library for working with OWL ontologies
 All Classes Namespaces Files Functions Macros Pages
check_ontology_id.hpp
Go to the documentation of this file.
1 
6 #ifndef CHECK_ONTOLOGY_ID_HPP_
7 #define CHECK_ONTOLOGY_ID_HPP_
8 #include <string>
10 
11 namespace owlcpp{
12 
16 struct Check_id {
17  struct Err : public Input_err {};
18  virtual void operator()(std::string const& iri, std::string const&) const {
19  if( iri.empty() ) BOOST_THROW_EXCEPTION(
20  Err()
21  << Err::msg_t("empty ontologyIRI")
22  );
23  }
24  virtual ~Check_id() {}
25 };
26 
29 struct No_check : public Check_id {
30  void operator()(std::string const& , std::string const&) const {}
31 };
32 
36 class Check_iri : public Check_id {
37 public:
38  Check_iri(std::string const& iri) : iri_(iri) {}
39 
40  void operator()(std::string const& iri, std::string const& ver) const {
41  Check_id::operator ()(iri, ver);
42  if( iri_ != iri && iri_ != ver ) BOOST_THROW_EXCEPTION(
43  Err()
44  << Err::msg_t("ontology IRI mismatch")
45  << Err::str1_t(iri)
46  << Err::str2_t(ver)
47  << Err::str3_t(iri_)
48  );
49  }
50 private:
51  const std::string iri_;
52 };
53 
58 class Check_both : public Check_id {
59 public:
60  Check_both(std::string const& iri, std::string const& ver)
61  : iri_(iri), ver_(ver) {}
62 
63  void operator()(std::string const& iri, std::string const& ver) const {
64  Check_id::operator ()(iri, ver);
65  if( iri_ != iri ) BOOST_THROW_EXCEPTION(
66  Err()
67  << Err::msg_t("ontology IRI mismatch")
68  << Err::str1_t(iri)
69  << Err::str2_t(iri_)
70  );
71  if( ver_ != ver ) BOOST_THROW_EXCEPTION(
72  Err()
73  << Err::msg_t("ontology versionIRI mismatch")
74  << Err::str1_t(ver)
75  << Err::str2_t(ver_)
76  );
77  }
78 private:
79  const std::string iri_;
80  const std::string ver_;
81 };
82 
83 }//namespace owlcpp
84 #endif /* CHECK_ONTOLOGY_ID_HPP_ */