zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #24696
[Merge] lp:~zorba-coders/zorba/markos-scratch into lp:zorba
Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch into lp:zorba.
Commit message:
renamed item_sequence_chainer.h + cosmetic
Requested reviews:
Markos Zaharioudakis (markos-za)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/178048
renamed item_sequence_chainer.h + cosmetic
--
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/178048
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/api/item_seq_chainer.cpp'
--- src/api/item_seq_chainer.cpp 2013-08-01 11:24:18 +0000
+++ src/api/item_seq_chainer.cpp 2013-08-01 12:01:31 +0000
@@ -16,7 +16,7 @@
#include "stdafx.h"
#include <zorba/iterator.h>
-#include "api/item_sequence_chainer.h"
+#include "api/item_seq_chainer.h"
#include <cassert>
namespace zorba {
=== renamed file 'src/api/item_sequence_chainer.h' => 'src/api/item_seq_chainer.h'
--- src/api/item_sequence_chainer.h 2013-02-07 17:24:36 +0000
+++ src/api/item_seq_chainer.h 2013-08-01 12:01:31 +0000
@@ -29,84 +29,84 @@
namespace zorba {
- /** \brief
- *
- * See ItemSequence
+/** \brief
+ *
+ * See ItemSequence
+ */
+class ZORBA_DLL_PUBLIC ItemSequenceChainer : public ItemSequence
+{
+ public:
+ /**
*/
- class ZORBA_DLL_PUBLIC ItemSequenceChainer : public ItemSequence
- {
- public:
- /**
- */
- ItemSequenceChainer(
+ ItemSequenceChainer(
const std::vector<ItemSequence_t>& aSequences,
bool aDoDupElim = false);
- /** \brief Destructor
- */
- virtual ~ItemSequenceChainer();
-
- /** \brief get the Iterator over the items
- * @return an iterator over the items
- */
- virtual Iterator_t getIterator();
-
- protected:
- std::vector<ItemSequence_t> theSequences;
- bool theDoDupElim;
-
- protected:
- class Iterator : public zorba::Iterator
- {
- public:
- Iterator(
+ /** \brief Destructor
+ */
+ virtual ~ItemSequenceChainer();
+
+ /** \brief get the Iterator over the items
+ * @return an iterator over the items
+ */
+ virtual Iterator_t getIterator();
+
+ protected:
+ std::vector<ItemSequence_t> theSequences;
+ bool theDoDupElim;
+
+ protected:
+ class Iterator : public zorba::Iterator
+ {
+ public:
+ Iterator(
const std::vector<ItemSequence_t>& aSequences,
bool aDoDupElim);
- virtual ~Iterator();
-
- virtual void
- open();
-
- virtual bool
- next(Item& aItem);
+ virtual ~Iterator();
+
+ virtual void
+ open();
+
+ virtual bool
+ next(Item& aItem);
- virtual void
- close();
-
- virtual bool
- isOpen() const;
-
- protected:
- std::vector<ItemSequence_t> theSequences;
- std::vector<ItemSequence_t>::iterator theSeqIter;
- zorba::Iterator_t theIter;
- bool theIsOpen;
- bool theDoDupElim;
-
- struct Comparator {
- bool operator()(const Item& i1, const Item& i2) const
- {
- assert(i1.getType().getLocalName() == "QName");
- assert(i2.getType().getLocalName() == "QName");
- int lNamespaceComparison = i1.getNamespace().compare(i2.getNamespace());
- if (lNamespaceComparison < 0)
- {
- return true;
- }
- if (lNamespaceComparison > 0)
- {
- return false;
- }
- // Namespaces are equal, comparing local names.
- return (i1.getLocalName().compare(i2.getLocalName()) < 0);
- }
- };
-
- std::set<Item, Comparator> theDupElimSet;
- };
- }; /* class ItemSequenceChainer */
-
+ virtual void
+ close();
+
+ virtual bool
+ isOpen() const;
+
+ protected:
+ std::vector<ItemSequence_t> theSequences;
+ std::vector<ItemSequence_t>::iterator theSeqIter;
+ zorba::Iterator_t theIter;
+ bool theIsOpen;
+ bool theDoDupElim;
+
+ struct Comparator {
+ bool operator()(const Item& i1, const Item& i2) const
+ {
+ assert(i1.getType().getLocalName() == "QName");
+ assert(i2.getType().getLocalName() == "QName");
+ int lNamespaceComparison = i1.getNamespace().compare(i2.getNamespace());
+ if (lNamespaceComparison < 0)
+ {
+ return true;
+ }
+ if (lNamespaceComparison > 0)
+ {
+ return false;
+ }
+ // Namespaces are equal, comparing local names.
+ return (i1.getLocalName().compare(i2.getLocalName()) < 0);
+ }
+ };
+
+ std::set<Item, Comparator> theDupElimSet;
+ };
+}; /* class ItemSequenceChainer */
+
} // namespace zorba
#endif
=== modified file 'src/api/staticcollectionmanagerimpl.cpp'
--- src/api/staticcollectionmanagerimpl.cpp 2013-02-07 17:24:36 +0000
+++ src/api/staticcollectionmanagerimpl.cpp 2013-08-01 12:01:31 +0000
@@ -27,7 +27,7 @@
#include <zorba/diagnostic_list.h>
#include "api/collectionmanagerimpl.h"
-#include "api/item_sequence_chainer.h"
+#include "api/item_seq_chainer.h"
#include "api/collectionimpl.h"
#include "api/unmarshaller.h"
#include "api/zorbaimpl.h"
=== modified file 'src/runtime/store/documents_impl.cpp'
--- src/runtime/store/documents_impl.cpp 2013-02-07 17:24:36 +0000
+++ src/runtime/store/documents_impl.cpp 2013-08-01 12:01:31 +0000
@@ -16,6 +16,7 @@
#include "stdafx.h"
#include "diagnostics/assert.h"
+#include "diagnostics/util_macros.h"
#include "diagnostics/xquery_diagnostics.h"
#include "zorbatypes/URI.h"
@@ -55,24 +56,22 @@
consumeNext(lUri, theChildren[0].getp(), aPlanState);
// absolutize retrieved uri
- try {
+ try
+ {
lUri->getStringValue2(lRetrievedUriString);
lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true);
- } catch (ZorbaException const&) {
- throw XQUERY_EXCEPTION(
- err::FODC0004,
- ERROR_PARAMS( lResolvedUriString, ZED( NoResolveRelativeURI ) ),
- ERROR_LOC( loc )
- );
+ }
+ catch (ZorbaException const&)
+ {
+ RAISE_ERROR(err::FODC0004, loc,
+ ERROR_PARAMS(lResolvedUriString, ZED(NoResolveRelativeURI)));
}
// check if document already exists in the store
- if (GENV_STORE.getDocument(lResolvedUriString) != NULL) {
- throw XQUERY_EXCEPTION(
- zerr::ZAPI0020_DOCUMENT_ALREADY_EXISTS,
- ERROR_PARAMS( lResolvedUriString ),
- ERROR_LOC( loc )
- );
+ if (GENV_STORE.getDocument(lResolvedUriString) != NULL)
+ {
+ RAISE_ERROR(zerr::ZAPI0020_DOCUMENT_ALREADY_EXISTS, loc,
+ ERROR_PARAMS(lResolvedUriString));
}
// create the pul and add the primitive
@@ -89,6 +88,7 @@
STACK_END(state);
}
+
/*******************************************************************************
declare updating function
remove($uri as xs:string) as empty-sequence()
@@ -101,7 +101,7 @@
zstring lResolvedUriString;
store::Item_t lUri;
store::Item_t lResolvedUriItem;
- std::auto_ptr<store::PUL> lPul;
+ store::PUL_t lPul;
PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
@@ -109,39 +109,38 @@
consumeNext(lUri, theChildren[0].getp(), aPlanState);
// absolutize retrieved uri
- try {
+ try
+ {
lUri->getStringValue2(lRetrievedUriString);
lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true);
- } catch (ZorbaException const&) {
- throw XQUERY_EXCEPTION(
- err::FODC0004,
- ERROR_PARAMS( lResolvedUriString, ZED( NoResolveRelativeURI ) ),
- ERROR_LOC( loc )
- );
+ }
+ catch (ZorbaException const&)
+ {
+ RAISE_ERROR(err::FODC0004, loc,
+ ERROR_PARAMS(lResolvedUriString, ZED(NoResolveRelativeURI)));
}
// check if document exists in the store
- if (GENV_STORE.getDocument(lResolvedUriString) == NULL) {
- throw XQUERY_EXCEPTION(
- zerr::ZXQD0002_DOCUMENT_NOT_VALID,
- ERROR_PARAMS( lResolvedUriString, ZED( NoURIInStore ) ),
- ERROR_LOC( loc )
- );
+ if (GENV_STORE.getDocument(lResolvedUriString) == NULL)
+ {
+ RAISE_ERROR(zerr::ZXQD0002_DOCUMENT_NOT_VALID, loc,
+ ERROR_PARAMS(lResolvedUriString, ZED(NoURIInStore)));
}
// create the pul and add the primitive
GENV_ITEMFACTORY->createAnyURI(lResolvedUriItem, lResolvedUriString);
- lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList());
+ lPul = GENV_ITEMFACTORY->createPendingUpdateList();
lPul->addDeleteDocument(&loc, lResolvedUriItem);
- result = lPul.release();
+ result.transfer(lPul);
STACK_PUSH(result != NULL, state);
STACK_END(state);
}
+
/*******************************************************************************
declare function
document($uri as xs:string) as document-node()
@@ -161,30 +160,68 @@
consumeNext(lUri, theChildren[0].getp(), aPlanState);
// absolutize retrieved uri
- try {
- lUri->getStringValue2(lRetrievedUriString);
- lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true);
- } catch (ZorbaException const&) {
- throw XQUERY_EXCEPTION(
- err::FODC0004,
- ERROR_PARAMS( lResolvedUriString, ZED( NoResolveRelativeURI ) ),
- ERROR_LOC( loc )
- );
- }
-
- // check if document exists in the store
- if ((result = GENV_STORE.getDocument(lResolvedUriString)) == NULL) {
- throw XQUERY_EXCEPTION(
- zerr::ZXQD0002_DOCUMENT_NOT_VALID,
- ERROR_PARAMS( lResolvedUriString, ZED( NoURIInStore ) ),
- ERROR_LOC( loc )
- );
- }
-
- STACK_PUSH(true, state);
-
- STACK_END(state);
-}
+ try
+ {
+ lUri->getStringValue2(lRetrievedUriString);
+ lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true);
+ }
+ catch (ZorbaException const&)
+ {
+ RAISE_ERROR(err::FODC0004, loc,
+ ERROR_PARAMS(lResolvedUriString, ZED( NoResolveRelativeURI)));
+ }
+
+ // check if document exists in the store
+ if ((result = GENV_STORE.getDocument(lResolvedUriString)) == NULL)
+ {
+ RAISE_ERROR(zerr::ZXQD0002_DOCUMENT_NOT_VALID, loc,
+ ERROR_PARAMS(lResolvedUriString, ZED( NoURIInStore)));
+ }
+
+ STACK_PUSH(true, state);
+
+ STACK_END(state);
+}
+
+
+/*******************************************************************************
+ declare function
+ is-available-document($uri as xs:string) as xs:boolean
+********************************************************************************/
+bool IsAvailableDocumentIterator::nextImpl(
+ store::Item_t& result,
+ PlanState& aPlanState) const
+{
+ zstring lRetrievedUriString;
+ zstring lResolvedUriString;
+ store::Item_t lUri;
+
+ PlanIteratorState* state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
+
+ consumeNext(lUri, theChildren[0].getp(), aPlanState);
+
+ // absolutize retrieved uri
+ try
+ {
+ lUri->getStringValue2(lRetrievedUriString);
+ lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true);
+ }
+ catch (ZorbaException const&)
+ {
+ RAISE_ERROR(err::FODC0004, loc,
+ ERROR_PARAMS(lResolvedUriString, ZED(NoResolveRelativeURI)));
+ }
+
+ // check if document exists in the store
+ GENV_ITEMFACTORY->
+ createBoolean(result, GENV_STORE.getDocument(lResolvedUriString) != NULL);
+
+ STACK_PUSH(true, state);
+
+ STACK_END(state);
+}
+
/*******************************************************************************
declare function
@@ -238,43 +275,5 @@
}
-/*******************************************************************************
- declare function
- is-available-document() as xs:boolean
-********************************************************************************/
-bool IsAvailableDocumentIterator::nextImpl(
- store::Item_t& result,
- PlanState& aPlanState) const
-{
- zstring lRetrievedUriString;
- zstring lResolvedUriString;
- store::Item_t lUri;
-
- PlanIteratorState* state;
- DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
-
- consumeNext(lUri, theChildren[0].getp(), aPlanState);
-
- // absolutize retrieved uri
- try {
- lUri->getStringValue2(lRetrievedUriString);
- lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true);
- } catch (ZorbaException const&) {
- throw XQUERY_EXCEPTION(
- err::FODC0004,
- ERROR_PARAMS( lResolvedUriString, ZED( NoResolveRelativeURI ) ),
- ERROR_LOC( loc )
- );
- }
-
- // check if document exists in the store
- GENV_ITEMFACTORY->createBoolean(
- result, GENV_STORE.getDocument(lResolvedUriString) != NULL);
-
- STACK_PUSH(true, state);
-
- STACK_END(state);
-}
-
} // namespace zorba
/* vim:set et sw=2 ts=2: */
=== modified file 'src/store/api/store.h'
--- src/store/api/store.h 2013-02-07 17:24:36 +0000
+++ src/store/api/store.h 2013-08-01 12:01:31 +0000
@@ -250,6 +250,8 @@
virtual void addNode(const zstring& uri, const Item_t& node) = 0;
+ virtual void deleteDocument(const zstring& uri) = 0;
+
virtual Iterator_t getDocumentNames() const = 0;
/* ------------------------ Collection Management ---------------------------*/
Follow ups