knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::XSDAtomic Class Reference

#include <XSDAtomic.h>

Inheritance diagram for knowrob::XSDAtomic:
Collaboration diagram for knowrob::XSDAtomic:

Public Member Functions

 XSDAtomic (XSDType xsdType)
 
std::string_view xsdTypeIRI () const
 
XSDType xsdType () const
 
 XSDAtomic (XSDType xsdType)
 
std::string_view xsdTypeIRI () const
 
XSDType xsdType () const
 
- Public Member Functions inherited from knowrob::RDFNode
 RDFNode (RDFNodeType rdfNodeType)
 
auto rdfNodeType () const
 
 RDFNode (RDFNodeType rdfNodeType)
 
auto rdfNodeType () const
 
- Public Member Functions inherited from knowrob::Atomic
 Atomic (AtomicType atomicType)
 
 ~Atomic () override=default
 
bool isSameAtomic (const Atomic &other) const
 
AtomicType atomicType () const
 
size_t hashOfAtomic () const
 
virtual std::string_view stringForm () const =0
 
const std::set< std::string_view > & variables () const final
 
void write (std::ostream &os) const override
 
 Atomic (AtomicType atomicType)
 
 ~Atomic () override=default
 
bool isSameAtomic (const Atomic &other) const
 
AtomicType atomicType () const
 
size_t hashOfAtomic () const
 
virtual std::string_view stringForm () const =0
 
const std::set< std::string_view > & variables () const final
 
void write (std::ostream &os) const override
 
- Public Member Functions inherited from knowrob::Term
 Term (TermType termType)
 
 ~Term () override=default
 
bool operator== (const Term &other) const
 
bool operator!= (const Term &other) const
 
TermType termType () const
 
bool isGround () const
 
bool isAtomic () const
 
bool isAtom () const
 
bool isVariable () const
 
bool isFunction () const
 
bool isNumeric () const
 
bool isString () const
 
bool isIRI () const
 
bool isBlank () const
 
size_t hash () const
 
 Term (TermType termType)
 
 ~Term () override=default
 
bool operator== (const Term &other) const
 
bool operator!= (const Term &other) const
 
TermType termType () const
 
bool isGround () const
 
bool isAtomic () const
 
bool isAtom () const
 
bool isVariable () const
 
bool isFunction () const
 
bool isNumeric () const
 
bool isString () const
 
bool isIRI () const
 
bool isBlank () const
 
size_t hash () const
 
- Public Member Functions inherited from knowrob::Printable
virtual ~Printable ()=default
 
virtual std::string format () const
 
virtual ~Printable ()=default
 
virtual std::string format () const
 

Static Public Member Functions

static std::shared_ptr< XSDAtomiccreate (std::string_view lexicalForm, std::string_view xsdTypeIRI)
 
static std::shared_ptr< XSDAtomiccreate (std::string_view lexicalForm, std::string_view xsdTypeIRI)
 
- Static Public Member Functions inherited from knowrob::Atomic
static std::shared_ptr< AtomicmakeTripleValue (const Triple &triple)
 
static std::shared_ptr< AtomicmakeTripleValue (const Triple &triple)
 

Protected Attributes

XSDType xsdType_
 
- Protected Attributes inherited from knowrob::RDFNode
const RDFNodeType rdfNodeType_
 
- Protected Attributes inherited from knowrob::Atomic
const AtomicType atomicType_
 
- Protected Attributes inherited from knowrob::Term
const TermType termType_
 
bool isBlank_ = false
 
bool isIRI_ = false
 

Additional Inherited Members

- Static Protected Attributes inherited from knowrob::Term
static const std::set< std::string_view > noVariables_ = {}
 

Detailed Description

An atomic RDF node with an XSD datatype

Definition at line 18 of file XSDAtomic.h.

Constructor & Destructor Documentation

◆ XSDAtomic() [1/2]

knowrob::XSDAtomic::XSDAtomic ( XSDType  xsdType)
inlineexplicit

Definition at line 20 of file XSDAtomic.h.

◆ XSDAtomic() [2/2]

knowrob::XSDAtomic::XSDAtomic ( XSDType  xsdType)
inlineexplicit

Member Function Documentation

◆ create() [1/2]

std::shared_ptr< XSDAtomic > XSDAtomic::create ( std::string_view  lexicalForm,
std::string_view  xsdTypeIRI 
)
static

Create an XSDAtomic from a lexical form and an XSD datatype IRI

Parameters
lexicalFormthe lexical form of the RDF literal
xsdTypeIRIthe IRI of the XSD datatype
Returns
a shared pointer to the XSDAtomic

Definition at line 17 of file XSDAtomic.cpp.

17  {
19  switch (type) {
20  case XSDType::STRING:
21  return std::make_shared<String>(lexicalForm);
22  case XSDType::BOOLEAN:
23  return std::make_shared<Boolean>(lexicalForm);
24  case XSDType::DOUBLE:
25  return std::make_shared<Double>(lexicalForm);
26  case XSDType::FLOAT:
27  return std::make_shared<Float>(lexicalForm);
29  case XSDType::INTEGER:
30  return std::make_shared<Integer>(lexicalForm);
31  case XSDType::LONG:
32  return std::make_shared<Long>(lexicalForm);
33  case XSDType::SHORT:
34  return std::make_shared<Short>(lexicalForm);
36  return std::make_shared<UnsignedLong>(lexicalForm);
38  return std::make_shared<UnsignedInt>(lexicalForm);
40  return std::make_shared<UnsignedShort>(lexicalForm);
41  default:
42  KB_ERROR("Unknown XSD type {} treated as string.", static_cast<int>(type));
43  return std::make_shared<String>(lexicalForm);
44  }
45 }
#define KB_ERROR
Definition: Logger.h:28
std::string_view xsdTypeIRI() const
Definition: XSDAtomic.cpp:90
const IRIAtomPtr type
Definition: rdf.h:15
XSDType xsdTypeFromIRI(std::string_view iri)
Definition: XSDAtomic.cpp:48

◆ create() [2/2]

static std::shared_ptr<XSDAtomic> knowrob::XSDAtomic::create ( std::string_view  lexicalForm,
std::string_view  xsdTypeIRI 
)
static

Create an XSDAtomic from a lexical form and an XSD datatype IRI

Parameters
lexicalFormthe lexical form of the RDF literal
xsdTypeIRIthe IRI of the XSD datatype
Returns
a shared pointer to the XSDAtomic

◆ xsdType() [1/2]

XSDType knowrob::XSDAtomic::xsdType ( ) const
inline

The XSD datatype determines how the lexical form maps to a literal value

Returns
the XSD datatype of the RDF literal

Definition at line 43 of file XSDAtomic.h.

43 { return xsdType_; }

◆ xsdType() [2/2]

XSDType knowrob::XSDAtomic::xsdType ( ) const
inline

The XSD datatype determines how the lexical form maps to a literal value

Returns
the XSD datatype of the RDF literal

Definition at line 43 of file XSDAtomic.h.

43 { return xsdType_; }

◆ xsdTypeIRI() [1/2]

std::string_view knowrob::XSDAtomic::xsdTypeIRI ( ) const

The IRI of the XSD datatype

Returns
the IRI of the XSD datatype of the RDF literal

Definition at line 90 of file XSDAtomic.cpp.

90  {
91  return xsdTypeToIRI(xsdType());
92  }
std::string_view xsdTypeToIRI(XSDType type)
Definition: XSDAtomic.cpp:70

◆ xsdTypeIRI() [2/2]

std::string_view knowrob::XSDAtomic::xsdTypeIRI ( ) const

The IRI of the XSD datatype

Returns
the IRI of the XSD datatype of the RDF literal

Member Data Documentation

◆ xsdType_

XSDType knowrob::XSDAtomic::xsdType_
protected

Definition at line 46 of file XSDAtomic.h.


The documentation for this class was generated from the following files: