1
2
3
4
5
6 #ifndef SNGXML_XPATH_XPATH_OBJECT
7 #define SNGXML_XPATH_XPATH_OBJECT
8 #include <sngxml/xpath/XPathApi.hpp>
9 #include <sngxml/dom/Node.hpp>
10
11 namespace sngxml { namespace xpath {
12
13 enum class XPathObjectType
14 {
15 nodeSet, boolean, number, string
16 };
17
18 class XPathObject
19 {
20 public:
21 XPathObject(XPathObjectType type_);
22 XPathObjectType Type() const { return type; }
23 virtual ~XPathObject();
24 virtual std::unique_ptr<dom::Node> ToDom() const = 0;
25 private:
26 XPathObjectType type;
27 };
28
29 class XPathNodeSet : public XPathObject
30 {
31 public:
32 XPathNodeSet();
33 sngxml::dom::Node* operator[](int index) const { return nodes[index]; }
34 int Length() const { return nodes.Length(); }
35 void Add(sngxml::dom::Node* node);
36 std::unique_ptr<dom::Node> ToDom() const override;
37 private:
38 sngxml::dom::NodeList nodes;
39 };
40
41 class XPathBoolean : public XPathObject
42 {
43 public:
44 XPathBoolean(bool value_);
45 bool Value() const { return value; }
46 std::unique_ptr<dom::Node> ToDom() const override;
47 private:
48 bool value;
49 };
50
51 class XPathNumber : public XPathObject
52 {
53 public:
54 XPathNumber(double value_);
55 double Value() const { return value; }
56 std::unique_ptr<dom::Node> ToDom() const override;
57 private:
58 double value;
59 };
60
61 class XPathString : public XPathObject
62 {
63 public:
64 XPathString(const std::u32string& value_);
65 const std::u32string& Value() const { return value; }
66 std::unique_ptr<dom::Node> ToDom() const override;
67 private:
68 std::u32string value;
69 };
70
71 } }
72
73 #endif // SNGXML_XPATH_XPATH_OBJECT