Bump for 3.6-28
[LibreOffice.git] / connectivity / source / inc / file / FStringFunctions.hxx
blob6b3a6bc88c3ef2aa00be5d2b81920faa720329cb
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
37 class OSQLParseNode;
38 namespace file
40 /** UCASE(str)
41 UPPER(str)
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');
45 -> 'HEJ'
48 class OOp_Upper : public OUnaryOperator
50 protected:
51 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
54 /** LCASE(str)
55 LOWER(str)
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');
59 -> 'quadratically'
62 class OOp_Lower : public OUnaryOperator
64 protected:
65 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
68 /** ASCII(str)
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:
71 > SELECT ASCII('2');
72 -> 50
73 > SELECT ASCII(2);
74 -> 50
75 > SELECT ASCII('dx');
76 -> 100
79 class OOp_Ascii : public OUnaryOperator
81 protected:
82 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
85 /** LENGTH(str)
86 OCTET_LENGTH(str)
87 CHAR_LENGTH(str)
88 CHARACTER_LENGTH(str)
89 Returns the length of the string str:
91 > SELECT LENGTH('text');
92 -> 4
93 > SELECT OCTET_LENGTH('text');
94 -> 4
97 class OOp_CharLength : public OUnaryOperator
99 protected:
100 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
103 /** CHAR(N,...)
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'));
107 -> 'test'
108 > SELECT CHAR(77,77.3,'77.3');
109 -> 'MMM'
112 class OOp_Char : public ONthOperator
114 protected:
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');
122 -> 'OOoOO'
123 > SELECT CONCAT('OO', NULL, 'OO');
124 -> NULL
125 > SELECT CONCAT(14.3);
126 -> '14.3'
129 class OOp_Concat : public ONthOperator
131 protected:
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');
140 -> 4
141 > SELECT LOCATE('xbar', 'foobar');
142 -> 0
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);
147 -> 7
150 class OOp_Locate : public ONthOperator
152 protected:
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);
161 -> 'ratically'
162 > SELECT SUBSTRING('foobarbar' FROM 4);
163 -> 'barbar'
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);
169 -> 'ratica'
172 class OOp_SubString : public ONthOperator
174 protected:
175 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
178 /** LTRIM(str)
179 Returns the string str with leading space characters removed:
181 > SELECT LTRIM(' barbar');
182 -> 'barbar'
185 class OOp_LTrim : public OUnaryOperator
187 protected:
188 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
191 /** RTRIM(str)
192 Returns the string str with trailing space characters removed:
194 > SELECT RTRIM('barbar ');
195 -> 'barbar'
198 class OOp_RTrim : public OUnaryOperator
200 protected:
201 virtual ORowSetValue operate(const ORowSetValue& lhs) const;
204 /** SPACE(N)
205 Returns a string consisting of N space characters:
207 > SELECT SPACE(6);
208 -> ' '
211 class OOp_Space : public OUnaryOperator
213 protected:
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');
221 -> 'WwWwWw.OOo.com'
224 class OOp_Replace : public ONthOperator
226 protected:
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);
234 -> 'OOoOOoOOo'
237 class OOp_Repeat : public OBinaryOperator
239 protected:
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');
247 -> 'QuWhattic'
250 class OOp_Insert : public ONthOperator
252 protected:
253 virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
256 /** LEFT(str,len)
257 Returns the leftmost len characters from the string str:
259 > SELECT LEFT('foobarbar', 5);
260 -> 'fooba'
263 class OOp_Left : public OBinaryOperator
265 protected:
266 virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
269 /** RIGHT(str,len)
270 Returns the rightmost len characters from the string str:
272 > SELECT RIGHT('foobarbar', 4);
273 -> 'rbar'
275 class OOp_Right : public OBinaryOperator
277 protected:
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: */