1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <sal/config.h>
24 #include <string_view>
26 #include "MacabHeader.hxx"
27 #include "MacabRecord.hxx"
29 #include <connectivity/dbexception.hxx>
31 namespace connectivity::macab
37 virtual ~MacabCondition();
38 virtual bool isAlwaysTrue() const = 0;
39 virtual bool isAlwaysFalse() const = 0;
40 virtual bool eval(const MacabRecord
*aRecord
) const = 0;
43 class MacabConditionConstant
: public MacabCondition
49 explicit MacabConditionConstant(const bool bValue
);
50 virtual bool isAlwaysTrue() const override
;
51 virtual bool isAlwaysFalse() const override
;
52 virtual bool eval(const MacabRecord
*aRecord
) const override
;
55 class MacabConditionColumn
: public MacabCondition
58 sal_Int32 m_nFieldNumber
;
61 /// @throws css::sdbc::SQLException
63 const MacabHeader
*header
,
64 std::u16string_view sColumnName
);
65 virtual bool isAlwaysTrue() const override
;
66 virtual bool isAlwaysFalse() const override
;
69 class MacabConditionNull
: public MacabConditionColumn
72 /// @throws css::sdbc::SQLException
74 const MacabHeader
*header
,
75 std::u16string_view sColumnName
);
76 virtual bool eval(const MacabRecord
*aRecord
) const override
;
79 class MacabConditionNotNull
: public MacabConditionColumn
82 /// @throws css::sdbc::SQLException
83 MacabConditionNotNull(
84 const MacabHeader
*header
,
85 std::u16string_view sColumnName
);
86 virtual bool eval(const MacabRecord
*aRecord
) const override
;
89 class MacabConditionCompare
: public MacabConditionColumn
92 const OUString m_sMatchString
;
95 /// @throws css::sdbc::SQLException
96 MacabConditionCompare(
97 const MacabHeader
*header
,
98 std::u16string_view sColumnName
,
99 const OUString
&sMatchString
);
102 class MacabConditionEqual
: public MacabConditionCompare
105 /// @throws css::sdbc::SQLException
107 const MacabHeader
*header
,
108 std::u16string_view sColumnName
,
109 const OUString
&sMatchString
);
110 virtual bool eval(const MacabRecord
*aRecord
) const override
;
113 class MacabConditionDifferent
: public MacabConditionCompare
116 /// @throws css::sdbc::SQLException
117 MacabConditionDifferent(
118 const MacabHeader
*header
,
119 std::u16string_view sColumnName
,
120 const OUString
&sMatchString
);
121 virtual bool eval(const MacabRecord
*aRecord
) const override
;
124 class MacabConditionSimilar
: public MacabConditionCompare
127 /// @throws css::sdbc::SQLException
128 MacabConditionSimilar(
129 const MacabHeader
*header
,
130 std::u16string_view sColumnName
,
131 const OUString
&sMatchString
);
132 virtual bool eval(const MacabRecord
*aRecord
) const override
;
135 class MacabConditionBoolean
: public MacabCondition
138 MacabCondition
*m_pLeft
, *m_pRight
;
141 MacabConditionBoolean(MacabCondition
*pLeft
, MacabCondition
*pRight
);
142 virtual ~MacabConditionBoolean() override
;
145 class MacabConditionOr
: public MacabConditionBoolean
148 MacabConditionOr(MacabCondition
*pLeft
, MacabCondition
*pRight
);
149 virtual bool isAlwaysTrue() const override
;
150 virtual bool isAlwaysFalse() const override
;
151 virtual bool eval(const MacabRecord
*aRecord
) const override
;
154 class MacabConditionAnd
: public MacabConditionBoolean
157 MacabConditionAnd(MacabCondition
*pLeft
, MacabCondition
*pRight
);
158 virtual bool isAlwaysTrue() const override
;
159 virtual bool isAlwaysFalse() const override
;
160 virtual bool eval(const MacabRecord
*aRecord
) const override
;
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */