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