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 INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FSTRINGFUNCTIONS_HXX
21 : #define INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FSTRINGFUNCTIONS_HXX
22 :
23 : #include "file/fcode.hxx"
24 : #include "file/filedllapi.hxx"
25 :
26 : namespace connectivity
27 : {
28 : namespace file
29 : {
30 : /** UCASE(str)
31 : UPPER(str)
32 : Returns the string str with all characters changed to uppercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
33 :
34 : > SELECT UCASE('Hej');
35 : -> 'HEJ'
36 :
37 : */
38 0 : class OOp_Upper : public OUnaryOperator
39 : {
40 : protected:
41 : virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
42 : };
43 :
44 : /** LCASE(str)
45 : LOWER(str)
46 : Returns the string str with all characters changed to lowercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
47 :
48 : > SELECT LCASE('QUADRATICALLY');
49 : -> 'quadratically'
50 :
51 : */
52 0 : class OOp_Lower : public OUnaryOperator
53 : {
54 : protected:
55 : virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
56 : };
57 :
58 : /** ASCII(str)
59 : Returns the ASCII code value of the leftmost character of the string str. Returns 0 if str is the empty string. Returns NULL if str is NULL:
60 :
61 : > SELECT ASCII('2');
62 : -> 50
63 : > SELECT ASCII(2);
64 : -> 50
65 : > SELECT ASCII('dx');
66 : -> 100
67 :
68 : */
69 0 : class OOp_Ascii : public OUnaryOperator
70 : {
71 : protected:
72 : virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
73 : };
74 :
75 : /** LENGTH(str)
76 : OCTET_LENGTH(str)
77 : CHAR_LENGTH(str)
78 : CHARACTER_LENGTH(str)
79 : Returns the length of the string str:
80 :
81 : > SELECT LENGTH('text');
82 : -> 4
83 : > SELECT OCTET_LENGTH('text');
84 : -> 4
85 :
86 : */
87 0 : class OOp_CharLength : public OUnaryOperator
88 : {
89 : protected:
90 : virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
91 : };
92 :
93 : /** CHAR(N,...)
94 : CHAR() interprets the arguments as integers and returns a string consisting of the characters given by the ASCII code values of those integers. NULL values are skipped:
95 :
96 : > SELECT CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t'));
97 : -> 'test'
98 : > SELECT CHAR(77,77.3,'77.3');
99 : -> 'MMM'
100 :
101 : */
102 0 : class OOp_Char : public ONthOperator
103 : {
104 : protected:
105 : virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const SAL_OVERRIDE;
106 : };
107 :
108 : /** CONCAT(str1,str2,...)
109 : Returns the string that results from concatenating the arguments. Returns NULL if any argument is NULL. May have more than 2 arguments. A numeric argument is converted to the equivalent string form:
110 :
111 : > SELECT CONCAT('OO', 'o', 'OO');
112 : -> 'OOoOO'
113 : > SELECT CONCAT('OO', NULL, 'OO');
114 : -> NULL
115 : > SELECT CONCAT(14.3);
116 : -> '14.3'
117 :
118 : */
119 0 : class OOp_Concat : public ONthOperator
120 : {
121 : protected:
122 : virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const SAL_OVERRIDE;
123 : };
124 :
125 : /** LOCATE(substr,str)
126 : POSITION(substr IN str)
127 : Returns the position of the first occurrence of substring substr in string str. Returns 0 if substr is not in str:
128 :
129 : > SELECT LOCATE('bar', 'foobarbar');
130 : -> 4
131 : > SELECT LOCATE('xbar', 'foobar');
132 : -> 0
133 : LOCATE(substr,str,pos)
134 : Returns the position of the first occurrence of substring substr in string str, starting at position pos. Returns 0 if substr is not in str:
135 :
136 : > SELECT LOCATE('bar', 'foobarbar',5);
137 : -> 7
138 :
139 : */
140 0 : class OOp_Locate : public ONthOperator
141 : {
142 : protected:
143 : virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const SAL_OVERRIDE;
144 : };
145 :
146 : /** SUBSTRING(str,pos)
147 : SUBSTRING(str FROM pos)
148 : Returns a substring from string str starting at position pos:
149 :
150 : > SELECT SUBSTRING('Quadratically',5);
151 : -> 'ratically'
152 : > SELECT SUBSTRING('foobarbar' FROM 4);
153 : -> 'barbar'
154 : SUBSTRING(str,pos,len)
155 : SUBSTRING(str FROM pos FOR len)
156 : Returns a substring len characters long from string str, starting at position pos. The variant form that uses FROM is SQL-92 syntax:
157 :
158 : > SELECT SUBSTRING('Quadratically',5,6);
159 : -> 'ratica'
160 :
161 : */
162 0 : class OOp_SubString : public ONthOperator
163 : {
164 : protected:
165 : virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const SAL_OVERRIDE;
166 : };
167 :
168 : /** LTRIM(str)
169 : Returns the string str with leading space characters removed:
170 :
171 : > SELECT LTRIM(' barbar');
172 : -> 'barbar'
173 :
174 : */
175 0 : class OOp_LTrim : public OUnaryOperator
176 : {
177 : protected:
178 : virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
179 : };
180 :
181 : /** RTRIM(str)
182 : Returns the string str with trailing space characters removed:
183 :
184 : > SELECT RTRIM('barbar ');
185 : -> 'barbar'
186 :
187 : */
188 0 : class OOp_RTrim : public OUnaryOperator
189 : {
190 : protected:
191 : virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
192 : };
193 :
194 : /** SPACE(N)
195 : Returns a string consisting of N space characters:
196 :
197 : > SELECT SPACE(6);
198 : -> ' '
199 :
200 : */
201 0 : class OOp_Space : public OUnaryOperator
202 : {
203 : protected:
204 : virtual ORowSetValue operate(const ORowSetValue& lhs) const SAL_OVERRIDE;
205 : };
206 :
207 : /** REPLACE(str,from_str,to_str)
208 : Returns the string str with all occurrences of the string from_str replaced by the string to_str:
209 :
210 : > SELECT REPLACE('www.OOo.com', 'w', 'Ww');
211 : -> 'WwWwWw.OOo.com'
212 :
213 : */
214 0 : class OOp_Replace : public ONthOperator
215 : {
216 : protected:
217 : virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const SAL_OVERRIDE;
218 : };
219 :
220 : /** REPEAT(str,count)
221 : Returns a string consisting of the string str repeated count times. If count <= 0, returns an empty string. Returns NULL if str or count are NULL:
222 :
223 : > SELECT REPEAT('OOo', 3);
224 : -> 'OOoOOoOOo'
225 :
226 : */
227 0 : class OOp_Repeat : public OBinaryOperator
228 : {
229 : protected:
230 : virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const SAL_OVERRIDE;
231 : };
232 :
233 : /** INSERT(str,pos,len,newstr)
234 : Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr:
235 :
236 : > SELECT INSERT('Quadratic', 3, 4, 'What');
237 : -> 'QuWhattic'
238 :
239 : */
240 0 : class OOp_Insert : public ONthOperator
241 : {
242 : protected:
243 : virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const SAL_OVERRIDE;
244 : };
245 :
246 : /** LEFT(str,len)
247 : Returns the leftmost len characters from the string str:
248 :
249 : > SELECT LEFT('foobarbar', 5);
250 : -> 'fooba'
251 :
252 : */
253 0 : class OOp_Left : public OBinaryOperator
254 : {
255 : protected:
256 : virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const SAL_OVERRIDE;
257 : };
258 :
259 : /** RIGHT(str,len)
260 : Returns the rightmost len characters from the string str:
261 :
262 : > SELECT RIGHT('foobarbar', 4);
263 : -> 'rbar'
264 : */
265 0 : class OOp_Right : public OBinaryOperator
266 : {
267 : protected:
268 : virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const SAL_OVERRIDE;
269 : };
270 : }
271 : }
272 :
273 : #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FSTRINGFUNCTIONS_HXX
274 :
275 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|