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 .
22 #include <file/fcode.hxx>
24 namespace connectivity::file
28 Returns the string str with all characters changed to uppercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
30 > SELECT UCASE('Hej');
34 class OOp_Upper
: public OUnaryOperator
37 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const override
;
42 Returns the string str with all characters changed to lowercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
44 > SELECT LCASE('QUADRATICALLY');
48 class OOp_Lower
: public OUnaryOperator
51 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const override
;
55 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:
65 class OOp_Ascii
: public OUnaryOperator
68 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const override
;
75 Returns the length of the string str:
77 > SELECT LENGTH('text');
79 > SELECT OCTET_LENGTH('text');
83 class OOp_CharLength
: public OUnaryOperator
86 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const override
;
90 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:
92 > SELECT CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t'));
94 > SELECT CHAR(77,77.3,'77.3');
98 class OOp_Char
: public ONthOperator
101 virtual ORowSetValue
operate(const std::vector
<ORowSetValue
>& lhs
) const override
;
104 /** CONCAT(str1,str2,...)
105 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:
107 > SELECT CONCAT('OO', 'o', 'OO');
109 > SELECT CONCAT('OO', NULL, 'OO');
111 > SELECT CONCAT(14.3);
115 class OOp_Concat
: public ONthOperator
118 virtual ORowSetValue
operate(const std::vector
<ORowSetValue
>& lhs
) const override
;
121 /** LOCATE(substr,str)
122 POSITION(substr IN str)
123 Returns the position of the first occurrence of substring substr in string str. Returns 0 if substr is not in str:
125 > SELECT LOCATE('bar', 'foobarbar');
127 > SELECT LOCATE('xbar', 'foobar');
129 LOCATE(substr,str,pos)
130 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:
132 > SELECT LOCATE('bar', 'foobarbar',5);
136 class OOp_Locate
: public ONthOperator
139 virtual ORowSetValue
operate(const std::vector
<ORowSetValue
>& lhs
) const override
;
142 /** SUBSTRING(str,pos)
143 SUBSTRING(str FROM pos)
144 Returns a substring from string str starting at position pos:
146 > SELECT SUBSTRING('Quadratically',5);
148 > SELECT SUBSTRING('foobarbar' FROM 4);
150 SUBSTRING(str,pos,len)
151 SUBSTRING(str FROM pos FOR len)
152 Returns a substring len characters long from string str, starting at position pos. The variant form that uses FROM is SQL-92 syntax:
154 > SELECT SUBSTRING('Quadratically',5,6);
158 class OOp_SubString
: public ONthOperator
161 virtual ORowSetValue
operate(const std::vector
<ORowSetValue
>& lhs
) const override
;
165 Returns the string str with leading space characters removed:
167 > SELECT LTRIM(' barbar');
171 class OOp_LTrim
: public OUnaryOperator
174 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const override
;
178 Returns the string str with trailing space characters removed:
180 > SELECT RTRIM('barbar ');
184 class OOp_RTrim
: public OUnaryOperator
187 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const override
;
191 Returns a string consisting of N space characters:
197 class OOp_Space
: public OUnaryOperator
200 virtual ORowSetValue
operate(const ORowSetValue
& lhs
) const override
;
203 /** REPLACE(str,from_str,to_str)
204 Returns the string str with all occurrences of the string from_str replaced by the string to_str:
206 > SELECT REPLACE('www.OOo.com', 'w', 'Ww');
210 class OOp_Replace
: public ONthOperator
213 virtual ORowSetValue
operate(const std::vector
<ORowSetValue
>& lhs
) const override
;
216 /** REPEAT(str,count)
217 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:
219 > SELECT REPEAT('OOo', 3);
223 class OOp_Repeat
: public OBinaryOperator
226 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const override
;
229 /** INSERT(str,pos,len,newstr)
230 Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr:
232 > SELECT INSERT('Quadratic', 3, 4, 'What');
236 class OOp_Insert
: public ONthOperator
239 virtual ORowSetValue
operate(const std::vector
<ORowSetValue
>& lhs
) const override
;
243 Returns the leftmost len characters from the string str:
245 > SELECT LEFT('foobarbar', 5);
249 class OOp_Left
: public OBinaryOperator
252 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const override
;
256 Returns the rightmost len characters from the string str:
258 > SELECT RIGHT('foobarbar', 4);
261 class OOp_Right
: public OBinaryOperator
264 virtual ORowSetValue
operate(const ORowSetValue
& lhs
,const ORowSetValue
& rhs
) const override
;
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */