1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _CONNECTIVITY_FILE_FANALYZER_HXX_
29 #define _CONNECTIVITY_FILE_FANALYZER_HXX_
30 
31 #include "file/fcomp.hxx"
32 #include "file/filedllapi.hxx"
33 
34 namespace connectivity
35 {
36 	namespace file
37 	{
38 		class OConnection;
39 		class OOO_DLLPUBLIC_FILE OSQLAnalyzer
40 		{
41 			typedef ::std::list<OEvaluateSet*>		OEvaluateSetList;
42 			typedef ::std::pair< ::vos::ORef<OPredicateCompiler>,::vos::ORef<OPredicateInterpreter> > TPredicates;
43 
44 			::std::vector< TPredicates >		m_aSelectionEvaluations;
45 			::vos::ORef<OPredicateCompiler>		m_aCompiler;
46 			::vos::ORef<OPredicateInterpreter>	m_aInterpreter;
47             OConnection*                        m_pConnection;
48 
49 			mutable sal_Bool 					m_bHasSelectionCode;
50 			mutable sal_Bool 					m_bSelectionFirstTime;
51 
52 			void bindRow(OCodeList& rCodeList,const OValueRefRow& _pRow,OEvaluateSetList& _rEvaluateSetList);
53 
54 		public:
55 			OSQLAnalyzer(OConnection* _pConnection);
56 			virtual ~OSQLAnalyzer();
57 			inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
58 				{ return ::rtl_allocateMemory( nSize ); }
59 			inline static void * SAL_CALL operator new( size_t /*nSize*/,void* _pHint ) SAL_THROW( () )
60 				{ return _pHint; }
61 			inline static void SAL_CALL	operator delete( void *	pMem ) SAL_THROW( () )
62 				{ ::rtl_freeMemory( pMem ); }
63 			inline static void SAL_CALL operator delete( void * /*pMem*/,void* /*_pHint*/ ) SAL_THROW( () )
64 				{  }
65 
66             OConnection* getConnection() const { return m_pConnection; }
67 			void describeParam(::vos::ORef<OSQLColumns> rParameterColumns); // genauere Beschreibung der Parameter
68 			::std::vector<sal_Int32>* bindEvaluationRow(OValueRefRow& _pRow);					// Anbinden einer Ergebniszeile an die Restrictions
69 			/** bind the select columns if they contain a function which needs a row value
70 				@param	_pRow	the result row
71 			*/
72 			void bindSelectRow(const OValueRefRow& _pRow);
73 
74 			/** binds the row to parameter for the restrictions
75 				@param	_pRow	the parameter row
76 			*/
77 			void bindParameterRow(OValueRefRow& _pRow);
78 
79 			void setIndexes(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xIndexes);
80 
81 			void dispose();
82 			void start(OSQLParseNode* pSQLParseNode);
83 			void clean();
84 			virtual sal_Bool hasRestriction() const;
85 			virtual sal_Bool hasFunctions() const;
86 			inline sal_Bool evaluateRestriction()	{ return m_aInterpreter->start(); }
87 			void setSelectionEvaluationResult(OValueRefRow& _pRow,const ::std::vector<sal_Int32>& _rColumnMapping);
88 			void setOrigColumns(const OFileColumns& rCols);
89 			virtual OOperandAttr* createOperandAttr(sal_Int32 _nPos,
90 													const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xCol,
91 													const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xIndexes=NULL);
92 		};
93 	}
94 }
95 #endif // _CONNECTIVITY_FILE_FANALYZER_HXX_
96 
97