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 
24 #ifndef _CONNECTIVITY_FILE_FANALYZER_HXX_
25 #define _CONNECTIVITY_FILE_FANALYZER_HXX_
26 
27 #include "file/fcomp.hxx"
28 #include "file/filedllapi.hxx"
29 
30 namespace connectivity
31 {
32 	namespace file
33 	{
34 		class OConnection;
35 		class OOO_DLLPUBLIC_FILE OSQLAnalyzer
36 		{
37 			typedef ::std::list<OEvaluateSet*>		OEvaluateSetList;
38 			typedef ::std::pair< ::vos::ORef<OPredicateCompiler>,::vos::ORef<OPredicateInterpreter> > TPredicates;
39 
40 			::std::vector< TPredicates >		m_aSelectionEvaluations;
41 			::vos::ORef<OPredicateCompiler>		m_aCompiler;
42 			::vos::ORef<OPredicateInterpreter>	m_aInterpreter;
43             OConnection*                        m_pConnection;
44 
45 			mutable sal_Bool 					m_bHasSelectionCode;
46 			mutable sal_Bool 					m_bSelectionFirstTime;
47 
48 			void bindRow(OCodeList& rCodeList,const OValueRefRow& _pRow,OEvaluateSetList& _rEvaluateSetList);
49 
50 		public:
51 			OSQLAnalyzer(OConnection* _pConnection);
52 			virtual ~OSQLAnalyzer();
operator new(size_t nSize)53 			inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
54 				{ return ::rtl_allocateMemory( nSize ); }
operator new(size_t,void * _pHint)55 			inline static void * SAL_CALL operator new( size_t /*nSize*/,void* _pHint ) SAL_THROW( () )
56 				{ return _pHint; }
operator delete(void * pMem)57 			inline static void SAL_CALL	operator delete( void *	pMem ) SAL_THROW( () )
58 				{ ::rtl_freeMemory( pMem ); }
operator delete(void *,void *)59 			inline static void SAL_CALL operator delete( void * /*pMem*/,void* /*_pHint*/ ) SAL_THROW( () )
60 				{  }
61 
getConnection() const62             OConnection* getConnection() const { return m_pConnection; }
63 			void describeParam(::vos::ORef<OSQLColumns> rParameterColumns); // genauere Beschreibung der Parameter
64 			::std::vector<sal_Int32>* bindEvaluationRow(OValueRefRow& _pRow);					// Anbinden einer Ergebniszeile an die Restrictions
65 			/** bind the select columns if they contain a function which needs a row value
66 				@param	_pRow	the result row
67 			*/
68 			void bindSelectRow(const OValueRefRow& _pRow);
69 
70 			/** binds the row to parameter for the restrictions
71 				@param	_pRow	the parameter row
72 			*/
73 			void bindParameterRow(OValueRefRow& _pRow);
74 
75 			void setIndexes(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xIndexes);
76 
77 			void dispose();
78 			void start(OSQLParseNode* pSQLParseNode);
79 			void clean();
80 			virtual sal_Bool hasRestriction() const;
81 			virtual sal_Bool hasFunctions() const;
evaluateRestriction()82 			inline sal_Bool evaluateRestriction()	{ return m_aInterpreter->start(); }
83 			void setSelectionEvaluationResult(OValueRefRow& _pRow,const ::std::vector<sal_Int32>& _rColumnMapping);
84 			void setOrigColumns(const OFileColumns& rCols);
85 			virtual OOperandAttr* createOperandAttr(sal_Int32 _nPos,
86 													const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xCol,
87 													const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xIndexes=NULL);
88 		};
89 	}
90 }
91 #endif // _CONNECTIVITY_FILE_FANALYZER_HXX_
92 
93