summaryrefslogtreecommitdiffstats
path: root/xbmc/utils/BooleanLogic.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/utils/BooleanLogic.h
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/utils/BooleanLogic.h')
-rw-r--r--xbmc/utils/BooleanLogic.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/xbmc/utils/BooleanLogic.h b/xbmc/utils/BooleanLogic.h
new file mode 100644
index 0000000..0355134
--- /dev/null
+++ b/xbmc/utils/BooleanLogic.h
@@ -0,0 +1,90 @@
1/*
2 * Copyright (C) 2012-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "utils/IXmlDeserializable.h"
12
13#include <memory>
14#include <string>
15#include <vector>
16
17typedef enum {
18 BooleanLogicOperationOr = 0,
19 BooleanLogicOperationAnd
20} BooleanLogicOperation;
21
22class CBooleanLogicValue : public IXmlDeserializable
23{
24public:
25 CBooleanLogicValue(const std::string &value = "", bool negated = false)
26 : m_value(value), m_negated(negated)
27 { }
28 ~CBooleanLogicValue() override = default;
29
30 bool Deserialize(const TiXmlNode *node) override;
31
32 virtual const std::string& GetValue() const { return m_value; }
33 virtual bool IsNegated() const { return m_negated; }
34 virtual const char* GetTag() const { return "value"; }
35
36 virtual void SetValue(const std::string &value) { m_value = value; }
37 virtual void SetNegated(bool negated) { m_negated = negated; }
38
39protected:
40 std::string m_value;
41 bool m_negated;
42};
43
44typedef std::shared_ptr<CBooleanLogicValue> CBooleanLogicValuePtr;
45typedef std::vector<CBooleanLogicValuePtr> CBooleanLogicValues;
46
47class CBooleanLogicOperation;
48typedef std::shared_ptr<CBooleanLogicOperation> CBooleanLogicOperationPtr;
49typedef std::vector<CBooleanLogicOperationPtr> CBooleanLogicOperations;
50
51class CBooleanLogicOperation : public IXmlDeserializable
52{
53public:
54 explicit CBooleanLogicOperation(BooleanLogicOperation op = BooleanLogicOperationAnd)
55 : m_operation(op)
56 { }
57 ~CBooleanLogicOperation() override = default;
58
59 bool Deserialize(const TiXmlNode *node) override;
60
61 virtual BooleanLogicOperation GetOperation() const { return m_operation; }
62 virtual const CBooleanLogicOperations& GetOperations() const { return m_operations; }
63 virtual const CBooleanLogicValues& GetValues() const { return m_values; }
64
65 virtual void SetOperation(BooleanLogicOperation op) { m_operation = op; }
66
67protected:
68 virtual CBooleanLogicOperation* newOperation() { return new CBooleanLogicOperation(); }
69 virtual CBooleanLogicValue* newValue() { return new CBooleanLogicValue(); }
70
71 BooleanLogicOperation m_operation;
72 CBooleanLogicOperations m_operations;
73 CBooleanLogicValues m_values;
74};
75
76class CBooleanLogic : public IXmlDeserializable
77{
78protected:
79 /* make sure nobody deletes a pointer to this class */
80 ~CBooleanLogic() override = default;
81
82public:
83 bool Deserialize(const TiXmlNode *node) override;
84
85 const CBooleanLogicOperationPtr& Get() const { return m_operation; }
86 CBooleanLogicOperationPtr Get() { return m_operation; }
87
88protected:
89 CBooleanLogicOperationPtr m_operation;
90};