1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski  *
3*b1cdbd2cSJim Jagielski  * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski  * or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski  * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski  * regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski  * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski  * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski  * with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski  *
11*b1cdbd2cSJim Jagielski  *   http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski  *
13*b1cdbd2cSJim Jagielski  * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski  * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski  * KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski  * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski  * under the License.
19*b1cdbd2cSJim Jagielski  *
20*b1cdbd2cSJim Jagielski  *************************************************************/
21*b1cdbd2cSJim Jagielski 
22*b1cdbd2cSJim Jagielski 
23*b1cdbd2cSJim Jagielski #ifndef _CONNECTIVITY_SQLSCAN_HXX
24*b1cdbd2cSJim Jagielski #define _CONNECTIVITY_SQLSCAN_HXX
25*b1cdbd2cSJim Jagielski 
26*b1cdbd2cSJim Jagielski #include <stdarg.h>
27*b1cdbd2cSJim Jagielski #include "connectivity/IParseContext.hxx"
28*b1cdbd2cSJim Jagielski #include "connectivity/dbtoolsdllapi.hxx"
29*b1cdbd2cSJim Jagielski 
30*b1cdbd2cSJim Jagielski namespace connectivity
31*b1cdbd2cSJim Jagielski {
32*b1cdbd2cSJim Jagielski 	//==========================================================================
33*b1cdbd2cSJim Jagielski 	//= OSQLScanner
34*b1cdbd2cSJim Jagielski 	//==========================================================================
35*b1cdbd2cSJim Jagielski 	/** Scanner for SQL92
36*b1cdbd2cSJim Jagielski 	*/
37*b1cdbd2cSJim Jagielski 	class OOO_DLLPUBLIC_DBTOOLS OSQLScanner
38*b1cdbd2cSJim Jagielski 	{
39*b1cdbd2cSJim Jagielski 		const IParseContext*	m_pContext;					// context for parse, knows all international stuff
40*b1cdbd2cSJim Jagielski 		::rtl::OString			m_sStatement;			    // statement to parse
41*b1cdbd2cSJim Jagielski 		::rtl::OUString			m_sErrorMessage;
42*b1cdbd2cSJim Jagielski 
43*b1cdbd2cSJim Jagielski 		sal_Int32				m_nCurrentPos;             // next position to read from the statement
44*b1cdbd2cSJim Jagielski 		sal_Bool				m_bInternational;		   // do we have a statement which may uses
45*b1cdbd2cSJim Jagielski 		sal_Int32				m_nRule;				   // rule to be set
46*b1cdbd2cSJim Jagielski 
47*b1cdbd2cSJim Jagielski 	public:
48*b1cdbd2cSJim Jagielski 		OSQLScanner();
49*b1cdbd2cSJim Jagielski 		virtual ~OSQLScanner();
50*b1cdbd2cSJim Jagielski 
operator new(size_t nSize)51*b1cdbd2cSJim Jagielski 		inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
52*b1cdbd2cSJim Jagielski 			{ return ::rtl_allocateMemory( nSize ); }
operator new(size_t,void * _pHint)53*b1cdbd2cSJim Jagielski 		inline static void * SAL_CALL operator new( size_t,void* _pHint ) SAL_THROW( () )
54*b1cdbd2cSJim Jagielski 			{ return _pHint; }
operator delete(void * pMem)55*b1cdbd2cSJim Jagielski 		inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
56*b1cdbd2cSJim Jagielski 			{ ::rtl_freeMemory( pMem ); }
operator delete(void *,void *)57*b1cdbd2cSJim Jagielski 		inline static void SAL_CALL operator delete( void *,void* ) SAL_THROW( () )
58*b1cdbd2cSJim Jagielski 			{  }
59*b1cdbd2cSJim Jagielski 
60*b1cdbd2cSJim Jagielski 		virtual sal_Int32 SQLyygetc(void);
61*b1cdbd2cSJim Jagielski 		virtual void SQLyyerror(char *fmt);
output(sal_Int32)62*b1cdbd2cSJim Jagielski 		virtual void output(sal_Int32) { OSL_ASSERT("Internal error in sdblex.l: output not possible"); }
ECHO(void)63*b1cdbd2cSJim Jagielski 		virtual void ECHO(void) { OSL_ASSERT("Internal error in sdblex.l: ECHO not possible"); }
64*b1cdbd2cSJim Jagielski 		virtual IParseContext::InternationalKeyCode getInternationalTokenID(const char* sToken) const;
65*b1cdbd2cSJim Jagielski 
66*b1cdbd2cSJim Jagielski 		// setting the new information before scanning
67*b1cdbd2cSJim Jagielski 		void prepareScan(const ::rtl::OUString & rNewStatement, const IParseContext* pContext, sal_Bool bInternational);
getErrorMessage() const68*b1cdbd2cSJim Jagielski 		const ::rtl::OUString& getErrorMessage() const {return m_sErrorMessage;}
getStatement() const69*b1cdbd2cSJim Jagielski 		::rtl::OString getStatement() const { return m_sStatement; }
70*b1cdbd2cSJim Jagielski 
71*b1cdbd2cSJim Jagielski 		sal_Int32 SQLlex();
72*b1cdbd2cSJim Jagielski 		// set this as scanner for flex
73*b1cdbd2cSJim Jagielski 		void setScanner(sal_Bool _bNull=sal_False);
74*b1cdbd2cSJim Jagielski 		// rules settings
SetRule(sal_Int32 nRule)75*b1cdbd2cSJim Jagielski 		void SetRule(sal_Int32 nRule) {m_nRule = nRule;}
76*b1cdbd2cSJim Jagielski 		sal_Int32	GetCurrentRule() const;
77*b1cdbd2cSJim Jagielski 		sal_Int32	GetGERRule() const;
78*b1cdbd2cSJim Jagielski 		sal_Int32	GetENGRule() const;
79*b1cdbd2cSJim Jagielski 		sal_Int32	GetSQLRule() const;
80*b1cdbd2cSJim Jagielski 		sal_Int32	GetDATERule() const;
81*b1cdbd2cSJim Jagielski 		sal_Int32	GetSTRINGRule() const;
GetCurrentPos() const82*b1cdbd2cSJim Jagielski         inline sal_Int32 GetCurrentPos() const { return m_nCurrentPos; }
83*b1cdbd2cSJim Jagielski 	};
84*b1cdbd2cSJim Jagielski }
85*b1cdbd2cSJim Jagielski 
86*b1cdbd2cSJim Jagielski #endif
87