2 * Copyright (C) 2012-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "utils/IXmlDeserializable.h"
18 BooleanLogicOperationOr
= 0,
19 BooleanLogicOperationAnd
20 } BooleanLogicOperation
;
24 class CBooleanLogicValue
: public IXmlDeserializable
27 CBooleanLogicValue(const std::string
&value
= "", bool negated
= false)
28 : m_value(value
), m_negated(negated
)
30 ~CBooleanLogicValue() override
= default;
32 bool Deserialize(const TiXmlNode
*node
) override
;
34 virtual const std::string
& GetValue() const { return m_value
; }
35 virtual bool IsNegated() const { return m_negated
; }
36 virtual const char* GetTag() const { return "value"; }
38 virtual void SetValue(const std::string
&value
) { m_value
= value
; }
39 virtual void SetNegated(bool negated
) { m_negated
= negated
; }
46 typedef std::shared_ptr
<CBooleanLogicValue
> CBooleanLogicValuePtr
;
47 typedef std::vector
<CBooleanLogicValuePtr
> CBooleanLogicValues
;
49 class CBooleanLogicOperation
;
50 typedef std::shared_ptr
<CBooleanLogicOperation
> CBooleanLogicOperationPtr
;
51 typedef std::vector
<CBooleanLogicOperationPtr
> CBooleanLogicOperations
;
53 class CBooleanLogicOperation
: public IXmlDeserializable
56 explicit CBooleanLogicOperation(BooleanLogicOperation op
= BooleanLogicOperationAnd
)
59 ~CBooleanLogicOperation() override
= default;
61 bool Deserialize(const TiXmlNode
*node
) override
;
63 virtual BooleanLogicOperation
GetOperation() const { return m_operation
; }
64 virtual const CBooleanLogicOperations
& GetOperations() const { return m_operations
; }
65 virtual const CBooleanLogicValues
& GetValues() const { return m_values
; }
67 virtual void SetOperation(BooleanLogicOperation op
) { m_operation
= op
; }
70 virtual CBooleanLogicOperation
* newOperation() { return new CBooleanLogicOperation(); }
71 virtual CBooleanLogicValue
* newValue() { return new CBooleanLogicValue(); }
73 BooleanLogicOperation m_operation
;
74 CBooleanLogicOperations m_operations
;
75 CBooleanLogicValues m_values
;
78 class CBooleanLogic
: public IXmlDeserializable
81 /* make sure nobody deletes a pointer to this class */
82 ~CBooleanLogic() override
= default;
85 bool Deserialize(const TiXmlNode
*node
) override
;
87 const CBooleanLogicOperationPtr
& Get() const { return m_operation
; }
88 CBooleanLogicOperationPtr
Get() { return m_operation
; }
91 CBooleanLogicOperationPtr m_operation
;