zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #02183
[Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
Juan Zacarias has proposed merging lp:~zorba-coders/zorba/api_changes into lp:zorba.
Requested reviews:
Matthias Brantner (matthias-brantner)
Markos Zaharioudakis (markos-za)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/api_changes/+merge/83426
API changes
Removed isBoundExternalVariable from xquery.h
Added 2 functions to dynamic_context.h
isBoundContextItem and isBoundExternalVariable
--
https://code.launchpad.net/~zorba-coders/zorba/api_changes/+merge/83426
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/dynamic_context.h'
--- include/zorba/dynamic_context.h 2011-10-20 17:17:48 +0000
+++ include/zorba/dynamic_context.h 2011-11-25 17:58:26 +0000
@@ -263,6 +263,19 @@
virtual ExternalFunctionParameter*
getExternalFunctionParameter ( const String& aName ) const = 0;
+ /** \brief Returns true if the variable is bound to a value
+ *
+ * @param aNamespace the namespace of the qname of the variable to check
+ * @param aLocalname the localname of the qname of the variable to check
+ */
+ virtual bool
+ isBoundExternalVariable(const String& aNamespace, const String& aLocalname) const = 0;
+
+ /** \brief Returns true if a context item has been bound to the Dynamic Context
+ */
+ virtual bool
+ isBoundContextItem() const = 0;
+
protected:
/** \brief Destructor
*/
=== modified file 'include/zorba/xquery.h'
--- include/zorba/xquery.h 2011-11-11 18:32:12 +0000
+++ include/zorba/xquery.h 2011-11-25 17:58:26 +0000
@@ -304,13 +304,6 @@
*/
virtual void
printPlan(std::ostream& aStream, bool aDotFormat = false) const = 0;
-
- /** \brief Returns true if the variable is bound to a value
- *
- * @param aQName the qname of the variable to check
- */
- virtual bool
- isBoundExternalVariable(const String& aNamespace, const String& aLocalname) const = 0;
/**
* \brief Check if this query is an updating query.
=== modified file 'src/api/dynamiccontextimpl.cpp'
--- src/api/dynamiccontextimpl.cpp 2011-10-20 17:17:48 +0000
+++ src/api/dynamiccontextimpl.cpp 2011-11-25 17:58:26 +0000
@@ -182,6 +182,7 @@
return var;
}
+
/****************************************************************************//**
********************************************************************************/
@@ -592,6 +593,7 @@
return false;
}
+
/****************************************************************************//**
********************************************************************************/
@@ -607,5 +609,38 @@
return 0;
}
+
+/****************************************************************************//**
+
+********************************************************************************/
+bool
+DynamicContextImpl::isBoundExternalVariable(const String& aNamespace, const String& aLocalname) const
+{
+ ZORBA_DCTX_TRY
+ {
+ if(theQuery->isBoundVariable(aNamespace, aLocalname))
+ return true;
+ }
+ ZORBA_DCTX_CATCH
+ return false;
+}
+
+/****************************************************************************//**
+
+********************************************************************************/
+bool
+DynamicContextImpl::isBoundContextItem() const
+{
+ ZORBA_DCTX_TRY
+ {
+ String varName = Unmarshaller::newString(static_context::DOT_VAR_NAME);
+ if(theQuery->isBoundVariable("", varName))
+ return true;
+ }
+ ZORBA_DCTX_CATCH
+ return false;
+
+}
+
} // namespace zorba
/* vim:set et sw=2 ts=2: */
=== modified file 'src/api/dynamiccontextimpl.h'
--- src/api/dynamiccontextimpl.h 2011-10-20 17:17:48 +0000
+++ src/api/dynamiccontextimpl.h 2011-11-25 17:58:26 +0000
@@ -143,6 +143,12 @@
virtual ExternalFunctionParameter*
getExternalFunctionParameter ( const String& aName ) const;
+ virtual bool
+ isBoundExternalVariable(const String& aNamespace, const String& aLocalname) const;
+
+ virtual bool
+ isBoundContextItem() const;
+
protected:
void checkNoIterators() const;
=== modified file 'src/api/xqueryimpl.cpp'
--- src/api/xqueryimpl.cpp 2011-11-11 18:32:12 +0000
+++ src/api/xqueryimpl.cpp 2011-11-25 17:58:26 +0000
@@ -772,11 +772,10 @@
QUERY_CATCH
}
-
/*******************************************************************************
********************************************************************************/
-bool XQueryImpl::isBoundExternalVariable(
+bool XQueryImpl::isBoundVariable(
const String& aNamespace,
const String& aLocalname) const
{
=== modified file 'src/api/xqueryimpl.h'
--- src/api/xqueryimpl.h 2011-11-11 18:32:12 +0000
+++ src/api/xqueryimpl.h 2011-11-25 17:58:26 +0000
@@ -286,8 +286,6 @@
void getExternalVariables(Iterator_t& aVarsIter) const;
- bool isBoundExternalVariable(const String& aNamespace, const String& aLocalname) const;
-
bool isUpdating() const;
bool isSequential() const;
@@ -399,6 +397,8 @@
#endif
void notifyAllWarnings() const;
+
+ bool isBoundVariable(const String& aNamespace, const String& aLocalname) const;
};
=== modified file 'test/unit/cxx_api_changes.cpp'
--- test/unit/cxx_api_changes.cpp 2011-11-11 18:32:12 +0000
+++ test/unit/cxx_api_changes.cpp 2011-11-25 17:58:26 +0000
@@ -226,7 +226,7 @@
std::vector<Item>::const_iterator lEnd = lVars.end();
Item item = aZorba->getItemFactory()->createInt(4);
-
+
bool isBound1;
bool isBound2;
@@ -234,10 +234,10 @@
for(; lIte != lEnd; ++lIte)
{
Item qname = *lIte;
- isBound1 = lQuery->isBoundExternalVariable(qname.getNamespace(), qname.getLocalName());
+ isBound1 = lQuery->getDynamicContext()->isBoundExternalVariable(qname.getNamespace(), qname.getLocalName());
Item value = aZorba->getItemFactory()->createString("foo");
lQuery->getDynamicContext()->setVariable(qname.getStringValue(), value);
- isBound2 = lQuery->isBoundExternalVariable(qname.getNamespace(), qname.getLocalName());
+ isBound2 = lQuery->getDynamicContext()->isBoundExternalVariable(qname.getNamespace(), qname.getLocalName());
}
if (!isBound1 && isBound2)
@@ -258,6 +258,44 @@
return true;
}
+bool
+cxx_api_changes_test6(Zorba* aZorba)
+{
+ try
+ {
+
+ std::string lIn = "1+1";
+
+ XQuery_t lQuery = aZorba->compileQuery(lIn);
+
+ Zorba* lZorba = Zorba::getInstance(0);
+
+ bool isBound1;
+ bool isBound2;
+
+ isBound1 = lQuery->getDynamicContext()->isBoundContextItem();
+
+ Item lContextItem = aZorba->getItemFactory()->createString("foo");
+ lQuery->getDynamicContext()->setContextItem(lContextItem);
+ isBound2 = lQuery->getDynamicContext()->isBoundContextItem();
+
+ if (!isBound1 && isBound2)
+ return true;
+
+ }
+ catch (XQueryException& qe)
+ {
+ std::cerr << qe << std::endl;
+ return false;
+ }
+ catch (ZorbaException& e)
+ {
+ std::cerr << e << std::endl;
+ return false;
+ }
+
+ return true;
+}
int
cxx_api_changes (int argc, char* argv[])
@@ -295,6 +333,12 @@
return 5;
}
+ std::cout << "executing cxx_api_changes_test6" << std::endl;
+ if (!cxx_api_changes_test6(lZorba))
+ {
+ return 6;
+ }
+
lZorba->shutdown();
zorba::StoreManager::shutdownStore(lStore);
return 0;
Follow ups
-
[Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: noreply, 2011-11-30
-
[Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Zorba Build Bot, 2011-11-30
-
[Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Zorba Build Bot, 2011-11-30
-
[Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Matthias Brantner, 2011-11-30
-
[Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Zorba Build Bot, 2011-11-30
-
Re: [Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Zorba Build Bot, 2011-11-30
-
[Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Zorba Build Bot, 2011-11-30
-
[Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Matthias Brantner, 2011-11-30
-
[Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Zorba Build Bot, 2011-11-29
-
Re: [Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Zorba Build Bot, 2011-11-29
-
[Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Zorba Build Bot, 2011-11-29
-
[Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Matthias Brantner, 2011-11-29
-
Re: [Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Matthias Brantner, 2011-11-29
-
Re: [Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Juan Zacarias, 2011-11-29
-
Re: [Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Matthias Brantner, 2011-11-28
-
Re: [Merge] lp:~zorba-coders/zorba/api_changes into lp:zorba
From: Markos Zaharioudakis, 2011-11-26