1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _CONNECTIVITY_MACAB_CONDITION_HXX_
25 #define _CONNECTIVITY_MACAB_CONDITION_HXX_
26 
27 #include "MacabHeader.hxx"
28 #include "MacabRecord.hxx"
29 
30 #ifndef _COMPHELPER_TYPES_H_
31 #include <comphelper/types.hxx>
32 #endif
33 #include <connectivity/dbexception.hxx>
34 
35 namespace connectivity
36 {
37 	namespace macab
38 	{
39 // -----------------------------------------------------------------------------
40 class MacabCondition
41 {
42 	public:
43 		virtual ~MacabCondition();
44 		virtual sal_Bool isAlwaysTrue() const = 0;
45 		virtual sal_Bool isAlwaysFalse() const = 0;
46 		virtual sal_Bool eval(const MacabRecord *aRecord) const = 0;
47 };
48 // -----------------------------------------------------------------------------
49 class MacabConditionConstant : public MacabCondition
50 {
51 	protected:
52 		sal_Bool m_bValue;
53 
54 	public:
55 		MacabConditionConstant(const sal_Bool bValue);
56 		virtual sal_Bool isAlwaysTrue() const;
57 		virtual sal_Bool isAlwaysFalse() const;
58 		virtual sal_Bool eval(const MacabRecord *aRecord) const;
59 };
60 // -----------------------------------------------------------------------------
61 class MacabConditionColumn : public MacabCondition
62 {
63 	protected:
64 		sal_Int32 m_nFieldNumber;
65 
66 	public:
67 		MacabConditionColumn(
68 			const MacabHeader *header,
69 			const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
70 		virtual sal_Bool isAlwaysTrue() const;
71 		virtual sal_Bool isAlwaysFalse() const;
72 };
73 // -----------------------------------------------------------------------------
74 class MacabConditionNull : public MacabConditionColumn
75 {
76 	public:
77 		MacabConditionNull(
78 			const MacabHeader *header,
79 			const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
80 		virtual sal_Bool eval(const MacabRecord *aRecord) const;
81 };
82 // -----------------------------------------------------------------------------
83 class MacabConditionNotNull : public MacabConditionColumn
84 {
85 	public:
86 		MacabConditionNotNull(
87 			const MacabHeader *header,
88 			const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
89 		virtual sal_Bool eval(const MacabRecord *aRecord) const;
90 };
91 // -----------------------------------------------------------------------------
92 class MacabConditionCompare : public MacabConditionColumn
93 {
94 	protected:
95 		const ::rtl::OUString m_sMatchString;
96 
97 	public:
98 		MacabConditionCompare(
99 			const MacabHeader *header,
100 			const ::rtl::OUString &sColumnName,
101 			const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
102 };
103 // -----------------------------------------------------------------------------
104 class MacabConditionEqual : public MacabConditionCompare
105 {
106 	public:
107 		MacabConditionEqual(
108 			const MacabHeader *header,
109 			const ::rtl::OUString &sColumnName,
110 			const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
111 		virtual sal_Bool eval(const MacabRecord *aRecord) const;
112 };
113 // -----------------------------------------------------------------------------
114 class MacabConditionDifferent : public MacabConditionCompare
115 {
116 	public:
117 		MacabConditionDifferent(
118 			const MacabHeader *header,
119 			const ::rtl::OUString &sColumnName,
120 			const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
121 		virtual sal_Bool eval(const MacabRecord *aRecord) const;
122 };
123 // -----------------------------------------------------------------------------
124 class MacabConditionSimilar : public MacabConditionCompare
125 {
126 	public:
127 		MacabConditionSimilar(
128 			const MacabHeader *header,
129 			const ::rtl::OUString &sColumnName,
130 			const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
131 		virtual sal_Bool eval(const MacabRecord *aRecord) const;
132 };
133 // -----------------------------------------------------------------------------
134 class MacabConditionBoolean : public MacabCondition
135 {
136 	protected:
137 		MacabCondition *m_pLeft, *m_pRight;
138 
139 	public:
140 		MacabConditionBoolean(MacabCondition *pLeft, MacabCondition *pRight);
141 		virtual ~MacabConditionBoolean();
142 };
143 // -----------------------------------------------------------------------------
144 class MacabConditionOr : public MacabConditionBoolean
145 {
146 	public:
147 		MacabConditionOr(MacabCondition *pLeft, MacabCondition *pRight);
148 		virtual sal_Bool isAlwaysTrue() const;
149 		virtual sal_Bool isAlwaysFalse() const;
150 		virtual sal_Bool eval(const MacabRecord *aRecord) const;
151 };
152 // -----------------------------------------------------------------------------
153 class MacabConditionAnd : public MacabConditionBoolean
154 {
155 	public:
156 		MacabConditionAnd(MacabCondition *pLeft, MacabCondition *pRight);
157 		virtual sal_Bool isAlwaysTrue() const;
158 		virtual sal_Bool isAlwaysFalse() const;
159 		virtual sal_Bool eval(const MacabRecord *aRecord) const;
160 };
161 // -----------------------------------------------------------------------------
162 	}
163 }
164 
165 #endif // _CONNECTIVITY_MACAB_CONDITION_HXX_
166