knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
xsd.cpp
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 #include <set>
7 #include "knowrob/semweb/xsd.h"
8 
9 namespace knowrob::xsd {
10  class XSD {
11  public:
12  static XSD& get() {
13  static XSD instance;
14  return instance;
15  }
16 
17  static bool isStringType(std::string_view &iri)
18  { return get().stringTypes_.count(iri)>0; }
19 
20  static bool isIntegerType(std::string_view &iri)
21  { return get().integerTypes_.count(iri)>0; }
22 
23  static bool isDoubleType(std::string_view &iri)
24  { return get().doubleTypes_.count(iri)>0; }
25 
26  static bool isDateType(std::string_view &iri)
27  { return get().dateTypes_.count(iri)>0; }
28 
29  static bool isBooleanType(std::string_view &iri)
30  { return iri == IRI_boolean->stringForm(); }
31 
32  protected:
33  XSD() {
34  stringTypes_.insert(IRI_anyURI->stringForm());
35  stringTypes_.insert(IRI_string->stringForm());
36  stringTypes_.insert(IRI_token->stringForm());
37  stringTypes_.insert(IRI_normalizedString->stringForm());
38  stringTypes_.insert(IRI_language->stringForm());
39 
40  integerTypes_.insert(IRI_byte->stringForm());
41  integerTypes_.insert(IRI_int->stringForm());
42  integerTypes_.insert(IRI_integer->stringForm());
43  integerTypes_.insert(IRI_long->stringForm());
44  integerTypes_.insert(IRI_negativeInteger->stringForm());
45  integerTypes_.insert(IRI_nonNegativeInteger->stringForm());
46  integerTypes_.insert(IRI_nonPositiveInteger->stringForm());
47  integerTypes_.insert(IRI_positiveInteger->stringForm());
48  integerTypes_.insert(IRI_short->stringForm());
49  integerTypes_.insert(IRI_unsignedLong->stringForm());
50  integerTypes_.insert(IRI_unsignedInt->stringForm());
51  integerTypes_.insert(IRI_unsignedShort->stringForm());
52  integerTypes_.insert(IRI_unsignedByte->stringForm());
53 
54  doubleTypes_.insert(IRI_decimal->stringForm());
55  doubleTypes_.insert(IRI_double->stringForm());
56  doubleTypes_.insert(IRI_float->stringForm());
57 
58  dateTypes_.insert(IRI_date->stringForm());
59  dateTypes_.insert(IRI_dateTime->stringForm());
60  dateTypes_.insert(IRI_duration->stringForm());
61  dateTypes_.insert(IRI_gDay->stringForm());
62  dateTypes_.insert(IRI_gMonth->stringForm());
63  dateTypes_.insert(IRI_gMonthDay->stringForm());
64  dateTypes_.insert(IRI_gYear->stringForm());
65  dateTypes_.insert(IRI_gYearMonth->stringForm());
66  dateTypes_.insert(IRI_time->stringForm());
67  }
68  std::set<std::string_view> stringTypes_;
69  std::set<std::string_view> integerTypes_;
70  std::set<std::string_view> doubleTypes_;
71  std::set<std::string_view> dateTypes_;
72  };
73 
74  bool isStringType(std::string_view iri)
75  {
76  return XSD::isStringType(iri);
77  }
78 
79  bool isNumericType(std::string_view iri)
80  {
81  return isDoubleType(iri) || isIntegerType(iri);
82  }
83 
84  bool isIntegerType(std::string_view iri)
85  {
86  return XSD::isIntegerType(iri);
87  }
88 
89  bool isDoubleType(std::string_view iri)
90  {
91  return XSD::isDoubleType(iri);
92  }
93 
94  bool isBooleanType(std::string_view iri)
95  {
96  return XSD::isBooleanType(iri);
97  }
98 
99  bool isDateType(std::string_view iri)
100  {
101  return XSD::isDateType(iri);
102  }
103 }
const IRIAtomPtr IRI_byte
Definition: xsd.h:32
const IRIAtomPtr IRI_integer
Definition: xsd.h:22
const IRIAtomPtr IRI_positiveInteger
Definition: xsd.h:23
bool isDoubleType(std::string_view iri)
Definition: xsd.cpp:89
const IRIAtomPtr IRI_unsignedByte
Definition: xsd.h:33
const IRIAtomPtr IRI_gYear
Definition: xsd.h:46
const IRIAtomPtr IRI_decimal
Definition: xsd.h:36
const IRIAtomPtr IRI_string
Definition: xsd.h:16
const IRIAtomPtr IRI_dateTime
Definition: xsd.h:41
const IRIAtomPtr IRI_gDay
Definition: xsd.h:43
const IRIAtomPtr IRI_short
Definition: xsd.h:30
const IRIAtomPtr IRI_boolean
Definition: xsd.h:34
const IRIAtomPtr IRI_language
Definition: xsd.h:19
const IRIAtomPtr IRI_long
Definition: xsd.h:28
const IRIAtomPtr IRI_nonPositiveInteger
Definition: xsd.h:26
const IRIAtomPtr IRI_normalizedString
Definition: xsd.h:18
const IRIAtomPtr IRI_gMonth
Definition: xsd.h:44
const IRIAtomPtr IRI_int
Definition: xsd.h:21
const IRIAtomPtr IRI_unsignedShort
Definition: xsd.h:31
bool isDateType(std::string_view iri)
Definition: xsd.cpp:99
const IRIAtomPtr IRI_unsignedLong
Definition: xsd.h:29
bool isStringType(std::string_view iri)
Definition: xsd.cpp:74
bool isBooleanType(std::string_view iri)
Definition: xsd.cpp:94
bool isIntegerType(std::string_view iri)
Definition: xsd.cpp:84
const IRIAtomPtr IRI_unsignedInt
Definition: xsd.h:27
const IRIAtomPtr IRI_gYearMonth
Definition: xsd.h:47
bool isNumericType(std::string_view iri)
Definition: xsd.cpp:79
const IRIAtomPtr IRI_float
Definition: xsd.h:38
const IRIAtomPtr IRI_anyURI
Definition: xsd.h:15
const IRIAtomPtr IRI_date
Definition: xsd.h:40
const IRIAtomPtr IRI_gMonthDay
Definition: xsd.h:45
const IRIAtomPtr IRI_token
Definition: xsd.h:17
const IRIAtomPtr IRI_nonNegativeInteger
Definition: xsd.h:25
const IRIAtomPtr IRI_time
Definition: xsd.h:48
const IRIAtomPtr IRI_negativeInteger
Definition: xsd.h:24
const IRIAtomPtr IRI_duration
Definition: xsd.h:42
const IRIAtomPtr IRI_double
Definition: xsd.h:37
IRIAtomPtr iri(std::string_view ns, std::string_view name)
Definition: IRIAtom.cpp:62