update dev300-m58
[ooovba.git] / connectivity / source / inc / file / FStringFunctions.hxx
blobb1831bb608ed351a4c14fa47b66008c5f3dae0d0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FStringFunctions.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CONNECTIVITY_FILE_FSTRINGFUNCTIONS_HXX_
32 #define _CONNECTIVITY_FILE_FSTRINGFUNCTIONS_HXX_
34 #include "file/fcode.hxx"
35 #include "file/filedllapi.hxx"
37 namespace connectivity
39 class OSQLParseNode;
40 namespace file
42 /** UCASE(str)
43 UPPER(str)
44 Returns the string str with all characters changed to uppercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
46 > SELECT UCASE('Hej');
47 -> 'HEJ'
50 class OOp_Upper : public OUnaryOperator
52 protected:
53 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
56 /** LCASE(str)
57 LOWER(str)
58 Returns the string str with all characters changed to lowercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
60 > SELECT LCASE('QUADRATICALLY');
61 -> 'quadratically'
64 class OOp_Lower : public OUnaryOperator
66 protected:
67 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
70 /** ASCII(str)
71 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:
73 > SELECT ASCII('2');
74 -> 50
75 > SELECT ASCII(2);
76 -> 50
77 > SELECT ASCII('dx');
78 -> 100
81 class OOp_Ascii : public OUnaryOperator
83 protected:
84 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
87 /** LENGTH(str)
88 OCTET_LENGTH(str)
89 CHAR_LENGTH(str)
90 CHARACTER_LENGTH(str)
91 Returns the length of the string str:
93 > SELECT LENGTH('text');
94 -> 4
95 > SELECT OCTET_LENGTH('text');
96 -> 4
99 class OOp_CharLength : public OUnaryOperator
101 protected:
102 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
105 /** CHAR(N,...)
106 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:
108 > SELECT CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t'));
109 -> 'test'
110 > SELECT CHAR(77,77.3,'77.3');
111 -> 'MMM'
114 class OOp_Char : public ONthOperator
116 protected:
117 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
120 /** CONCAT(str1,str2,...)
121 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:
123 > SELECT CONCAT('OO', 'o', 'OO');
124 -> 'OOoOO'
125 > SELECT CONCAT('OO', NULL, 'OO');
126 -> NULL
127 > SELECT CONCAT(14.3);
128 -> '14.3'
131 class OOp_Concat : public ONthOperator
133 protected:
134 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
137 /** LOCATE(substr,str)
138 POSITION(substr IN str)
139 Returns the position of the first occurrence of substring substr in string str. Returns 0 if substr is not in str:
141 > SELECT LOCATE('bar', 'foobarbar');
142 -> 4
143 > SELECT LOCATE('xbar', 'foobar');
144 -> 0
145 LOCATE(substr,str,pos)
146 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:
148 > SELECT LOCATE('bar', 'foobarbar',5);
149 -> 7
152 class OOp_Locate : public ONthOperator
154 protected:
155 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
158 /** SUBSTRING(str,pos)
159 SUBSTRING(str FROM pos)
160 Returns a substring from string str starting at position pos:
162 > SELECT SUBSTRING('Quadratically',5);
163 -> 'ratically'
164 > SELECT SUBSTRING('foobarbar' FROM 4);
165 -> 'barbar'
166 SUBSTRING(str,pos,len)
167 SUBSTRING(str FROM pos FOR len)
168 Returns a substring len characters long from string str, starting at position pos. The variant form that uses FROM is SQL-92 syntax:
170 > SELECT SUBSTRING('Quadratically',5,6);
171 -> 'ratica'
174 class OOp_SubString : public ONthOperator
176 protected:
177 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
180 /** LTRIM(str)
181 Returns the string str with leading space characters removed:
183 > SELECT LTRIM(' barbar');
184 -> 'barbar'
187 class OOp_LTrim : public OUnaryOperator
189 protected:
190 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
193 /** RTRIM(str)
194 Returns the string str with trailing space characters removed:
196 > SELECT RTRIM('barbar ');
197 -> 'barbar'
200 class OOp_RTrim : public OUnaryOperator
202 protected:
203 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
206 /** SPACE(N)
207 Returns a string consisting of N space characters:
209 > SELECT SPACE(6);
210 -> ' '
213 class OOp_Space : public OUnaryOperator
215 protected:
216 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
219 /** REPLACE(str,from_str,to_str)
220 Returns the string str with all occurrences of the string from_str replaced by the string to_str:
222 > SELECT REPLACE('www.OOo.com', 'w', 'Ww');
223 -> 'WwWwWw.OOo.com'
226 class OOp_Replace : public ONthOperator
228 protected:
229 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
232 /** REPEAT(str,count)
233 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:
235 > SELECT REPEAT('OOo', 3);
236 -> 'OOoOOoOOo'
239 class OOp_Repeat : public OBinaryOperator
241 protected:
242 virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
245 /** INSERT(str,pos,len,newstr)
246 Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr:
248 > SELECT INSERT('Quadratic', 3, 4, 'What');
249 -> 'QuWhattic'
252 class OOp_Insert : public ONthOperator
254 protected:
255 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
258 /** LEFT(str,len)
259 Returns the leftmost len characters from the string str:
261 > SELECT LEFT('foobarbar', 5);
262 -> 'fooba'
265 class OOp_Left : public OBinaryOperator
267 protected:
268 virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
271 /** RIGHT(str,len)
272 Returns the rightmost len characters from the string str:
274 > SELECT RIGHT('foobarbar', 4);
275 -> 'rbar'
277 class OOp_Right : public OBinaryOperator
279 protected:
280 virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
285 #endif // _CONNECTIVITY_FILE_FCODE_HXX_