LibreOffice Module connectivity (master) 1
fcode.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
23#include <com/sun/star/sdbc/DataType.hpp>
25#include <file/filedllapi.hxx>
26
27#include <stack>
28#include <utility>
29
30namespace connectivity
31{
32 class OSQLParseNode;
33 namespace file
34 {
35
36 class OOperand;
37 typedef std::stack<OOperand*> OCodeStack;
38
40 {
41 public:
42 //virtual dtor to allow this to be the root of the class hierarchy
43 virtual ~OCode();
44 //but that disables the default move ctor
45 OCode(OCode&&) = default;
46 //but that disables the rest of default ctors
47 OCode(const OCode&) = default;
48 OCode() = default;
49 //and same issue for the assignment operators
50 OCode& operator=(const OCode&) = default;
51 OCode& operator=(OCode&&) = default;
52 };
53
54
55 // operands that the parsetree generate
57 {
58 protected:
59 sal_Int32 m_eDBType;
60
61 OOperand(sal_Int32 _rType) : m_eDBType(_rType){}
62 OOperand() : m_eDBType(css::sdbc::DataType::OTHER){}
63
64 public:
65 virtual const ORowSetValue& getValue() const = 0;
66 virtual void setValue(const ORowSetValue& _rVal) = 0;
67
68 sal_Int32 getDBType() const {return m_eDBType;}
69 inline bool isValid() const;
70
71 };
72
73 class OOperandRow : public OOperand
74 {
75 sal_uInt16 m_nRowPos;
77
78 protected:
79 OOperandRow(sal_uInt16 _nPos, sal_Int32 _rType);
80 public:
81 virtual const ORowSetValue& getValue() const override;
82 virtual void setValue(const ORowSetValue& _rVal) override;
83 void bindValue(const OValueRefRow& _pRow); // Bind to the value that the operand represents
84
85 };
86
87 // Attributes from a result row
89 {
90 public:
91 OOperandAttr(sal_uInt16 _nPos,
92 const css::uno::Reference< css::beans::XPropertySet>& _xColumn);
93
94 };
95
96 // Parameter for a predicate
98 {
99 public:
100 OOperandParam(sal_Int32 _nPos);
101 };
102
103 // Value operands
104 class OOperandValue : public OOperand
105 {
106 protected:
108
109 protected:
111 OOperandValue(ORowSetValue _aVar, sal_Int32 eDbType)
112 : OOperand(eDbType)
113 , m_aValue(std::move(_aVar))
114 {}
115
116 OOperandValue(sal_Int32 eDbType) :OOperand(eDbType){}
117 public:
118 virtual const ORowSetValue& getValue() const override;
119 virtual void setValue(const ORowSetValue& _rVal) override;
120
121 };
122
123
124 // Constants
126 {
127 public:
128 OOperandConst(const connectivity::OSQLParseNode& rColumnRef, const OUString& aStrValue);
129
130 };
131
132
133 // Result operands
135 {
136 protected:
137 OOperandResult(sal_Int32 eDbType)
138 :OOperandValue(eDbType) {}
139 public:
141 :OOperandValue(_rVar, _rVar.getTypeKind()) {}
142 };
143
144
146 {
147 public:
148 OOperandResultBOOL(bool bResult) : OOperandResult(css::sdbc::DataType::BIT)
149 {
150 m_aValue = bResult ? 1.0 : 0.0;
151 m_aValue.setBound(true);
152 }
153 };
154
156 {
157 public:
159 {
160 m_aValue = fNum;
161 m_aValue.setBound(true);
162 }
163 };
164
169 {
170 public:
172 };
173
174 // Operators
176 {
177 public:
178 virtual void Exec(OCodeStack&) = 0;
179 };
180
181
182 // Boolean operators
184 {
185 public:
186 virtual void Exec(OCodeStack&) override;
187 virtual bool operate(const OOperand*, const OOperand*) const;
188 };
189
190 class OOp_NOT : public OBoolOperator
191 {
192 public:
193
194 protected:
195 virtual void Exec(OCodeStack&) override;
196 virtual bool operate(const OOperand*, const OOperand*) const override;
197 };
198
199 class OOp_AND : public OBoolOperator
200 {
201 public:
202
203 protected:
204 virtual bool operate(const OOperand*, const OOperand*) const override;
205 };
206
207 class OOp_OR : public OBoolOperator
208 {
209 public:
210 protected:
211 virtual bool operate(const OOperand*, const OOperand*) const override;
212 };
213
215 {
216 public:
217 public:
218 virtual void Exec(OCodeStack&) override;
219 virtual bool operate(const OOperand*, const OOperand*) const override;
220 };
221
223 {
224 public:
225 virtual bool operate(const OOperand*, const OOperand*) const override;
226 };
227
229 {
231
232 public:
233 OOp_LIKE(const sal_Unicode cEsc):cEscape(cEsc){};
234
235 virtual bool operate(const OOperand*, const OOperand*) const override;
236 };
237
238 class OOp_NOTLIKE : public OOp_LIKE
239 {
240 public:
241 public:
242 OOp_NOTLIKE(const sal_Unicode cEsc):OOp_LIKE(cEsc){};
243
244 virtual bool operate(const OOperand*, const OOperand*) const override;
245 };
246
248 {
249 sal_Int32 aPredicateType;
250
251 public:
252 OOp_COMPARE(sal_Int32 aPType)
253 :aPredicateType(aPType) {}
254
255 sal_Int32 getPredicateType() const { return aPredicateType; }
256 virtual bool operate(const OOperand*, const OOperand*) const override;
257 };
258
259 // Numerical operators
260 class ONumOperator : public OOperator
261 {
262 public:
263 virtual void Exec(OCodeStack&) override;
264
265
266 protected:
267 virtual double operate(const double& fLeft,const double& fRight) const = 0;
268 };
269
270 class OOp_ADD : public ONumOperator
271 {
272 protected:
273 virtual double operate(const double& fLeft,const double& fRight) const override;
274 };
275
276 class OOp_SUB : public ONumOperator
277 {
278 protected:
279 virtual double operate(const double& fLeft,const double& fRight) const override;
280 };
281
282 class OOp_MUL : public ONumOperator
283 {
284 protected:
285 virtual double operate(const double& fLeft,const double& fRight) const override;
286 };
287
288 class OOp_DIV : public ONumOperator
289 {
290 protected:
291 virtual double operate(const double& fLeft,const double& fRight) const override;
292 };
293
294 inline bool OOperand::isValid() const
295 {
296 return getValue().getDouble() != 0.0;
297 }
298
299 // Operator
300 class ONthOperator : public OOperator
301 {
302 public:
303 virtual void Exec(OCodeStack&) override;
304
305
306 protected:
307 virtual ORowSetValue operate(const std::vector<ORowSetValue>& lhs) const = 0;
308 };
309
311 {
312 public:
313 virtual void Exec(OCodeStack&) override;
314
315
316 protected:
317 virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const = 0;
318 };
319
321 {
322 public:
323 virtual void Exec(OCodeStack&) override;
324 virtual ORowSetValue operate(const ORowSetValue& lhs) const = 0;
325
326
327 };
328 }
329}
330
331/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define DOUBLE
void setBound(bool _bBound)
Definition: FValue.hxx:332
double getDouble() const
Definition: FValue.cxx:1745
virtual void Exec(OCodeStack &) override
Definition: fcode.cxx:344
virtual ORowSetValue operate(const ORowSetValue &lhs, const ORowSetValue &rhs) const =0
OCode(OCode &&)=default
OCode(const OCode &)=default
OCode & operator=(const OCode &)=default
OCode & operator=(OCode &&)=default
virtual void Exec(OCodeStack &) override
Definition: fcode.cxx:318
virtual ORowSetValue operate(const std::vector< ORowSetValue > &lhs) const =0
virtual double operate(const double &fLeft, const double &fRight) const =0
virtual void Exec(OCodeStack &) override
Definition: fcode.cxx:281
virtual double operate(const double &fLeft, const double &fRight) const override
Definition: fcode.cxx:295
virtual bool operate(const OOperand *, const OOperand *) const override
Definition: fcode.cxx:159
OOp_COMPARE(sal_Int32 aPType)
Definition: fcode.hxx:252
sal_Int32 getPredicateType() const
Definition: fcode.hxx:255
virtual double operate(const double &fLeft, const double &fRight) const override
Definition: fcode.cxx:313
OOp_LIKE(const sal_Unicode cEsc)
Definition: fcode.hxx:233
const sal_Unicode cEscape
Definition: fcode.hxx:230
virtual double operate(const double &fLeft, const double &fRight) const override
Definition: fcode.cxx:307
virtual bool operate(const OOperand *, const OOperand *) const override
Definition: fcode.cxx:210
OOp_NOTLIKE(const sal_Unicode cEsc)
Definition: fcode.hxx:242
virtual void Exec(OCodeStack &) override
Definition: fcode.cxx:148
virtual bool operate(const OOperand *, const OOperand *) const override
Definition: fcode.cxx:143
virtual bool operate(const OOperand *, const OOperand *) const override
Definition: fcode.cxx:165
virtual double operate(const double &fLeft, const double &fRight) const override
Definition: fcode.cxx:301
OOperandAttr(sal_uInt16 _nPos, const css::uno::Reference< css::beans::XPropertySet > &_xColumn)
Definition: FDriver.cxx:200
OOperandConst(const connectivity::OSQLParseNode &rColumnRef, const OUString &aStrValue)
Definition: fcode.cxx:83
OOperandParam(sal_Int32 _nPos)
Definition: fcode.cxx:66
OOperandResult(sal_Int32 eDbType)
Definition: fcode.hxx:137
OOperandResult(const ORowSetValue &_rVar)
Definition: fcode.hxx:140
virtual const ORowSetValue & getValue() const override
Definition: fcode.cxx:54
virtual void setValue(const ORowSetValue &_rVal) override
Definition: fcode.cxx:48
void bindValue(const OValueRefRow &_pRow)
Definition: fcode.cxx:40
OOperandRow(sal_uInt16 _nPos, sal_Int32 _rType)
Definition: fcode.cxx:35
OOperandValue(sal_Int32 eDbType)
Definition: fcode.hxx:116
virtual const ORowSetValue & getValue() const override
Definition: fcode.cxx:77
OOperandValue(ORowSetValue _aVar, sal_Int32 eDbType)
Definition: fcode.hxx:111
virtual void setValue(const ORowSetValue &_rVal) override
Definition: fcode.cxx:61
OOperand(sal_Int32 _rType)
Definition: fcode.hxx:61
sal_Int32 getDBType() const
Definition: fcode.hxx:68
virtual void setValue(const ORowSetValue &_rVal)=0
virtual const ORowSetValue & getValue() const =0
virtual void Exec(OCodeStack &)=0
special stop operand is appended when a list of arguments ends
Definition: fcode.hxx:169
virtual void Exec(OCodeStack &) override
Definition: fcode.cxx:361
virtual ORowSetValue operate(const ORowSetValue &lhs) const =0
#define OOO_DLLPUBLIC_FILE
Definition: filedllapi.hxx:29
std::stack< OOperand * > OCodeStack
Definition: fcode.hxx:36
DataType
sal_uInt16 sal_Unicode
sal_Int32 _nPos