1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _CONNECTIVITY_FILE_FSTRINGFUNCTIONS_HXX_
25 #define _CONNECTIVITY_FILE_FSTRINGFUNCTIONS_HXX_
26 
27 #include "file/fcode.hxx"
28 #include "file/filedllapi.hxx"
29 
30 namespace connectivity
31 {
32 	class OSQLParseNode;
33 	namespace file
34 	{
35 		/** UCASE(str)
36 			UPPER(str)
37 				Returns the string str with all characters changed to uppercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
38 
39 			> SELECT UCASE('Hej');
40 					-> 'HEJ'
41 
42 		*/
43 		class OOp_Upper : public OUnaryOperator
44 		{
45 		protected:
46 			virtual ORowSetValue operate(const ORowSetValue& lhs) const;
47 		};
48 
49 		/** LCASE(str)
50 			LOWER(str)
51 				Returns the string str with all characters changed to lowercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
52 
53 			> SELECT LCASE('QUADRATICALLY');
54 					-> 'quadratically'
55 
56 		*/
57 		class OOp_Lower : public OUnaryOperator
58 		{
59 		protected:
60 			virtual ORowSetValue operate(const ORowSetValue& lhs) const;
61 		};
62 
63 		/** ASCII(str)
64 			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 
66 			> SELECT ASCII('2');
67 				-> 50
68 			> SELECT ASCII(2);
69 				-> 50
70 			> SELECT ASCII('dx');
71 				-> 100
72 
73 		*/
74 		class OOp_Ascii : public OUnaryOperator
75 		{
76 		protected:
77 			virtual ORowSetValue operate(const ORowSetValue& lhs) const;
78 		};
79 
80 		/** LENGTH(str)
81 			OCTET_LENGTH(str)
82 			CHAR_LENGTH(str)
83 			CHARACTER_LENGTH(str)
84 				Returns the length of the string str:
85 
86 			> SELECT LENGTH('text');
87 					-> 4
88 			> SELECT OCTET_LENGTH('text');
89 					-> 4
90 
91 		*/
92 		class OOp_CharLength : public OUnaryOperator
93 		{
94 		protected:
95 			virtual ORowSetValue operate(const ORowSetValue& lhs) const;
96 		};
97 
98 		/** CHAR(N,...)
99 			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:
100 
101 			> SELECT CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t'));
102 				-> 'test'
103 			> SELECT CHAR(77,77.3,'77.3');
104 				-> 'MMM'
105 
106 		*/
107 		class OOp_Char : public ONthOperator
108 		{
109 		protected:
110 			virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
111 		};
112 
113 		/** CONCAT(str1,str2,...)
114 			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:
115 
116 			> SELECT CONCAT('OO', 'o', 'OO');
117 				-> 'OOoOO'
118 			> SELECT CONCAT('OO', NULL, 'OO');
119 				-> NULL
120 			> SELECT CONCAT(14.3);
121 				-> '14.3'
122 
123 		*/
124 		class OOp_Concat : public ONthOperator
125 		{
126 		protected:
127 			virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
128 		};
129 
130 		/** LOCATE(substr,str)
131 			POSITION(substr IN str)
132 			Returns the position of the first occurrence of substring substr in string str. Returns 0 if substr is not in str:
133 
134 			> SELECT LOCATE('bar', 'foobarbar');
135 					-> 4
136 			> SELECT LOCATE('xbar', 'foobar');
137 					-> 0
138 			LOCATE(substr,str,pos)
139 			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:
140 
141 			> SELECT LOCATE('bar', 'foobarbar',5);
142 				-> 7
143 
144 		*/
145 		class OOp_Locate : public ONthOperator
146 		{
147 		protected:
148 			virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
149 		};
150 
151 		/** SUBSTRING(str,pos)
152 			SUBSTRING(str FROM pos)
153 				Returns a substring from string str starting at position pos:
154 
155 			> SELECT SUBSTRING('Quadratically',5);
156 					-> 'ratically'
157 			> SELECT SUBSTRING('foobarbar' FROM 4);
158 					-> 'barbar'
159 			SUBSTRING(str,pos,len)
160 			SUBSTRING(str FROM pos FOR len)
161 				Returns a substring len characters long from string str, starting at position pos. The variant form that uses FROM is SQL-92 syntax:
162 
163 			> SELECT SUBSTRING('Quadratically',5,6);
164 					-> 'ratica'
165 
166 		*/
167 		class OOp_SubString : public ONthOperator
168 		{
169 		protected:
170 			virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
171 		};
172 
173 		/** LTRIM(str)
174 			Returns the string str with leading space characters removed:
175 
176 			> SELECT LTRIM('  barbar');
177 				-> 'barbar'
178 
179 		*/
180 		class OOp_LTrim : public OUnaryOperator
181 		{
182 		protected:
183 			virtual ORowSetValue operate(const ORowSetValue& lhs) const;
184 		};
185 
186 		/** RTRIM(str)
187 			Returns the string str with trailing space characters removed:
188 
189 			> SELECT RTRIM('barbar   ');
190 				-> 'barbar'
191 
192 		*/
193 		class OOp_RTrim : public OUnaryOperator
194 		{
195 		protected:
196 			virtual ORowSetValue operate(const ORowSetValue& lhs) const;
197 		};
198 
199 		/** SPACE(N)
200 			Returns a string consisting of N space characters:
201 
202 			> SELECT SPACE(6);
203 				-> '      '
204 
205 		*/
206 		class OOp_Space : public OUnaryOperator
207 		{
208 		protected:
209 			virtual ORowSetValue operate(const ORowSetValue& lhs) const;
210 		};
211 
212 		/** REPLACE(str,from_str,to_str)
213 			Returns the string str with all occurrences of the string from_str replaced by the string to_str:
214 
215 			> SELECT REPLACE('www.OOo.com', 'w', 'Ww');
216 				-> 'WwWwWw.OOo.com'
217 
218 		*/
219 		class OOp_Replace : public ONthOperator
220 		{
221 		protected:
222 			virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
223 		};
224 
225 		/** REPEAT(str,count)
226 			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:
227 
228 			> SELECT REPEAT('OOo', 3);
229 				-> 'OOoOOoOOo'
230 
231 		*/
232 		class OOp_Repeat : public OBinaryOperator
233 		{
234 		protected:
235 			virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
236 		};
237 
238 		/** INSERT(str,pos,len,newstr)
239 			Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr:
240 
241 			> SELECT INSERT('Quadratic', 3, 4, 'What');
242 				-> 'QuWhattic'
243 
244 		*/
245 		class OOp_Insert : public ONthOperator
246 		{
247 		protected:
248 			virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
249 		};
250 
251 		/** LEFT(str,len)
252 			Returns the leftmost len characters from the string str:
253 
254 			> SELECT LEFT('foobarbar', 5);
255 				-> 'fooba'
256 
257 		*/
258 		class OOp_Left : public OBinaryOperator
259 		{
260 		protected:
261 			virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
262 		};
263 
264 		/** RIGHT(str,len)
265 			Returns the rightmost len characters from the string str:
266 
267 			> SELECT RIGHT('foobarbar', 4);
268 				-> 'rbar'
269 		*/
270 		class OOp_Right : public OBinaryOperator
271 		{
272 		protected:
273 			virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
274 		};
275 	}
276 }
277 
278 #endif // _CONNECTIVITY_FILE_FCODE_HXX_
279 
280