19#ifndef INCLUDED_CONNECTIVITY_SQLNODE_HXX
20#define INCLUDED_CONNECTIVITY_SQLNODE_HXX
24#include <com/sun/star/uno/Reference.hxx>
29#include <rtl/ustrbuf.hxx>
43 class XNumberFormatter;
51#define ORDER_BY_CHILD_POS 5
52#define TABLE_EXPRESSION_CHILD_COUNT 9
75 css::uno::Reference< css::util::XNumberFormatter >
xFormatter;
76 css::uno::Reference< css::beans::XPropertySet >
xField;
78 css::uno::Reference< css::container::XNameAccess >
xQueries;
87 const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
88 const css::uno::Reference< css::util::XNumberFormatter >& _xFormatter,
89 const css::uno::Reference< css::beans::XPropertySet >& _xField,
90 OUString _sPredicateTableAlias,
91 const css::lang::Locale& _rLocale,
107 std::vector< std::unique_ptr<OSQLParseNode> >
232 sal_uInt32 _nNodeID = 0);
236 sal_uInt32 nNewNodeID=0);
240 sal_uInt32 _nNodeID = 0);
255 size_t count()
const {
return m_aChildren.size();};
265 void replaceNodeValue(
const OUString& rTableAlias,
const OUString& rColumnName);
303 bool parseNodeToExecutableStatement( OUString& _out_rString,
304 const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
306 css::sdbc::SQLException* _pErrorHolder )
const;
309 const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
312 bool _bQuote=
true)
const;
316 const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
317 const css::uno::Reference< css::util::XNumberFormatter > & xFormatter,
318 const css::lang::Locale& rIntl,
323 const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
324 const css::uno::Reference< css::util::XNumberFormatter > & xFormatter,
325 const css::uno::Reference< css::beans::XPropertySet > & _xField,
326 const OUString &_sTableAlias,
327 const css::lang::Locale& rIntl,
333#if OSL_DEBUG_LEVEL > 1
335 void showParseTree( OUString& rString )
const;
336 void showParseTree( OUStringBuffer& _inout_rBuf, sal_uInt32 nLevel )
const;
347 Rule getKnownRuleID()
const;
363 bool isLeaf()
const {
return m_aChildren.empty();}
366 static void negateSearchCondition(
OSQLParseNode*& pSearchCondition,
bool bNegate=
false);
370 static void disjunctiveNormalForm(
OSQLParseNode*& pSearchCondition);
386 static bool getTableComponents(
const OSQLParseNode* _pTableNode,
387 css::uno::Any &_rCatalog,
390 const css::uno::Reference< css::sdbc::XDatabaseMetaData >& _xMetaData);
394 static void substituteParameterNames(
OSQLParseNode const * _pNode);
398 static OUString getTableRange(
const OSQLParseNode* _pTableRef);
403 const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
404 const css::uno::Reference< css::util::XNumberFormatter > & xFormatter,
405 const css::uno::Reference< css::beans::XPropertySet > & _xField,
406 const OUString &_sPredicateTableAlias,
407 const css::lang::Locale& rIntl,
412 bool _bPredicate)
const;
415 void impl_parseNodeToString_throw( OUStringBuffer& rString,
const SQLParseNodeParameter& rParam,
bool bSimple=
true )
const;
416 void impl_parseLikeNodeToString_throw( OUStringBuffer& rString,
const SQLParseNodeParameter& rParam,
bool bSimple=
true )
const;
417 void impl_parseTableRangeNodeToString_throw( OUStringBuffer& rString,
const SQLParseNodeParameter& rParam )
const;
424 bool impl_parseTableNameNodeToString_throw( OUStringBuffer& rString,
const SQLParseNodeParameter& rParam )
const;
439 #define SQL_ISRULE(pParseNode, eRule) ((pParseNode)->isRule() && (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::eRule))
440 #define SQL_ISRULEOR2(pParseNode, e1, e2) ((pParseNode)->isRule() && ( \
441 (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \
442 (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2)))
443 #define SQL_ISRULEOR3(pParseNode, e1, e2, e3) ((pParseNode)->isRule() && ( \
444 (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \
445 (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2) || \
446 (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e3)))
447 #define SQL_ISTOKEN(pParseNode, token) ((pParseNode)->isToken() && (pParseNode)->getTokenID() == SQL_TOKEN_##token)
448 #define SQL_ISTOKENOR2(pParseNode, tok0, tok1) ((pParseNode)->isToken() && ( (pParseNode)->getTokenID() == SQL_TOKEN_##tok0 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok1 ))
449 #define SQL_ISTOKENOR3(pParseNode, tok0, tok1, tok2) ((pParseNode)->isToken() && ( (pParseNode)->getTokenID() == SQL_TOKEN_##tok0 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok1 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok2 ))
450 #define SQL_ISPUNCTUATION(pParseNode, aString) ((pParseNode)->getNodeType() == SQLNodeType::Punctuation && (pParseNode)->getTokenValue() == (aString))
void parseNodeToStr(OUString &rString, const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const css::uno::Reference< css::beans::XPropertySet > &_xField, const OUString &_sPredicateTableAlias, const css::lang::Locale &rIntl, const IParseContext *pContext, bool _bIntl, bool _bQuote, OUString _sDecSep, bool _bPredicate) const
void parseNodeToStr(OUString &rString, const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, const IParseContext *pContext=nullptr, bool _bIntl=false, bool _bQuote=true) const
void setParent(OSQLParseNode *pParseNode)
@ base_table_element_commalist
@ delete_statement_searched
@ between_predicate_part_2
@ other_like_predicate_part_2
@ ordering_spec_commalist
@ table_primary_as_range_column
@ update_statement_searched
@ parenthesized_boolean_value_expression
@ comparison_predicate_part_2
@ delete_statement_positioned
@ update_statement_positioned
void parseNodeToPredicateStr(OUString &rString, const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const css::uno::Reference< css::beans::XPropertySet > &_xField, const OUString &_sTableAlias, const css::lang::Locale &rIntl, OUString strDec, const IParseContext *pContext=nullptr) const
std::vector< std::unique_ptr< OSQLParseNode > > m_aChildren
sal_uInt32 getTokenID() const
void parseNodeToPredicateStr(OUString &rString, const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const css::lang::Locale &rIntl, OUString _sDec, const IParseContext *pContext=nullptr) const
const OUString & getTokenValue() const
sal_uInt32 getRuleID() const
OSQLParseNode * getParent() const
OSQLParseNode * getChild(sal_uInt32 nPos) const
OSQLParseNode * m_pParent
SQLNodeType getNodeType() const
class SAL_NO_VTABLE XPropertySet
::std::set< OUString > QueryNameSet
SQLParseNodeParameter(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, const css::uno::Reference< css::util::XNumberFormatter > &_xFormatter, const css::uno::Reference< css::beans::XPropertySet > &_xField, OUString _sPredicateTableAlias, const css::lang::Locale &_rLocale, const IParseContext *_pContext, bool _bIntl, bool _bQuote, OUString _sDecSep, bool _bPredicate, bool _bParseToSDBC)
should we create an SDBC-level statement (e.g. with substituted sub queries)?
::dbtools::DatabaseMetaData aMetaData
const IParseContext & m_rContext
const css::lang::Locale & rLocale
bool bPredicate
should we internationalize keywords and placeholders?
css::uno::Reference< css::beans::XPropertySet > xField
css::uno::Reference< css::util::XNumberFormatter > xFormatter
OUString sPredicateTableAlias
std::shared_ptr< QueryNameSet > pSubQueryHistory
css::uno::Reference< css::container::XNameAccess > xQueries
bool bParseToSDBCLevel
are we going to parse a mere predicate?
bool bInternational
should we quote identifiers?