1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef _CONNECTIVITY_FILE_FCOMP_HXX_
29 #define _CONNECTIVITY_FILE_FCOMP_HXX_
31 #include "file/fcode.hxx"
32 #include "file/filedllapi.hxx"
37 namespace connectivity
45 typedef::std::vector
<OCode
*> OCodeList
;
47 class OPredicateCompiler
: public ::salhelper::SimpleReferenceObject
49 friend class OPredicateInterpreter
;
50 friend class OSQLAnalyzer
;
52 OCodeList m_aCodeList
;
53 OFileColumns m_orgColumns
; // in filecurs this are the filecolumns
54 OSQLAnalyzer
* m_pAnalyzer
;
55 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> m_xIndexes
;
56 sal_Int32 m_nParamCounter
;
57 sal_Bool m_bORCondition
;
59 OPredicateCompiler(OSQLAnalyzer
* pAnalyzer
);
61 virtual ~OPredicateCompiler();
63 inline static void * SAL_CALL
operator new( size_t nSize
) SAL_THROW(())
64 { return ::rtl_allocateMemory( nSize
); }
65 inline static void * SAL_CALL
operator new( size_t /*nSize*/,void* _pHint
) SAL_THROW(())
67 inline static void SAL_CALL
operator delete( void * pMem
) SAL_THROW(())
68 { ::rtl_freeMemory( pMem
); }
69 inline static void SAL_CALL
operator delete( void * /*pMem*/,void* /*_pHint*/ ) SAL_THROW(())
73 void start(connectivity::OSQLParseNode
* pSQLParseNode
);
74 OOperand
* execute(connectivity::OSQLParseNode
* pPredicateNode
);
77 sal_Bool
isClean() const {return m_aCodeList
.empty();}
78 sal_Bool
hasCode() const {return !isClean();}
79 sal_Bool
hasORCondition() const {return m_bORCondition
;}
80 void setOrigColumns(const OFileColumns
& rCols
) { m_orgColumns
= rCols
; }
81 const OFileColumns
getOrigColumns() const { return m_orgColumns
; }
83 OOperand
* execute_COMPARE(connectivity::OSQLParseNode
* pPredicateNode
) throw( ::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
84 OOperand
* execute_LIKE(connectivity::OSQLParseNode
* pPredicateNode
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
85 OOperand
* execute_BETWEEN(connectivity::OSQLParseNode
* pPredicateNode
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
86 OOperand
* execute_ISNULL(connectivity::OSQLParseNode
* pPredicateNode
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
87 OOperand
* execute_Operand(connectivity::OSQLParseNode
* pPredicateNode
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
88 OOperand
* execute_Fold(OSQLParseNode
* pPredicateNode
) throw( ::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
89 OOperand
* executeFunction(OSQLParseNode
* pPredicateNode
) throw( ::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
93 class OPredicateInterpreter
:
94 public ::salhelper::SimpleReferenceObject
97 ::rtl::Reference
<OPredicateCompiler
> m_rCompiler
;
100 OPredicateInterpreter(const ::rtl::Reference
<OPredicateCompiler
>& rComp
) : m_rCompiler(rComp
){}
101 virtual ~OPredicateInterpreter();
103 sal_Bool
evaluate(OCodeList
& rCodeList
);
104 void evaluateSelection(OCodeList
& rCodeList
,ORowSetValueDecoratorRef
& _rVal
);
106 inline sal_Bool
start()
108 return evaluate(m_rCompiler
->m_aCodeList
);
111 inline void startSelection(ORowSetValueDecoratorRef
& _rVal
)
113 evaluateSelection(m_rCompiler
->m_aCodeList
,_rVal
);
120 #endif // _CONNECTIVITY_FILE_FCOMP_HXX_
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */