1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _CONNECTIVITY_FILE_FSTRINGFUNCTIONS_HXX_
29*cdf0e10cSrcweir #define _CONNECTIVITY_FILE_FSTRINGFUNCTIONS_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "file/fcode.hxx"
32*cdf0e10cSrcweir #include "file/filedllapi.hxx"
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir namespace connectivity
35*cdf0e10cSrcweir {
36*cdf0e10cSrcweir 	class OSQLParseNode;
37*cdf0e10cSrcweir 	namespace file
38*cdf0e10cSrcweir 	{
39*cdf0e10cSrcweir 		/** UCASE(str)
40*cdf0e10cSrcweir 			UPPER(str)
41*cdf0e10cSrcweir 				Returns the string str with all characters changed to uppercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir 			> SELECT UCASE('Hej');
44*cdf0e10cSrcweir 					-> 'HEJ'
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir 		*/
47*cdf0e10cSrcweir 		class OOp_Upper : public OUnaryOperator
48*cdf0e10cSrcweir 		{
49*cdf0e10cSrcweir 		protected:
50*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ORowSetValue& lhs) const;
51*cdf0e10cSrcweir 		};
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir 		/** LCASE(str)
54*cdf0e10cSrcweir 			LOWER(str)
55*cdf0e10cSrcweir 				Returns the string str with all characters changed to lowercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir 			> SELECT LCASE('QUADRATICALLY');
58*cdf0e10cSrcweir 					-> 'quadratically'
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir 		*/
61*cdf0e10cSrcweir 		class OOp_Lower : public OUnaryOperator
62*cdf0e10cSrcweir 		{
63*cdf0e10cSrcweir 		protected:
64*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ORowSetValue& lhs) const;
65*cdf0e10cSrcweir 		};
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 		/** ASCII(str)
68*cdf0e10cSrcweir 			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:
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 			> SELECT ASCII('2');
71*cdf0e10cSrcweir 				-> 50
72*cdf0e10cSrcweir 			> SELECT ASCII(2);
73*cdf0e10cSrcweir 				-> 50
74*cdf0e10cSrcweir 			> SELECT ASCII('dx');
75*cdf0e10cSrcweir 				-> 100
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 		*/
78*cdf0e10cSrcweir 		class OOp_Ascii : public OUnaryOperator
79*cdf0e10cSrcweir 		{
80*cdf0e10cSrcweir 		protected:
81*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ORowSetValue& lhs) const;
82*cdf0e10cSrcweir 		};
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 		/** LENGTH(str)
85*cdf0e10cSrcweir 			OCTET_LENGTH(str)
86*cdf0e10cSrcweir 			CHAR_LENGTH(str)
87*cdf0e10cSrcweir 			CHARACTER_LENGTH(str)
88*cdf0e10cSrcweir 				Returns the length of the string str:
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 			> SELECT LENGTH('text');
91*cdf0e10cSrcweir 					-> 4
92*cdf0e10cSrcweir 			> SELECT OCTET_LENGTH('text');
93*cdf0e10cSrcweir 					-> 4
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 		*/
96*cdf0e10cSrcweir 		class OOp_CharLength : public OUnaryOperator
97*cdf0e10cSrcweir 		{
98*cdf0e10cSrcweir 		protected:
99*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ORowSetValue& lhs) const;
100*cdf0e10cSrcweir 		};
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 		/** CHAR(N,...)
103*cdf0e10cSrcweir 			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:
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 			> SELECT CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t'));
106*cdf0e10cSrcweir 				-> 'test'
107*cdf0e10cSrcweir 			> SELECT CHAR(77,77.3,'77.3');
108*cdf0e10cSrcweir 				-> 'MMM'
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 		*/
111*cdf0e10cSrcweir 		class OOp_Char : public ONthOperator
112*cdf0e10cSrcweir 		{
113*cdf0e10cSrcweir 		protected:
114*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
115*cdf0e10cSrcweir 		};
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 		/** CONCAT(str1,str2,...)
118*cdf0e10cSrcweir 			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:
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 			> SELECT CONCAT('OO', 'o', 'OO');
121*cdf0e10cSrcweir 				-> 'OOoOO'
122*cdf0e10cSrcweir 			> SELECT CONCAT('OO', NULL, 'OO');
123*cdf0e10cSrcweir 				-> NULL
124*cdf0e10cSrcweir 			> SELECT CONCAT(14.3);
125*cdf0e10cSrcweir 				-> '14.3'
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 		*/
128*cdf0e10cSrcweir 		class OOp_Concat : public ONthOperator
129*cdf0e10cSrcweir 		{
130*cdf0e10cSrcweir 		protected:
131*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
132*cdf0e10cSrcweir 		};
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 		/** LOCATE(substr,str)
135*cdf0e10cSrcweir 			POSITION(substr IN str)
136*cdf0e10cSrcweir 			Returns the position of the first occurrence of substring substr in string str. Returns 0 if substr is not in str:
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 			> SELECT LOCATE('bar', 'foobarbar');
139*cdf0e10cSrcweir 					-> 4
140*cdf0e10cSrcweir 			> SELECT LOCATE('xbar', 'foobar');
141*cdf0e10cSrcweir 					-> 0
142*cdf0e10cSrcweir 			LOCATE(substr,str,pos)
143*cdf0e10cSrcweir 			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:
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir 			> SELECT LOCATE('bar', 'foobarbar',5);
146*cdf0e10cSrcweir 				-> 7
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 		*/
149*cdf0e10cSrcweir 		class OOp_Locate : public ONthOperator
150*cdf0e10cSrcweir 		{
151*cdf0e10cSrcweir 		protected:
152*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
153*cdf0e10cSrcweir 		};
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 		/** SUBSTRING(str,pos)
156*cdf0e10cSrcweir 			SUBSTRING(str FROM pos)
157*cdf0e10cSrcweir 				Returns a substring from string str starting at position pos:
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 			> SELECT SUBSTRING('Quadratically',5);
160*cdf0e10cSrcweir 					-> 'ratically'
161*cdf0e10cSrcweir 			> SELECT SUBSTRING('foobarbar' FROM 4);
162*cdf0e10cSrcweir 					-> 'barbar'
163*cdf0e10cSrcweir 			SUBSTRING(str,pos,len)
164*cdf0e10cSrcweir 			SUBSTRING(str FROM pos FOR len)
165*cdf0e10cSrcweir 				Returns a substring len characters long from string str, starting at position pos. The variant form that uses FROM is SQL-92 syntax:
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 			> SELECT SUBSTRING('Quadratically',5,6);
168*cdf0e10cSrcweir 					-> 'ratica'
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 		*/
171*cdf0e10cSrcweir 		class OOp_SubString : public ONthOperator
172*cdf0e10cSrcweir 		{
173*cdf0e10cSrcweir 		protected:
174*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
175*cdf0e10cSrcweir 		};
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 		/** LTRIM(str)
178*cdf0e10cSrcweir 			Returns the string str with leading space characters removed:
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 			> SELECT LTRIM('  barbar');
181*cdf0e10cSrcweir 				-> 'barbar'
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 		*/
184*cdf0e10cSrcweir 		class OOp_LTrim : public OUnaryOperator
185*cdf0e10cSrcweir 		{
186*cdf0e10cSrcweir 		protected:
187*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ORowSetValue& lhs) const;
188*cdf0e10cSrcweir 		};
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir 		/** RTRIM(str)
191*cdf0e10cSrcweir 			Returns the string str with trailing space characters removed:
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 			> SELECT RTRIM('barbar   ');
194*cdf0e10cSrcweir 				-> 'barbar'
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 		*/
197*cdf0e10cSrcweir 		class OOp_RTrim : public OUnaryOperator
198*cdf0e10cSrcweir 		{
199*cdf0e10cSrcweir 		protected:
200*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ORowSetValue& lhs) const;
201*cdf0e10cSrcweir 		};
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 		/** SPACE(N)
204*cdf0e10cSrcweir 			Returns a string consisting of N space characters:
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir 			> SELECT SPACE(6);
207*cdf0e10cSrcweir 				-> '      '
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 		*/
210*cdf0e10cSrcweir 		class OOp_Space : public OUnaryOperator
211*cdf0e10cSrcweir 		{
212*cdf0e10cSrcweir 		protected:
213*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ORowSetValue& lhs) const;
214*cdf0e10cSrcweir 		};
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir 		/** REPLACE(str,from_str,to_str)
217*cdf0e10cSrcweir 			Returns the string str with all occurrences of the string from_str replaced by the string to_str:
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 			> SELECT REPLACE('www.OOo.com', 'w', 'Ww');
220*cdf0e10cSrcweir 				-> 'WwWwWw.OOo.com'
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir 		*/
223*cdf0e10cSrcweir 		class OOp_Replace : public ONthOperator
224*cdf0e10cSrcweir 		{
225*cdf0e10cSrcweir 		protected:
226*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
227*cdf0e10cSrcweir 		};
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 		/** REPEAT(str,count)
230*cdf0e10cSrcweir 			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:
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 			> SELECT REPEAT('OOo', 3);
233*cdf0e10cSrcweir 				-> 'OOoOOoOOo'
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir 		*/
236*cdf0e10cSrcweir 		class OOp_Repeat : public OBinaryOperator
237*cdf0e10cSrcweir 		{
238*cdf0e10cSrcweir 		protected:
239*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
240*cdf0e10cSrcweir 		};
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 		/** INSERT(str,pos,len,newstr)
243*cdf0e10cSrcweir 			Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr:
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir 			> SELECT INSERT('Quadratic', 3, 4, 'What');
246*cdf0e10cSrcweir 				-> 'QuWhattic'
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 		*/
249*cdf0e10cSrcweir 		class OOp_Insert : public ONthOperator
250*cdf0e10cSrcweir 		{
251*cdf0e10cSrcweir 		protected:
252*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
253*cdf0e10cSrcweir 		};
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir 		/** LEFT(str,len)
256*cdf0e10cSrcweir 			Returns the leftmost len characters from the string str:
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir 			> SELECT LEFT('foobarbar', 5);
259*cdf0e10cSrcweir 				-> 'fooba'
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 		*/
262*cdf0e10cSrcweir 		class OOp_Left : public OBinaryOperator
263*cdf0e10cSrcweir 		{
264*cdf0e10cSrcweir 		protected:
265*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
266*cdf0e10cSrcweir 		};
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 		/** RIGHT(str,len)
269*cdf0e10cSrcweir 			Returns the rightmost len characters from the string str:
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir 			> SELECT RIGHT('foobarbar', 4);
272*cdf0e10cSrcweir 				-> 'rbar'
273*cdf0e10cSrcweir 		*/
274*cdf0e10cSrcweir 		class OOp_Right : public OBinaryOperator
275*cdf0e10cSrcweir 		{
276*cdf0e10cSrcweir 		protected:
277*cdf0e10cSrcweir 			virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
278*cdf0e10cSrcweir 		};
279*cdf0e10cSrcweir 	}
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir #endif // _CONNECTIVITY_FILE_FCODE_HXX_
283*cdf0e10cSrcweir 
284