Branch data Line data Source code
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 : : #ifndef _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_
21 : : #define _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_
22 : :
23 : : #include "file/fcode.hxx"
24 : : #include "file/filedllapi.hxx"
25 : :
26 : : namespace connectivity
27 : : {
28 : : namespace file
29 : : {
30 : : /** ABS(X)
31 : : Returns the absolute value of X:
32 : :
33 : : > SELECT ABS(2);
34 : : -> 2
35 : : > SELECT ABS(-32);
36 : : -> 32
37 : :
38 : : */
39 [ # # ]: 0 : class OOp_Abs : public OUnaryOperator
40 : : {
41 : : protected:
42 : : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
43 : : };
44 : :
45 : : /** SIGN(X)
46 : : Returns the sign of the argument as -1, 0, or 1, depending on whether X is negative, zero, or positive:
47 : :
48 : : > SELECT SIGN(-32);
49 : : -> -1
50 : : > SELECT SIGN(0);
51 : : -> 0
52 : : > SELECT SIGN(234);
53 : : -> 1
54 : :
55 : : */
56 [ # # ]: 0 : class OOp_Sign : public OUnaryOperator
57 : : {
58 : : protected:
59 : : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
60 : : };
61 : :
62 : : /** MOD(N,M)
63 : : %
64 : : Modulo (like the % operator in C). Returns the remainder of N divided by M:
65 : :
66 : : > SELECT MOD(234, 10);
67 : : -> 4
68 : : > SELECT 253 % 7;
69 : : -> 1
70 : : > SELECT MOD(29,9);
71 : : -> 2
72 : : > SELECT 29 MOD 9;
73 : : -> 2
74 : : */
75 [ # # ]: 0 : class OOp_Mod : public OBinaryOperator
76 : : {
77 : : protected:
78 : : virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
79 : : };
80 : :
81 : : /** FLOOR(X)
82 : : Returns the largest integer value not greater than X:
83 : :
84 : : > SELECT FLOOR(1.23);
85 : : -> 1
86 : : > SELECT FLOOR(-1.23);
87 : : -> -2
88 : :
89 : : */
90 [ # # ]: 0 : class OOp_Floor : public OUnaryOperator
91 : : {
92 : : protected:
93 : : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
94 : : };
95 : :
96 : : /** CEILING(X)
97 : : Returns the smallest integer value not less than X:
98 : :
99 : : > SELECT CEILING(1.23);
100 : : -> 2
101 : : > SELECT CEILING(-1.23);
102 : : -> -1
103 : :
104 : : */
105 [ # # ]: 0 : class OOp_Ceiling : public OUnaryOperator
106 : : {
107 : : protected:
108 : : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
109 : : };
110 : :
111 : : /** ROUND(X)
112 : : ROUND(X,D)
113 : : Returns the argument X, rounded to the nearest integer. With two arguments rounded to a number to D decimals.
114 : :
115 : : > SELECT ROUND(-1.23);
116 : : -> -1
117 : : > SELECT ROUND(-1.58);
118 : : -> -2
119 : : > SELECT ROUND(1.58);
120 : : -> 2
121 : : > SELECT ROUND(1.298, 1);
122 : : -> 1.3
123 : : > SELECT ROUND(1.298, 0);
124 : : -> 1
125 : : > SELECT ROUND(23.298, -1);
126 : : -> 20
127 : : */
128 [ # # ]: 0 : class OOp_Round : public ONthOperator
129 : : {
130 : : protected:
131 : : virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
132 : : };
133 : :
134 : : /** EXP(X)
135 : : Returns the value of e (the base of natural logarithms) raised to the power of X:
136 : :
137 : : > SELECT EXP(2);
138 : : -> 7.389056
139 : : > SELECT EXP(-2);
140 : : -> 0.135335
141 : : */
142 [ # # ]: 0 : class OOp_Exp : public OUnaryOperator
143 : : {
144 : : protected:
145 : : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
146 : : };
147 : :
148 : : /** LN(X)
149 : : Returns the natural logarithm of X:
150 : :
151 : : > SELECT LN(2);
152 : : -> 0.693147
153 : : > SELECT LN(-2);
154 : : -> NULL
155 : :
156 : : */
157 [ # # ]: 0 : class OOp_Ln : public OUnaryOperator
158 : : {
159 : : protected:
160 : : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
161 : : };
162 : :
163 : : /** LOG(X)
164 : : LOG(B,X)
165 : : If called with one parameter, this function returns the natural logarithm of X:
166 : :
167 : : > SELECT LOG(2);
168 : : -> 0.693147
169 : : > SELECT LOG(-2);
170 : : -> NULL
171 : :
172 : : If called with two parameters, this function returns the logarithm of X for an arbitary base B:
173 : :
174 : : > SELECT LOG(2,65536);
175 : : -> 16.000000
176 : : > SELECT LOG(1,100);
177 : : -> NULL
178 : : */
179 [ # # ]: 0 : class OOp_Log : public ONthOperator
180 : : {
181 : : protected:
182 : : virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
183 : : };
184 : :
185 : : /** LOG10(X)
186 : : Returns the base-10 logarithm of X:
187 : :
188 : : > SELECT LOG10(2);
189 : : -> 0.301030
190 : : > SELECT LOG10(100);
191 : : -> 2.000000
192 : : > SELECT LOG10(-100);
193 : : -> NULL
194 : : */
195 [ # # ]: 0 : class OOp_Log10 : public OUnaryOperator
196 : : {
197 : : protected:
198 : : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
199 : : };
200 : :
201 : : /** POWER(X,Y)
202 : : Returns the value of X raised to the power of Y:
203 : :
204 : : > SELECT POW(2,2);
205 : : -> 4.000000
206 : : > SELECT POW(2,-2);
207 : : -> 0.250000
208 : : */
209 [ # # ]: 0 : class OOp_Pow : public OBinaryOperator
210 : : {
211 : : protected:
212 : : virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
213 : : };
214 : :
215 : : /** SQRT(X)
216 : : Returns the non-negative square root of X:
217 : :
218 : : > SELECT SQRT(4);
219 : : -> 2.000000
220 : : > SELECT SQRT(20);
221 : : -> 4.472136
222 : : */
223 [ # # ]: 0 : class OOp_Sqrt : public OUnaryOperator
224 : : {
225 : : protected:
226 : : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
227 : : };
228 : :
229 : : /** PI()
230 : : Returns the value of PI. The default shown number of decimals is 5, but internally uses the full double precession for PI.
231 : :
232 : : > SELECT PI();
233 : : -> 3.141593
234 : : > SELECT PI()+0.000000000000000000;
235 : : -> 3.141592653589793116
236 : :
237 : : */
238 [ # # ]: 0 : class OOp_Pi : public ONthOperator
239 : : {
240 : : protected:
241 : : virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
242 : : };
243 : :
244 : : /** COS(X)
245 : : Returns the cosine of X, where X is given in radians:
246 : :
247 : : > SELECT COS(PI());
248 : : -> -1.000000
249 : : */
250 [ # # ]: 0 : class OOp_Cos : public OUnaryOperator
251 : : {
252 : : protected:
253 : : virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
254 : : };
255 : :
256 : : /** SIN(X)
257 : : Returns the sine of X, where X is given in radians:
258 : :
259 : : > SELECT SIN(PI());
260 : : -> 0.000000
261 : :
262 : : */
263 [ # # ]: 0 : class OOp_Sin : public OUnaryOperator
264 : : {
265 : : protected:
266 : : virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
267 : : };
268 : : /** TAN(X)
269 : : Returns the tangent of X, where X is given in radians:
270 : :
271 : : > SELECT TAN(PI()+1);
272 : : -> 1.557408
273 : : */
274 [ # # ]: 0 : class OOp_Tan : public OUnaryOperator
275 : : {
276 : : protected:
277 : : virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
278 : : };
279 : :
280 : : /** ACOS(X)
281 : : Returns the arc cosine of X, that is, the value whose cosine is X. Returns NULL if X is not in the range -1 to 1:
282 : :
283 : : > SELECT ACOS(1);
284 : : -> 0.000000
285 : : > SELECT ACOS(1.0001);
286 : : -> NULL
287 : : > SELECT ACOS(0);
288 : : -> 1.570796
289 : : */
290 [ # # ]: 0 : class OOp_ACos : public OUnaryOperator
291 : : {
292 : : protected:
293 : : virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
294 : : };
295 : :
296 : : /** ASIN(X)
297 : : Returns the arc sine of X, that is, the value whose sine is X. Returns NULL if X is not in the range -1 to 1:
298 : :
299 : : > SELECT ASIN(0.2);
300 : : -> 0.201358
301 : : > SELECT ASIN('foo');
302 : : -> 0.000000
303 : : */
304 [ # # ]: 0 : class OOp_ASin : public OUnaryOperator
305 : : {
306 : : protected:
307 : : virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
308 : : };
309 : :
310 : : /** ATAN(X)
311 : : Returns the arc tangent of X, that is, the value whose tangent is X:
312 : :
313 : : > SELECT ATAN(2);
314 : : -> 1.107149
315 : : > SELECT ATAN(-2);
316 : : -> -1.107149
317 : : */
318 [ # # ]: 0 : class OOp_ATan : public OUnaryOperator
319 : : {
320 : : protected:
321 : : virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
322 : : };
323 : :
324 : : /** ATAN2(Y,X)
325 : : Returns the arc tangent of the two variables X and Y. It is similar to calculating the arc tangent of Y / X, except that the signs of both arguments are used to determine the quadrant of the result:
326 : :
327 : : > SELECT ATAN2(-2,2);
328 : : -> -0.785398
329 : : > SELECT ATAN2(PI(),0);
330 : : -> 1.570796
331 : :
332 : : */
333 [ # # ]: 0 : class OOp_ATan2 : public OBinaryOperator
334 : : {
335 : : protected:
336 : : virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
337 : : };
338 : :
339 : : /** DEGREES(X)
340 : : Returns the argument X, converted from radians to degrees:
341 : :
342 : : > SELECT DEGREES(PI());
343 : : -> 180.000000
344 : : */
345 [ # # ]: 0 : class OOp_Degrees : public OUnaryOperator
346 : : {
347 : : protected:
348 : : virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
349 : : };
350 : :
351 : : /** RADIANS(X)
352 : : Returns the argument X, converted from degrees to radians:
353 : :
354 : : > SELECT RADIANS(90);
355 : : -> 1.570796
356 : :
357 : : */
358 [ # # ]: 0 : class OOp_Radians : public OUnaryOperator
359 : : {
360 : : protected:
361 : : virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
362 : : };
363 : : }
364 : : }
365 : :
366 : : #endif // _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_
367 : :
368 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|