Use correct object
[LibreOffice.git] / connectivity / source / drivers / macab / macabcondition.hxx
blob32e7b7071cf32c9025a810cf0c3d75044c33dc81
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #pragma once
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
34 class MacabCondition
36 public:
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
45 protected:
46 bool m_bValue;
48 public:
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
57 protected:
58 sal_Int32 m_nFieldNumber;
60 public:
61 /// @throws css::sdbc::SQLException
62 MacabConditionColumn(
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
71 public:
72 /// @throws css::sdbc::SQLException
73 MacabConditionNull(
74 const MacabHeader *header,
75 std::u16string_view sColumnName);
76 virtual bool eval(const MacabRecord *aRecord) const override;
79 class MacabConditionNotNull : public MacabConditionColumn
81 public:
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
91 protected:
92 const OUString m_sMatchString;
94 public:
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
104 public:
105 /// @throws css::sdbc::SQLException
106 MacabConditionEqual(
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
115 public:
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
126 public:
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
137 protected:
138 MacabCondition *m_pLeft, *m_pRight;
140 public:
141 MacabConditionBoolean(MacabCondition *pLeft, MacabCondition *pRight);
142 virtual ~MacabConditionBoolean() override;
145 class MacabConditionOr : public MacabConditionBoolean
147 public:
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
156 public:
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: */