1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FSTRINGFUNCTIONS_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FSTRINGFUNCTIONS_HXX
23 #include "file/fcode.hxx"
24 #include "file/filedllapi.hxx"
26 namespace connectivity
32 Returns the string str with all characters changed to uppercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
34 > SELECT UCASE('Hej');
38 class OOp_Upper
: public OUnaryOperator
41 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
46 Returns the string str with all characters changed to lowercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
48 > SELECT LCASE('QUADRATICALLY');
52 class OOp_Lower
: public OUnaryOperator
55 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
59 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 class OOp_Ascii
: public OUnaryOperator
72 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
79 Returns the length of the string str:
81 > SELECT LENGTH('text');
83 > SELECT OCTET_LENGTH('text');
87 class OOp_CharLength
: public OUnaryOperator
90 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
94 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:
96 > SELECT CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t'));
98 > SELECT CHAR(77,77.3,'77.3');
102 class OOp_Char
: public ONthOperator
105 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const SAL_OVERRIDE
;
108 /** CONCAT(str1,str2,...)
109 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:
111 > SELECT CONCAT('OO', 'o', 'OO');
113 > SELECT CONCAT('OO', NULL, 'OO');
115 > SELECT CONCAT(14.3);
119 class OOp_Concat
: public ONthOperator
122 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const SAL_OVERRIDE
;
125 /** LOCATE(substr,str)
126 POSITION(substr IN str)
127 Returns the position of the first occurrence of substring substr in string str. Returns 0 if substr is not in str:
129 > SELECT LOCATE('bar', 'foobarbar');
131 > SELECT LOCATE('xbar', 'foobar');
133 LOCATE(substr,str,pos)
134 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:
136 > SELECT LOCATE('bar', 'foobarbar',5);
140 class OOp_Locate
: public ONthOperator
143 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const SAL_OVERRIDE
;
146 /** SUBSTRING(str,pos)
147 SUBSTRING(str FROM pos)
148 Returns a substring from string str starting at position pos:
150 > SELECT SUBSTRING('Quadratically',5);
152 > SELECT SUBSTRING('foobarbar' FROM 4);
154 SUBSTRING(str,pos,len)
155 SUBSTRING(str FROM pos FOR len)
156 Returns a substring len characters long from string str, starting at position pos. The variant form that uses FROM is SQL-92 syntax:
158 > SELECT SUBSTRING('Quadratically',5,6);
162 class OOp_SubString
: public ONthOperator
165 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const SAL_OVERRIDE
;
169 Returns the string str with leading space characters removed:
171 > SELECT LTRIM(' barbar');
175 class OOp_LTrim
: public OUnaryOperator
178 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
182 Returns the string str with trailing space characters removed:
184 > SELECT RTRIM('barbar ');
188 class OOp_RTrim
: public OUnaryOperator
191 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
195 Returns a string consisting of N space characters:
201 class OOp_Space
: public OUnaryOperator
204 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const SAL_OVERRIDE
;
207 /** REPLACE(str,from_str,to_str)
208 Returns the string str with all occurrences of the string from_str replaced by the string to_str:
210 > SELECT REPLACE('www.OOo.com', 'w', 'Ww');
214 class OOp_Replace
: public ONthOperator
217 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const SAL_OVERRIDE
;
220 /** REPEAT(str,count)
221 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:
223 > SELECT REPEAT('OOo', 3);
227 class OOp_Repeat
: public OBinaryOperator
230 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const SAL_OVERRIDE
;
233 /** INSERT(str,pos,len,newstr)
234 Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr:
236 > SELECT INSERT('Quadratic', 3, 4, 'What');
240 class OOp_Insert
: public ONthOperator
243 virtual ORowSetValue
operate(const ::std::vector
<ORowSetValue
>& lhs
) const SAL_OVERRIDE
;
247 Returns the leftmost len characters from the string str:
249 > SELECT LEFT('foobarbar', 5);
253 class OOp_Left
: public OBinaryOperator
256 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const SAL_OVERRIDE
;
260 Returns the rightmost len characters from the string str:
262 > SELECT RIGHT('foobarbar', 4);
265 class OOp_Right
: public OBinaryOperator
268 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const SAL_OVERRIDE
;
273 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FSTRINGFUNCTIONS_HXX
275 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */