1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FStringFunctions.hxx,v $
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
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');
50 class OOp_Upper
: public OUnaryOperator
53 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
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');
64 class OOp_Lower
: public OUnaryOperator
67 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
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:
81 class OOp_Ascii
: public OUnaryOperator
84 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
91 Returns the length of the string str:
93 > SELECT LENGTH('text');
95 > SELECT OCTET_LENGTH('text');
99 class OOp_CharLength
: public OUnaryOperator
102 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
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'));
110 > SELECT CHAR(77,77.3,'77.3');
114 class OOp_Char
: public ONthOperator
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');
125 > SELECT CONCAT('OO', NULL, 'OO');
127 > SELECT CONCAT(14.3);
131 class OOp_Concat
: public ONthOperator
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');
143 > SELECT LOCATE('xbar', 'foobar');
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);
152 class OOp_Locate
: public ONthOperator
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);
164 > SELECT SUBSTRING('foobarbar' FROM 4);
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);
174 class OOp_SubString
: public ONthOperator
177 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
181 Returns the string str with leading space characters removed:
183 > SELECT LTRIM(' barbar');
187 class OOp_LTrim
: public OUnaryOperator
190 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
194 Returns the string str with trailing space characters removed:
196 > SELECT RTRIM('barbar ');
200 class OOp_RTrim
: public OUnaryOperator
203 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
207 Returns a string consisting of N space characters:
213 class OOp_Space
: public OUnaryOperator
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');
226 class OOp_Replace
: public ONthOperator
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);
239 class OOp_Repeat
: public OBinaryOperator
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');
252 class OOp_Insert
: public ONthOperator
255 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
259 Returns the leftmost len characters from the string str:
261 > SELECT LEFT('foobarbar', 5);
265 class OOp_Left
: public OBinaryOperator
268 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const;
272 Returns the rightmost len characters from the string str:
274 > SELECT RIGHT('foobarbar', 4);
277 class OOp_Right
: public OBinaryOperator
280 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const;
285 #endif // _CONNECTIVITY_FILE_FCODE_HXX_