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