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 #ifndef _CONNECTIVITY_SQLSCAN_HXX 24 #define _CONNECTIVITY_SQLSCAN_HXX 25 26 #include <stdarg.h> 27 #include "connectivity/IParseContext.hxx" 28 #include "connectivity/dbtoolsdllapi.hxx" 29 30 namespace connectivity 31 { 32 //========================================================================== 33 //= OSQLScanner 34 //========================================================================== 35 /** Scanner for SQL92 36 */ 37 class OOO_DLLPUBLIC_DBTOOLS OSQLScanner 38 { 39 const IParseContext* m_pContext; // context for parse, knows all international stuff 40 ::rtl::OString m_sStatement; // statement to parse 41 ::rtl::OUString m_sErrorMessage; 42 43 sal_Int32 m_nCurrentPos; // next position to read from the statement 44 sal_Bool m_bInternational; // do we have a statement which may uses 45 sal_Int32 m_nRule; // rule to be set 46 47 public: 48 OSQLScanner(); 49 virtual ~OSQLScanner(); 50 51 inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) 52 { return ::rtl_allocateMemory( nSize ); } 53 inline static void * SAL_CALL operator new( size_t,void* _pHint ) SAL_THROW( () ) 54 { return _pHint; } 55 inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) 56 { ::rtl_freeMemory( pMem ); } 57 inline static void SAL_CALL operator delete( void *,void* ) SAL_THROW( () ) 58 { } 59 60 virtual sal_Int32 SQLyygetc(void); 61 virtual void SQLyyerror(char *fmt); 62 virtual void output(sal_Int32) { OSL_ASSERT("Internal error in sdblex.l: output not possible"); } 63 virtual void ECHO(void) { OSL_ASSERT("Internal error in sdblex.l: ECHO not possible"); } 64 virtual IParseContext::InternationalKeyCode getInternationalTokenID(const char* sToken) const; 65 66 // setting the new information before scanning 67 void prepareScan(const ::rtl::OUString & rNewStatement, const IParseContext* pContext, sal_Bool bInternational); 68 const ::rtl::OUString& getErrorMessage() const {return m_sErrorMessage;} 69 ::rtl::OString getStatement() const { return m_sStatement; } 70 71 sal_Int32 SQLlex(); 72 // set this as scanner for flex 73 void setScanner(sal_Bool _bNull=sal_False); 74 // rules settings 75 void SetRule(sal_Int32 nRule) {m_nRule = nRule;} 76 sal_Int32 GetCurrentRule() const; 77 sal_Int32 GetGERRule() const; 78 sal_Int32 GetENGRule() const; 79 sal_Int32 GetSQLRule() const; 80 sal_Int32 GetDATERule() const; 81 sal_Int32 GetSTRINGRule() const; 82 inline sal_Int32 GetCurrentPos() const { return m_nCurrentPos; } 83 }; 84 } 85 86 #endif 87