knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
String.h
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 #ifndef KNOWROB_STRING_H
7 #define KNOWROB_STRING_H
8 
9 #include "XSDAtomic.h"
10 
11 namespace knowrob {
15  class StringBase : public XSDAtomic {
16  public:
18 
19  ~StringBase() override = default;
20 
25  bool isSameString(const StringBase &other) const;
26 
27  protected:
28  // override Term
29  void write(std::ostream &os) const override;
30  };
31 
36  template<typename StrType>
37  class StringTemplate : public StringBase {
38  public:
39  explicit StringTemplate(std::string_view str) : str_(str) {}
40 
41  ~StringTemplate() override = default;
42 
43  // override Atomic
44  std::string_view stringForm() const override { return str_; }
45 
46  // override Printable
47  void write(std::ostream &os) const override { os << '"' << str_ << '"'; }
48 
49  protected:
50  StrType str_;
51  };
52 
56  using String = StringTemplate<std::string>;
61  using StringView = StringTemplate<std::string_view>;
62 
63 } // knowrob
64 
65 #endif //KNOWROB_STRING_H
~StringBase() override=default
void write(std::ostream &os) const override
bool isSameString(const StringBase &other) const
std::string_view stringForm() const override
Definition: String.h:44
void write(std::ostream &os) const override
Definition: String.h:47
StringTemplate(std::string_view str)
Definition: String.h:39
~StringTemplate() override=default
StringTemplate< std::string_view > StringView
Definition: String.h:61
StringTemplate< std::string > String
Definition: String.h:56
XSDType
The XSDType enum Enumeration of the XSD types.
Definition: XSDType.h:16