1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _CONNECTIVITY_FILE_FSTRINGFUNCTIONS_HXX_
30 #define _CONNECTIVITY_FILE_FSTRINGFUNCTIONS_HXX_
32 #include "file/fcode.hxx"
33 #include "file/filedllapi.hxx"
35 namespace connectivity
42 Returns the string str with all characters changed to uppercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
44 > SELECT UCASE('Hej');
48 class OOp_Upper
: public OUnaryOperator
51 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
56 Returns the string str with all characters changed to lowercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
58 > SELECT LCASE('QUADRATICALLY');
62 class OOp_Lower
: public OUnaryOperator
65 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
69 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:
79 class OOp_Ascii
: public OUnaryOperator
82 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
89 Returns the length of the string str:
91 > SELECT LENGTH('text');
93 > SELECT OCTET_LENGTH('text');
97 class OOp_CharLength
: public OUnaryOperator
100 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
104 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:
106 > SELECT CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t'));
108 > SELECT CHAR(77,77.3,'77.3');
112 class OOp_Char
: public ONthOperator
115 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
118 /** CONCAT(str1,str2,...)
119 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:
121 > SELECT CONCAT('OO', 'o', 'OO');
123 > SELECT CONCAT('OO', NULL, 'OO');
125 > SELECT CONCAT(14.3);
129 class OOp_Concat
: public ONthOperator
132 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
135 /** LOCATE(substr,str)
136 POSITION(substr IN str)
137 Returns the position of the first occurrence of substring substr in string str. Returns 0 if substr is not in str:
139 > SELECT LOCATE('bar', 'foobarbar');
141 > SELECT LOCATE('xbar', 'foobar');
143 LOCATE(substr,str,pos)
144 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:
146 > SELECT LOCATE('bar', 'foobarbar',5);
150 class OOp_Locate
: public ONthOperator
153 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
156 /** SUBSTRING(str,pos)
157 SUBSTRING(str FROM pos)
158 Returns a substring from string str starting at position pos:
160 > SELECT SUBSTRING('Quadratically',5);
162 > SELECT SUBSTRING('foobarbar' FROM 4);
164 SUBSTRING(str,pos,len)
165 SUBSTRING(str FROM pos FOR len)
166 Returns a substring len characters long from string str, starting at position pos. The variant form that uses FROM is SQL-92 syntax:
168 > SELECT SUBSTRING('Quadratically',5,6);
172 class OOp_SubString
: public ONthOperator
175 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
179 Returns the string str with leading space characters removed:
181 > SELECT LTRIM(' barbar');
185 class OOp_LTrim
: public OUnaryOperator
188 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
192 Returns the string str with trailing space characters removed:
194 > SELECT RTRIM('barbar ');
198 class OOp_RTrim
: public OUnaryOperator
201 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
205 Returns a string consisting of N space characters:
211 class OOp_Space
: public OUnaryOperator
214 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const;
217 /** REPLACE(str,from_str,to_str)
218 Returns the string str with all occurrences of the string from_str replaced by the string to_str:
220 > SELECT REPLACE('www.OOo.com', 'w', 'Ww');
224 class OOp_Replace
: public ONthOperator
227 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
230 /** REPEAT(str,count)
231 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:
233 > SELECT REPEAT('OOo', 3);
237 class OOp_Repeat
: public OBinaryOperator
240 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const;
243 /** INSERT(str,pos,len,newstr)
244 Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr:
246 > SELECT INSERT('Quadratic', 3, 4, 'What');
250 class OOp_Insert
: public ONthOperator
253 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const;
257 Returns the leftmost len characters from the string str:
259 > SELECT LEFT('foobarbar', 5);
263 class OOp_Left
: public OBinaryOperator
266 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const;
270 Returns the rightmost len characters from the string str:
272 > SELECT RIGHT('foobarbar', 4);
275 class OOp_Right
: public OBinaryOperator
278 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const;
283 #endif // _CONNECTIVITY_FILE_FCODE_HXX_
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */