zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #01738
[Merge] lp:~ceejatec/zorba/feature-thesaurus-uriresolver into lp:zorba
Chris Hillery has proposed merging lp:~ceejatec/zorba/feature-thesaurus-uriresolver into lp:zorba.
Requested reviews:
Zorba Coders (zorba-coders)
For more details, see:
https://code.launchpad.net/~ceejatec/zorba/feature-thesaurus-uriresolver/+merge/81664
--
https://code.launchpad.net/~ceejatec/zorba/feature-thesaurus-uriresolver/+merge/81664
Your team Zorba Coders is requested to review the proposed merge of lp:~ceejatec/zorba/feature-thesaurus-uriresolver into lp:zorba.
=== modified file 'bin/zorbacmd.cpp'
--- bin/zorbacmd.cpp 2011-10-21 08:07:43 +0000
+++ bin/zorbacmd.cpp 2011-11-09 03:20:30 +0000
@@ -70,7 +70,7 @@
#ifndef ZORBA_NO_FULL_TEXT
OneToOneURIMapper theStopWordsMapper(EntityData::STOP_WORDS);
-OneToOneURIMapper theThesaurusMapper(EntityData::THESAURUS, URIMapper::COMPONENT);
+OneToOneURIMapper theThesaurusMapper(EntityData::THESAURUS);
#endif
bool
=== modified file 'include/zorba/static_context.h'
--- include/zorba/static_context.h 2011-10-21 08:07:43 +0000
+++ include/zorba/static_context.h 2011-11-09 03:20:30 +0000
@@ -384,14 +384,6 @@
virtual TypeIdentifier_t
getCollectionType(const String& aCollectionUri) const = 0;
-#ifndef ZORBA_NO_FULL_TEXT
- virtual void
- addThesaurusProvider( ThesaurusProvider const* ) = 0;
-
- virtual void
- removeThesaurusProvider( ThesaurusProvider const* ) = 0;
-#endif /* ZORBA_NO_FULL_TEXT */
-
/** \brief Check if a function with the given name and arity are registered in the context.
*/
virtual bool
=== modified file 'include/zorba/thesaurus.h'
--- include/zorba/thesaurus.h 2011-09-07 20:08:18 +0000
+++ include/zorba/thesaurus.h 2011-11-09 03:20:30 +0000
@@ -24,6 +24,7 @@
#include <zorba/internal/unique_ptr.h>
#include <zorba/internal/ztd.h>
#include <zorba/locale.h>
+#include <zorba/uri_resolvers.h>
#include <zorba/zorba_string.h>
namespace zorba {
@@ -31,11 +32,24 @@
///////////////////////////////////////////////////////////////////////////////
/**
- * A %Thesaurus is an abstract base class for thesaurus implementations.
- */
-class ZORBA_DLL_PUBLIC Thesaurus {
-public:
- typedef std::unique_ptr<Thesaurus,internal::ztd::destroy_delete<Thesaurus> >
+ * Contains additional data for URIMappers and URLResolvers
+ * when mapping/resolving a Thesaurus URI.
+ */
+class ZORBA_DLL_PUBLIC ThesaurusEntityData : public EntityData {
+public:
+ /**
+ * @brief Return the language for which a thesaurus is being requested.
+ */
+ virtual locale::iso639_1::type getLanguage() const = 0;
+};
+
+/**
+ * A %ThesaurusResource is-a Resource for thesaurus implementations.
+ */
+class ZORBA_DLL_PUBLIC ThesaurusResource : public Resource {
+public:
+ typedef std::unique_ptr<ThesaurusResource,
+ internal::ztd::destroy_delete<ThesaurusResource> >
ptr;
/**
@@ -65,19 +79,20 @@
*/
virtual bool next( String *synonym ) = 0;
protected:
- virtual ~iterator() {}
+ virtual ~iterator() { }
};
/**
- * Destroys this %Thesaurus.
- * This function is called by Zorba when the %Thesaurus is no longer needed.
- *
- * If your ThesaurusProvider dynamically allocates %Thesaurus objects, then
- * the implementation can simply be (and usually is) <code>delete
- * this</code>.
- *
- * If your ThesaurusProvider returns a pointer to a static %Thesaurus object,
- * then the implementation should do nothing.
+ * Destroys this %ThesaurusResource.
+ * This function is called by Zorba when the %ThesaurusResource is no longer
+ * needed.
+ *
+ * If your URLResolver dynamically allocates %ThesaurusResource
+ * objects, then the implementation can simply be (and usually is)
+ * <code>delete this</code>.
+ *
+ * If your URLResolver returns a pointer to a static %ThesaurusResource
+ * object, then the implementation should do nothing.
*/
virtual void destroy() const = 0;
@@ -99,26 +114,7 @@
range_type at_least, range_type at_most ) const = 0;
protected:
- virtual ~Thesaurus();
-};
-
-/**
- * A %ThesaurusProvider, given an language, provies a thesaurus for it.
- */
-class ZORBA_DLL_PUBLIC ThesaurusProvider {
-public:
- virtual ~ThesaurusProvider();
-
- /**
- * Gets a Thesaurus for the given language.
- *
- * @param uri The URI provided in the query for the thesaurus.
- * @param lang The language to get a Thesaurus for.
- * @return The relevant Thesaurus or \c NULL if no thesaurus for the given
- * language is available.
- */
- virtual Thesaurus::ptr
- getThesaurus( String const &uri, locale::iso639_1::type lang ) const = 0;
+ virtual ~ThesaurusResource();
};
///////////////////////////////////////////////////////////////////////////////
=== modified file 'include/zorba/uri_resolvers.h'
--- include/zorba/uri_resolvers.h 2011-08-17 15:48:35 +0000
+++ include/zorba/uri_resolvers.h 2011-11-09 03:20:30 +0000
@@ -25,6 +25,9 @@
#include <zorba/item.h>
#include <zorba/zorba_string.h>
#include <zorba/streams.h>
+#include <zorba/locale.h>
+#include <zorba/internal/unique_ptr.h>
+#include <zorba/internal/ztd.h>
/**
* @file uri_resolvers.h
@@ -47,7 +50,19 @@
class ZORBA_DLL_PUBLIC Resource
{
public:
+ typedef std::unique_ptr<Resource,internal::ztd::destroy_delete<Resource> > ptr;
+
virtual ~Resource() = 0;
+
+ /**
+ * @brief Destroy/clean up this Resource.
+ *
+ * Zorba will call this method when it no longer needs the Resource. It
+ * is the responsibility of subclasses to clean up appropriate when
+ * this method is called, including calling "delete this" if the Resource
+ * was allocated with "new".
+ */
+ virtual void destroy() const = 0;
};
/**
@@ -90,9 +105,8 @@
* and URLResolvers when mapping/resolving a URI.
*
* This base class specifies the kind of entity for which this URI is being
- * resolved - for instance, a schema URI or a module URI. In the future,
- * there may be kind-specific subclasses containing additional information;
- * as yet however there are none.
+ * resolved - for instance, a schema URI or a module URI. Subclasses of
+ * this class will provide additional data for specific kinds of entities.
*/
class ZORBA_DLL_PUBLIC EntityData
{
@@ -254,6 +268,7 @@
* Constructor. Specify the Entity Kind you wish to map. Optionally,
* specify whether this should be a CANDIDATE or COMPONENT mapper;
* default is CANDIDATE.
+ * QQQ COMPONENT is no longer used; delete?
*/
OneToOneURIMapper(EntityData::Kind aEntityKind,
URIMapper::Kind aMapperKind = URIMapper::CANDIDATE);
=== modified file 'src/api/collectionimpl.cpp'
--- src/api/collectionimpl.cpp 2011-11-01 13:47:10 +0000
+++ src/api/collectionimpl.cpp 2011-11-09 03:20:30 +0000
@@ -30,6 +30,7 @@
#include "api/zorbaimpl.h"
#include "api/unmarshaller.h"
+#include "diagnostics/assert.h"
#include "diagnostics/xquery_diagnostics.h"
#include "diagnostics/zorba_exception.h"
@@ -45,6 +46,7 @@
#include "context/static_context.h"
+#include "types/typeimpl.h"
#include "types/typeops.h"
#include "compiler/xqddf/collection_decl.h"
=== modified file 'src/api/staticcontextimpl.cpp'
--- src/api/staticcontextimpl.cpp 2011-10-21 10:25:18 +0000
+++ src/api/staticcontextimpl.cpp 2011-11-09 03:20:30 +0000
@@ -749,34 +749,6 @@
return TypeOps::get_type_identifier(theCtx->get_typemanager(), *xqType);
}
-
-#ifndef ZORBA_NO_FULL_TEXT
-/*******************************************************************************
-
-********************************************************************************/
-
-void StaticContextImpl::addThesaurusProvider( ThesaurusProvider const *p ) {
- if ( !theThesaurusProviders[ p ] ) {
- internal::ThesaurusProviderWrapper *const w =
- new internal::ThesaurusProviderWrapper( p );
- theThesaurusProviders[ p ] = w;
- theCtx->add_thesaurus_provider( w );
- }
-}
-
-void StaticContextImpl::removeThesaurusProvider( ThesaurusProvider const *p ) {
- thesaurus_providers_t::iterator const i = theThesaurusProviders.find( p );
- if ( i != theThesaurusProviders.end() ) {
- internal::ThesaurusProviderWrapper const *const w = i->second;
- theThesaurusProviders.erase( i );
- theCtx->remove_thesaurus_provider( w );
- delete w;
- }
-}
-
-#endif /* ZORBA_NO_FULL_TEXT */
-
-
/*******************************************************************************
********************************************************************************/
=== modified file 'src/api/staticcontextimpl.h'
--- src/api/staticcontextimpl.h 2011-10-19 16:19:45 +0000
+++ src/api/staticcontextimpl.h 2011-11-09 03:20:30 +0000
@@ -30,11 +30,6 @@
class DiagnosticHandler;
class StaticCollectionManagerImpl;
class static_context;
-#ifndef ZORBA_NO_FULL_TEXT
- namespace internal {
- class ThesaurusProviderWrapper;
- }
-#endif /* ZORBA_NO_FULL_TEXT */
/*******************************************************************************
@@ -62,14 +57,6 @@
DiagnosticHandler * theDiagnosticHandler;
bool theUserDiagnosticHandler;
-#ifndef ZORBA_NO_FULL_TEXT
- typedef std::map<ThesaurusProvider const*,
- internal::ThesaurusProviderWrapper const*>
- thesaurus_providers_t;
-
- thesaurus_providers_t theThesaurusProviders;
-#endif /* ZORBA_NO_FULL_TEXT */
-
// allow for lazy creation
mutable StaticCollectionManagerImpl* theCollectionMgr;
@@ -186,14 +173,6 @@
virtual TypeIdentifier_t
getCollectionType(const String& aCollectionUri) const;
-#ifndef ZORBA_NO_FULL_TEXT
- virtual void
- addThesaurusProvider( ThesaurusProvider const* );
-
- virtual void
- removeThesaurusProvider( ThesaurusProvider const* );
-#endif /* ZORBA_NO_FULL_TEXT */
-
virtual bool
containsFunction(const String& aFnNameUri, const String& aFnNameLocal, int arity) const;
=== modified file 'src/api/thesaurus.cpp'
--- src/api/thesaurus.cpp 2011-09-07 20:08:18 +0000
+++ src/api/thesaurus.cpp 2011-11-09 03:20:30 +0000
@@ -21,18 +21,14 @@
///////////////////////////////////////////////////////////////////////////////
-Thesaurus::~Thesaurus() {
+ThesaurusResource::~ThesaurusResource() {
// out-of-line since it's virtual
}
-//Thesaurus::iterator::~iterator() {
+//ThesaurusResource::iterator::~iterator() {
// // out-of-line since it's virtual
//}
-ThesaurusProvider::~ThesaurusProvider() {
- // out-of-line since it's virtual
-}
-
///////////////////////////////////////////////////////////////////////////////
} // namespace zorba
=== modified file 'src/api/uri_resolver_wrappers.cpp'
--- src/api/uri_resolver_wrappers.cpp 2011-07-22 07:23:17 +0000
+++ src/api/uri_resolver_wrappers.cpp 2011-11-09 03:20:30 +0000
@@ -18,28 +18,39 @@
#include "uri_resolver_wrappers.h"
#include "uriresolverimpl.h"
#include "unmarshaller.h"
+#include <zorba/thesaurus.h>
+#include <runtime/full_text/thesaurus.h>
+#include <context/thesaurus_wrappers.h>
namespace zorba
{
-
- class EntityDataWrapper : public EntityData
+ // "Convenience" class for passing an internal EntityData object to
+ // external mappers/resolvers. This can serve as a plain EntityData or
+ // a ThesaurusEntityData. However, when there's another EntityData subclass
+ // in future, this won't work as EntityData becomes an ambiguous base class...
+ class EntityDataWrapper : public ThesaurusEntityData
{
public:
- static EntityDataWrapper const* create(impl::EntityData::Kind aKind) {
+ static EntityDataWrapper const* create(internal::EntityData const* aData) {
// More ugly: Create a public-API EntityData with the same Entity Kind,
// but only if it's one of the publicly-supported kinds
- switch (aKind) {
- case impl::EntityData::MODULE:
+ switch (aData->getKind()) {
+ case internal::EntityData::MODULE:
return new EntityDataWrapper(EntityData::MODULE);
- case impl::EntityData::SCHEMA:
+ case internal::EntityData::SCHEMA:
return new EntityDataWrapper(EntityData::SCHEMA);
- case impl::EntityData::THESAURUS:
- return new EntityDataWrapper(EntityData::THESAURUS);
- case impl::EntityData::STOP_WORDS:
+ case internal::EntityData::THESAURUS:
+ {
+ EntityDataWrapper* retval = new EntityDataWrapper(EntityData::THESAURUS);
+ retval->theThesaurusLang =
+ dynamic_cast<const internal::ThesaurusEntityData*>(aData)->getLanguage();
+ return retval;
+ }
+ case internal::EntityData::STOP_WORDS:
return new EntityDataWrapper(EntityData::STOP_WORDS);
- case impl::EntityData::COLLECTION:
+ case internal::EntityData::COLLECTION:
return new EntityDataWrapper(EntityData::COLLECTION);
- case impl::EntityData::DOCUMENT:
+ case internal::EntityData::DOCUMENT:
return new EntityDataWrapper(EntityData::DOCUMENT);
default:
return NULL;
@@ -50,12 +61,17 @@
return theKind;
}
+ virtual zorba::locale::iso639_1::type getLanguage() const {
+ return theThesaurusLang;
+ }
+
private:
EntityDataWrapper(EntityData::Kind aKind)
: theKind(aKind)
{}
EntityData::Kind const theKind;
+ zorba::locale::iso639_1::type theThesaurusLang;
};
URIMapperWrapper::URIMapperWrapper(zorba::URIMapper& aUserMapper)
@@ -68,40 +84,40 @@
void
URIMapperWrapper::mapURI
(const zstring& aUri,
- impl::EntityData const* aEntityData,
+ internal::EntityData const* aEntityData,
static_context const& aSctx,
std::vector<zstring>& oUris)
{
std::auto_ptr<const EntityDataWrapper> lDataWrap
- (EntityDataWrapper::create(aEntityData->getKind()));
+ (EntityDataWrapper::create(aEntityData));
if (lDataWrap.get() == NULL) {
return;
}
std::vector<zorba::String> lUserUris;
// QQQ should public API have a StaticContext on it?
- theUserMapper.mapURI(zorba::String(aUri.c_str()),
- lDataWrap.get(), lUserUris);
+ theUserMapper.mapURI(zorba::String(aUri.c_str()), lDataWrap.get(),
+ lUserUris);
std::vector<zorba::String>::iterator iter;
for (iter = lUserUris.begin(); iter != lUserUris.end(); iter++) {
oUris.push_back(Unmarshaller::getInternalString(*iter));
}
}
- impl::URIMapper::Kind
+ internal::URIMapper::Kind
URIMapperWrapper::mapperKind()
{
// Still so ugly.
switch (theUserMapper.mapperKind()) {
case URIMapper::COMPONENT:
- return impl::URIMapper::COMPONENT;
+ return internal::URIMapper::COMPONENT;
case URIMapper::CANDIDATE:
- return impl::URIMapper::CANDIDATE;
+ return internal::URIMapper::CANDIDATE;
}
assert(false);
// dummy return
- return impl::URIMapper::COMPONENT;
+ return internal::URIMapper::COMPONENT;
}
@@ -112,39 +128,48 @@
URLResolverWrapper::~URLResolverWrapper()
{}
- impl::Resource*
+ internal::Resource*
URLResolverWrapper::resolveURL
(const zstring& aUrl,
- impl::EntityData const* aEntityData)
+ internal::EntityData const* aEntityData)
{
std::auto_ptr<const EntityDataWrapper> lDataWrap
- (EntityDataWrapper::create(aEntityData->getKind()));
+ (EntityDataWrapper::create(aEntityData));
if (lDataWrap.get() == NULL) {
return NULL;
}
- impl::StreamResource* lRetval = nullptr;
- // Get the user's Resource. It's OK to use an auto_ptr here for safety,
- // because the Resource will have been created by a factory method inside
- // libzorba (no cross-DLL memory allocation issue).
- std::auto_ptr<Resource> lUserPtr
+ internal::Resource* lRetval = nullptr;
+ // Get the user's Resource.
+ Resource::ptr lUserPtr
(theUserResolver.resolveURL(zorba::String(aUrl.c_str()),
lDataWrap.get()));
if (lUserPtr.get() != NULL) {
- // This will get a bit more complicated when we publicly support more than
- // one kind of Resource subclass.
+ // Sooo ugly... have to try down-casting to each subclass in turn to
+ // figure out what kind of Resource we've got.
StreamResourceImpl* lUserStream =
dynamic_cast<StreamResourceImpl*>(lUserPtr.get());
if (lUserStream != NULL) {
// Here we pass memory ownership of the std::istream to the internal
// StreamResource, by passing the StreamReleaser to it and setting the
// user's StreamResource's StreamReleaser to nullptr.
- lRetval = new impl::StreamResource(lUserStream->getStream(),
+ lRetval = new internal::StreamResource(lUserStream->getStream(),
lUserStream->getStreamReleaser());
lUserStream->setStreamReleaser(nullptr);
}
else {
- assert(false);
+ ThesaurusResource* lUserThesaurus =
+ dynamic_cast<ThesaurusResource*>(lUserPtr.get());
+ if (lUserThesaurus != NULL) {
+ // Here we pass memory ownership of the actual ThesaurusResource
+ // to the internal ThesaurusWrapper.
+ lRetval = new internal::ThesaurusWrapper
+ (ThesaurusResource::ptr(lUserThesaurus));
+ lUserPtr.release();
+ }
+ else {
+ assert(false);
+ }
}
}
return lRetval;
=== modified file 'src/api/uri_resolver_wrappers.h'
--- src/api/uri_resolver_wrappers.h 2011-07-12 20:15:01 +0000
+++ src/api/uri_resolver_wrappers.h 2011-11-09 03:20:30 +0000
@@ -37,7 +37,7 @@
namespace zorba {
-class URIMapperWrapper : public zorba::impl::URIMapper
+class URIMapperWrapper : public zorba::internal::URIMapper
{
public:
@@ -46,18 +46,18 @@
virtual ~URIMapperWrapper();
virtual void mapURI(const zstring& aUri,
- zorba::impl::EntityData const* aEntityData,
+ zorba::internal::EntityData const* aEntityData,
static_context const& aSctx,
std::vector<zstring>& oUris);
- virtual zorba::impl::URIMapper::Kind mapperKind();
+ virtual zorba::internal::URIMapper::Kind mapperKind();
private:
zorba::URIMapper& theUserMapper;
};
-class URLResolverWrapper : public zorba::impl::URLResolver
+class URLResolverWrapper : public zorba::internal::URLResolver
{
public:
@@ -65,8 +65,8 @@
virtual ~URLResolverWrapper();
- virtual zorba::impl::Resource* resolveURL(const zstring& aUrl,
- zorba::impl::EntityData const* aEntityData);
+ virtual zorba::internal::Resource* resolveURL(const zstring& aUrl,
+ zorba::internal::EntityData const* aEntityData);
private:
=== modified file 'src/api/uriresolverimpl.cpp'
--- src/api/uriresolverimpl.cpp 2011-08-17 15:48:35 +0000
+++ src/api/uriresolverimpl.cpp 2011-11-09 03:20:30 +0000
@@ -37,6 +37,11 @@
}
}
+ void StreamResourceImpl::destroy() const
+ {
+ delete this;
+ }
+
StreamResource* StreamResource::create(std::istream* aStream,
StreamReleaser aStreamReleaser)
{
=== modified file 'src/api/uriresolverimpl.h'
--- src/api/uriresolverimpl.h 2011-07-22 07:23:17 +0000
+++ src/api/uriresolverimpl.h 2011-11-09 03:20:30 +0000
@@ -37,6 +37,8 @@
virtual ~StreamResourceImpl();
+ virtual void destroy() const;
+
private:
StreamResourceImpl(std::istream* aStream, StreamReleaser aStreamReleaser);
=== modified file 'src/compiler/api/compiler_api.cpp'
--- src/compiler/api/compiler_api.cpp 2011-08-19 23:22:48 +0000
+++ src/compiler/api/compiler_api.cpp 2011-11-09 03:20:30 +0000
@@ -328,7 +328,7 @@
"stream URL" hack in StreamResource - this is the only place in the code where
we use the two-arg StreamResource constructor.
*******************************************************************************/
-class FakeLibraryModuleURLResolver : public impl::URLResolver
+class FakeLibraryModuleURLResolver : public internal::URLResolver
{
public:
FakeLibraryModuleURLResolver
@@ -341,8 +341,8 @@
virtual ~FakeLibraryModuleURLResolver()
{}
- virtual impl::Resource* resolveURL
- (zstring const& aUrl, impl::EntityData const* aEntityData)
+ virtual internal::Resource* resolveURL
+ (zstring const& aUrl, internal::EntityData const* aEntityData)
{
if (aUrl != theLibraryModuleNamespace) {
return NULL;
@@ -351,7 +351,7 @@
// Pass a nullptr StreamReleaser; memory ownership of the istream remains
// with the caller of this method.
// QQQ We can remove this third argument when we can compile modules individually
- return new impl::StreamResource(&theStream, nullptr,
+ return new internal::StreamResource(&theStream, nullptr,
theLibraryModuleFilename);
}
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2011-11-01 19:44:03 +0000
+++ src/compiler/translator/translator.cpp 2011-11-09 03:20:30 +0000
@@ -2011,16 +2011,16 @@
try
{
- std::auto_ptr<impl::Resource> lSchema;
- impl::StreamResource* lStream = NULL;
+ std::auto_ptr<internal::Resource> lSchema;
+ internal::StreamResource* lStream = NULL;
zstring lErrorMessage;
for (std::vector<zstring>::iterator lIter = lCandidates.begin();
lIter != lCandidates.end();
++lIter)
{
- lSchema = theSctx->resolve_uri(*lIter, impl::EntityData::SCHEMA,
+ lSchema = theSctx->resolve_uri(*lIter, internal::EntityData::SCHEMA,
lErrorMessage);
- lStream = dynamic_cast<impl::StreamResource*>(lSchema.get());
+ lStream = dynamic_cast<internal::StreamResource*>(lSchema.get());
if (lStream != NULL)
{
break;
@@ -2824,7 +2824,7 @@
// Note the use of versioned_uri() here, so that the namespace with any
// version fragment will be passed through to the mappers.
theSctx->get_component_uris(modVer.versioned_uri(),
- impl::EntityData::MODULE, compURIs);
+ internal::EntityData::MODULE, compURIs);
}
else
{
@@ -2898,13 +2898,13 @@
// rather than using compURI directly, because we want the version
// fragment to be passed to the mappers.
zstring lErrorMessage;
- std::auto_ptr<impl::Resource> lResource =
+ std::auto_ptr<internal::Resource> lResource =
theSctx->resolve_uri(compModVer.versioned_uri(),
- impl::EntityData::MODULE,
+ internal::EntityData::MODULE,
lErrorMessage);
- impl::StreamResource* lStreamResource =
- dynamic_cast<impl::StreamResource*> (lResource.get());
+ internal::StreamResource* lStreamResource =
+ dynamic_cast<internal::StreamResource*> (lResource.get());
if (lStreamResource != NULL)
{
=== modified file 'src/context/default_uri_mappers.cpp'
--- src/context/default_uri_mappers.cpp 2011-10-19 16:19:45 +0000
+++ src/context/default_uri_mappers.cpp 2011-11-09 03:20:30 +0000
@@ -27,7 +27,7 @@
namespace zorba {
-namespace impl {
+namespace internal {
/******
* Fileize mapper.
=== modified file 'src/context/default_uri_mappers.h'
--- src/context/default_uri_mappers.h 2011-07-12 20:15:01 +0000
+++ src/context/default_uri_mappers.h 2011-11-09 03:20:30 +0000
@@ -31,14 +31,14 @@
namespace zorba {
-namespace impl {
+namespace internal {
/**
* @brief URI Mapper which ensures URIs look like they point to files. Helpful
* for deploying modules both to filesystems and webservers; also the module
* versioning mapper depends on this.
*/
-class FileizeURIMapper : public impl::URIMapper
+class FileizeURIMapper : public internal::URIMapper
{
public:
@@ -52,7 +52,7 @@
* @brief URI Mapper which mangles non-file: URIs to a standardized location on
* the filesystem, honoring Zorba's module-path.
*/
-class AutoFSURIMapper : public impl::URIMapper
+class AutoFSURIMapper : public internal::URIMapper
{
public:
@@ -66,13 +66,13 @@
* @brief A URI mapper which returns a collection
* ressource from the store.
*/
-class ZorbaCollectionURIMapper : public impl::URIMapper
+class ZorbaCollectionURIMapper : public internal::URIMapper
{
public:
virtual ~ZorbaCollectionURIMapper();
- virtual impl::URIMapper::Kind mapperKind();
+ virtual internal::URIMapper::Kind mapperKind();
virtual void mapURI(zstring const& aUri,
EntityData const* aEntityData,
@@ -84,7 +84,7 @@
/**
* @brief Module versioning URI Mapper.
*/
-class ModuleVersioningURIMapper : public impl::URIMapper
+class ModuleVersioningURIMapper : public internal::URIMapper
{
public:
=== modified file 'src/context/default_url_resolvers.cpp'
--- src/context/default_url_resolvers.cpp 2011-10-20 19:50:15 +0000
+++ src/context/default_url_resolvers.cpp 2011-11-09 03:20:30 +0000
@@ -31,7 +31,7 @@
namespace zorba {
-namespace impl {
+namespace internal {
/******
* http: (and https: and ftp:) URL resolver.
@@ -109,7 +109,7 @@
ZorbaCollectionURLResolver::resolveURL
(zstring const& aUrl, EntityData const* aEntityData)
{
- if (aEntityData->getKind() != impl::EntityData::COLLECTION)
+ if (aEntityData->getKind() != internal::EntityData::COLLECTION)
return NULL;
store::Item_t lName;
=== modified file 'src/context/default_url_resolvers.h'
--- src/context/default_url_resolvers.h 2011-07-11 11:12:23 +0000
+++ src/context/default_url_resolvers.h 2011-11-09 03:20:30 +0000
@@ -31,12 +31,12 @@
namespace zorba {
-namespace impl {
+namespace internal {
/**
* @brief http: URL Resolver.
*/
-class HTTPURLResolver : public impl::URLResolver
+class HTTPURLResolver : public internal::URLResolver
{
public:
@@ -47,7 +47,7 @@
/**
* @brief file: URL Resolver.
*/
-class FileURLResolver : public impl::URLResolver
+class FileURLResolver : public internal::URLResolver
{
public:
@@ -57,7 +57,7 @@
/**
*/
-class ZorbaCollectionURLResolver : public impl::URLResolver
+class ZorbaCollectionURLResolver : public internal::URLResolver
{
public:
=== modified file 'src/context/root_static_context.cpp'
--- src/context/root_static_context.cpp 2011-10-21 10:25:18 +0000
+++ src/context/root_static_context.cpp 2011-11-09 03:20:30 +0000
@@ -106,13 +106,13 @@
// TODO move into globalenv? memory leaks?
- add_url_resolver(new impl::FileURLResolver());
- add_url_resolver(new impl::HTTPURLResolver());
- add_uri_mapper(new impl::FileizeURIMapper());
- add_uri_mapper(new impl::ModuleVersioningURIMapper());
- add_uri_mapper(new impl::AutoFSURIMapper());
- add_url_resolver(new impl::ZorbaCollectionURLResolver());
- add_uri_mapper(new impl::ZorbaCollectionURIMapper());
+ add_url_resolver(new internal::FileURLResolver());
+ add_url_resolver(new internal::HTTPURLResolver());
+ add_uri_mapper(new internal::FileizeURIMapper());
+ add_uri_mapper(new internal::ModuleVersioningURIMapper());
+ add_uri_mapper(new internal::AutoFSURIMapper());
+ add_url_resolver(new internal::ZorbaCollectionURLResolver());
+ add_uri_mapper(new internal::ZorbaCollectionURIMapper());
set_validation_mode(StaticContextConsts::lax_validation);
=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp 2011-11-04 11:40:20 +0000
+++ src/context/static_context.cpp 2011-11-09 03:20:30 +0000
@@ -1364,71 +1364,57 @@
/***************************************************************************//**
********************************************************************************/
-void static_context::add_uri_mapper(impl::URIMapper* aMapper)
-{
- theURIMappers.push_back(std::auto_ptr<impl::URIMapper>(aMapper));
-}
-
-
-/***************************************************************************//**
-
-********************************************************************************/
-void static_context::add_url_resolver(impl::URLResolver* aResolver)
-{
- theURLResolvers.push_back(std::auto_ptr<impl::URLResolver>(aResolver));
-}
-
-
-/***************************************************************************//**
- Helper class for resolve_uri()
-********************************************************************************/
-class SimpleEntityData : public impl::EntityData
-{
-public:
- SimpleEntityData(impl::EntityData::Kind aKind) : theKind(aKind)
- {
- }
-
- virtual impl::EntityData::Kind getKind() const
- {
- return theKind;
- }
-
-private:
- impl::EntityData::Kind const theKind;
-};
-
-
-/***************************************************************************//**
-
-********************************************************************************/
-std::auto_ptr<impl::Resource> static_context::resolve_uri(
+void static_context::add_uri_mapper(internal::URIMapper* aMapper)
+{
+ theURIMappers.push_back(std::auto_ptr<internal::URIMapper>(aMapper));
+}
+
+
+/***************************************************************************//**
+
+********************************************************************************/
+void static_context::add_url_resolver(internal::URLResolver* aResolver)
+{
+ theURLResolvers.push_back(std::auto_ptr<internal::URLResolver>(aResolver));
+}
+
+
+/***************************************************************************//**
+
+********************************************************************************/
+std::auto_ptr<internal::Resource> static_context::resolve_uri(
zstring const& aUri,
- impl::EntityData::Kind aEntityKind,
+ internal::EntityData::Kind aEntityKind,
zstring& oErrorMessage) const
{
// Create a simple EntityData that just reports the specified Kind
- SimpleEntityData const lData(aEntityKind);
+ internal::EntityData const lData(aEntityKind);
+ return this->resolve_uri(aUri, lData, oErrorMessage);
+}
+std::auto_ptr<internal::Resource> static_context::resolve_uri(
+ zstring const& aUri,
+ internal::EntityData const& aEntityData,
+ zstring& oErrorMessage) const
+{
std::vector<zstring> lUris;
- apply_uri_mappers(aUri, &lData, impl::URIMapper::CANDIDATE, lUris);
+ apply_uri_mappers(aUri, &aEntityData, internal::URIMapper::CANDIDATE, lUris);
- std::auto_ptr<impl::Resource> lRetval;
- apply_url_resolvers(lUris, &lData, lRetval, oErrorMessage);
+ std::auto_ptr<internal::Resource> lRetval;
+ apply_url_resolvers(lUris, &aEntityData, lRetval, oErrorMessage);
return lRetval;
}
-
void static_context::get_component_uris(
zstring const& aUri,
- impl::EntityData::Kind aEntityKind,
+ internal::EntityData::Kind aEntityKind,
std::vector<zstring>& oComponents) const
{
// Create a simple EntityData that just reports the specified Kind
- SimpleEntityData const lData(aEntityKind);
+ internal::EntityData const lData(aEntityKind);
- apply_uri_mappers(aUri, &lData, impl::URIMapper::COMPONENT, oComponents);
+ apply_uri_mappers(aUri, &lData, internal::URIMapper::COMPONENT, oComponents);
if (oComponents.size() == 0)
{
oComponents.push_back(aUri);
@@ -1441,8 +1427,8 @@
********************************************************************************/
void static_context::apply_uri_mappers(
zstring const& aUri,
- impl::EntityData const* aEntityData,
- impl::URIMapper::Kind aMapperKind,
+ internal::EntityData const* aEntityData,
+ internal::URIMapper::Kind aMapperKind,
std::vector<zstring>& oUris) const
{
// Initialize list with the one input URI.
@@ -1453,7 +1439,7 @@
sctx != NULL; sctx = sctx->theParent)
{
// Iterate through all available mappers on this static_context...
- for (ztd::auto_vector<impl::URIMapper>::const_iterator mapper =
+ for (ztd::auto_vector<internal::URIMapper>::const_iterator mapper =
sctx->theURIMappers.begin();
mapper != sctx->theURIMappers.end(); mapper++)
{
@@ -1485,7 +1471,7 @@
// Check the new entries for DENY_ACCESS.
for (size_t i = lPreNumResultUris; i < lPostNumResultUris; i++)
{
- if (lResultUris.at(i) == impl::URIMapper::DENY_ACCESS) {
+ if (lResultUris.at(i) == internal::URIMapper::DENY_ACCESS) {
throw XQUERY_EXCEPTION(zerr::ZXQP0029_URI_ACCESS_DENIED,
ERROR_PARAMS(aUri));
}
@@ -1506,8 +1492,8 @@
********************************************************************************/
void static_context::apply_url_resolvers(
std::vector<zstring>& aUrls,
- impl::EntityData const* aEntityData,
- std::auto_ptr<impl::Resource>& oResource,
+ internal::EntityData const* aEntityData,
+ std::auto_ptr<internal::Resource>& oResource,
zstring& oErrorMessage) const
{
oErrorMessage = "";
@@ -1528,7 +1514,7 @@
sctx != NULL; sctx = sctx->theParent)
{
// Iterate through all available resolvers on this static_context...
- for (ztd::auto_vector<impl::URLResolver>::const_iterator resolver =
+ for (ztd::auto_vector<internal::URLResolver>::const_iterator resolver =
sctx->theURLResolvers.begin();
resolver != sctx->theURLResolvers.end(); resolver++)
{
@@ -4001,32 +3987,5 @@
}
}
-
-#ifndef ZORBA_NO_FULL_TEXT
-
-internal::Thesaurus::ptr
-static_context::get_thesaurus( zstring const &uri, iso639_1::type lang ) const {
- FOR_EACH( thesaurus_providers_t, p, theThesaurusProviders ) {
- internal::Thesaurus::ptr t( (*p)->get_thesaurus( uri, lang ) );
- if ( t.get() )
- return std::move( t );
- }
- return theParent ?
- theParent->get_thesaurus( uri, lang ) :
- internal::ThesaurusProvider::get_default_provider()
- .get_thesaurus( uri, lang );
-}
-
-void static_context::remove_thesaurus_provider(
- internal::ThesaurusProvider const *p ) {
- ztd::erase_1st_if(
- theThesaurusProviders,
- std::bind2nd( std::equal_to<internal::ThesaurusProvider const*>(), p )
- );
-}
-
-#endif /* ZORBA_NO_FULL_TEXT */
-
-
} // namespace zorba
/* vim:set et sw=2 ts=2: */
=== modified file 'src/context/static_context.h'
--- src/context/static_context.h 2011-11-04 11:40:20 +0000
+++ src/context/static_context.h 2011-11-09 03:20:30 +0000
@@ -40,10 +40,6 @@
#include "zorbautils/hashmap_zstring.h"
-#ifndef ZORBA_NO_FULL_TEXT
-#include "runtime/full_text/thesaurus.h"
-#endif /* ZORBA_NO_FULL_TEXT */
-
#include "common/shared_types.h"
#include "util/stl_util.h"
#include "util/auto_vector.h"
@@ -498,14 +494,9 @@
BaseUriInfo * theBaseUriInfo;
- ztd::auto_vector<impl::URIMapper> theURIMappers;
-
- ztd::auto_vector<impl::URLResolver> theURLResolvers;
-
-#ifndef ZORBA_NO_FULL_TEXT
- typedef std::deque<internal::ThesaurusProvider const*> thesaurus_providers_t;
- thesaurus_providers_t theThesaurusProviders;
-#endif /* ZORBA_NO_FULL_TEXT */
+ ztd::auto_vector<internal::URIMapper> theURIMappers;
+
+ ztd::auto_vector<internal::URLResolver> theURLResolvers;
checked_vector<zstring> theURIPath;
@@ -668,20 +659,27 @@
* Add a URIMapper to be used by this static context when resolving
* URIs to resources.
*/
- void add_uri_mapper(impl::URIMapper* aMapper);
+ void add_uri_mapper(internal::URIMapper* aMapper);
/**
* Add a URLResolver to be used by this static context when
* resolving URIs to resources.
*/
- void add_url_resolver(impl::URLResolver* aResolver);
+ void add_url_resolver(internal::URLResolver* aResolver);
/**
* Given a URI, return a Resource for that URI.
* @param aEntityKind the expected kind of entity expected at this aUri
*/
- std::auto_ptr<impl::Resource> resolve_uri
- (zstring const& aUri, impl::EntityData::Kind aEntityKind, zstring& oErrorMessage) const;
+ std::auto_ptr<internal::Resource> resolve_uri
+ (zstring const& aUri, internal::EntityData::Kind aEntityKind, zstring& oErrorMessage) const;
+
+ /**
+ * Given a URI, return a Resource for that URI.
+ * @param aEntityData an EntityData object to pass to the mappers/resolvers.
+ */
+ std::auto_ptr<internal::Resource> resolve_uri
+ (zstring const& aUri, internal::EntityData const& aEntityData, zstring& oErrorMessage) const;
/**
* Given a URI, populate a vector with a list of component URIs. If
@@ -689,9 +687,10 @@
* with (only) the input URI.
*/
void get_component_uris
- (zstring const& aUri, impl::EntityData::Kind aEntityKind,
+ (zstring const& aUri, internal::EntityData::Kind aEntityKind,
std::vector<zstring>& oComponents) const;
+<<<<<<< TREE
#ifndef ZORBA_NO_FULL_TEXT
void add_thesaurus_provider( internal::ThesaurusProvider const *p ) {
theThesaurusProviders.push_front( p );
@@ -714,6 +713,14 @@
void get_lib_path(std::vector<zstring>& oLibPath) const;
void get_full_lib_path(std::vector<zstring>& oLibPath) const;
+=======
+ void set_module_paths(const std::vector<zstring>& aModulePaths);
+
+ void get_module_paths(std::vector<zstring>& aModulePaths) const;
+
+ void get_full_module_paths(std::vector<zstring>& aFullModulePaths) const;
+
+>>>>>>> MERGE-SOURCE
//
// Validating Items
@@ -1032,13 +1039,13 @@
private:
void apply_uri_mappers(zstring const& aUri,
- impl::EntityData const* aEntityData,
- impl::URIMapper::Kind aMapperKind,
+ internal::EntityData const* aEntityData,
+ internal::URIMapper::Kind aMapperKind,
std::vector<zstring>& oUris) const;
void apply_url_resolvers(std::vector<zstring>& aUrls,
- impl::EntityData const* aEntityData,
- std::auto_ptr<impl::Resource>& oResource,
+ internal::EntityData const* aEntityData,
+ std::auto_ptr<internal::Resource>& oResource,
zstring& oErrorMessage) const;
public:
=== modified file 'src/context/thesaurus_wrappers.cpp'
--- src/context/thesaurus_wrappers.cpp 2011-08-31 13:17:59 +0000
+++ src/context/thesaurus_wrappers.cpp 2011-11-09 03:20:30 +0000
@@ -57,7 +57,7 @@
return false;
}
-ThesaurusWrapper::ThesaurusWrapper( zorba::Thesaurus::ptr p ) :
+ThesaurusWrapper::ThesaurusWrapper( zorba::ThesaurusResource::ptr p ) :
api_thesaurus_( std::move( p ) )
{
ZORBA_ASSERT( api_thesaurus_.get() );
@@ -87,27 +87,6 @@
///////////////////////////////////////////////////////////////////////////////
-ThesaurusProviderWrapper::
-ThesaurusProviderWrapper( zorba::ThesaurusProvider const *p ) :
- api_thesaurus_provider_( p )
-{
- ZORBA_ASSERT( api_thesaurus_provider_ );
-}
-
-Thesaurus::ptr ThesaurusProviderWrapper::
-get_thesaurus( zstring const &uri, iso639_1::type lang ) const {
- String const api_uri( Unmarshaller::newString( uri ) );
- zorba::Thesaurus::ptr t(
- api_thesaurus_provider_->getThesaurus( api_uri, lang )
- );
- Thesaurus::ptr result(
- t.get() ? new ThesaurusWrapper( std::move( t ) ) : nullptr
- );
- return std::move( result );
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
} // namespace internal
} // namespace zorba
=== modified file 'src/context/thesaurus_wrappers.h'
--- src/context/thesaurus_wrappers.h 2011-08-31 13:17:59 +0000
+++ src/context/thesaurus_wrappers.h 2011-11-09 03:20:30 +0000
@@ -31,7 +31,7 @@
class ThesaurusWrapper : public Thesaurus {
public:
- ThesaurusWrapper( zorba::Thesaurus::ptr );
+ ThesaurusWrapper( zorba::ThesaurusResource::ptr );
~ThesaurusWrapper();
// inherited
@@ -39,7 +39,7 @@
iterator::ptr lookup( zstring const&, zstring const&, ft_int, ft_int ) const;
private:
- typedef zorba::Thesaurus::iterator::ptr api_iterator_ptr;
+ typedef zorba::ThesaurusResource::iterator::ptr api_iterator_ptr;
struct iterator_wrapper : Thesaurus::iterator {
void destroy() const;
@@ -51,17 +51,7 @@
api_iterator_ptr api_ptr_;
};
- zorba::Thesaurus::ptr api_thesaurus_;
-};
-
-class ThesaurusProviderWrapper : public ThesaurusProvider {
-public:
- ThesaurusProviderWrapper( zorba::ThesaurusProvider const *p );
-
- Thesaurus::ptr get_thesaurus( zstring const &uri,
- locale::iso639_1::type lang ) const;
-private:
- zorba::ThesaurusProvider const *const api_thesaurus_provider_;
+ zorba::ThesaurusResource::ptr api_thesaurus_;
};
///////////////////////////////////////////////////////////////////////////////
=== modified file 'src/context/uri_resolver.cpp'
--- src/context/uri_resolver.cpp 2011-08-20 01:30:48 +0000
+++ src/context/uri_resolver.cpp 2011-11-09 03:20:30 +0000
@@ -26,13 +26,13 @@
// We avoid the "static initialization order fiasco" by initializing both of
// these constants here in the same file. This also makes it easy to ensure
// both strings have the same value.
-const zorba::zstring zorba::impl::URIMapper::DENY_ACCESS("[~~Deny Access~~]");
-const zorba::String zorba::URIMapper::DENY_ACCESS(zorba::impl::URIMapper::DENY_ACCESS.c_str());
+const zorba::zstring zorba::internal::URIMapper::DENY_ACCESS("[~~Deny Access~~]");
+const zorba::String zorba::URIMapper::DENY_ACCESS(zorba::internal::URIMapper::DENY_ACCESS.c_str());
namespace zorba {
-namespace impl {
+namespace internal {
/*************
* Implementation of the Resource class hierarchy.
@@ -100,6 +100,33 @@
return theCollection;
}
+/*************
+ * Implementation of EntityData hierarchy.
+ *************/
+ EntityData::EntityData(EntityData::Kind aKind)
+ : theKind(aKind)
+ {
+ }
+
+ EntityData::Kind EntityData::getKind() const
+ {
+ return theKind;
+ }
+
+ EntityData::~EntityData()
+ {
+ }
+
+ ThesaurusEntityData::ThesaurusEntityData(locale::iso639_1::type aLang)
+ : EntityData(EntityData::THESAURUS),
+ theLang(aLang)
+ {
+ }
+
+ locale::iso639_1::type ThesaurusEntityData::getLanguage() const
+ {
+ return theLang;
+ }
/*************
* URIMapper is an abstract class, but we have to define its vtbl and
@@ -117,15 +144,6 @@
URLResolver::~URLResolver()
{}
- /*************
- * EntityData is an abstract class, but we have to define its vtbl
- * and base destructor somewhere.
- *************/
-
- EntityData::~EntityData()
- {}
-
-
} /* namespace zorba::impl */
} /* namespace zorba */
=== modified file 'src/context/uri_resolver.h'
--- src/context/uri_resolver.h 2011-08-20 01:30:48 +0000
+++ src/context/uri_resolver.h 2011-11-09 03:20:30 +0000
@@ -34,13 +34,14 @@
#include <util/auto_vector.h>
#include <store/api/shared_types.h>
#include <zorba/streams.h>
+#include <zorba/locale.h>
namespace zorba {
// Forward declaration
class static_context;
-namespace impl {
+namespace internal {
/**
* @brief The class representing the result of URL resolution.
@@ -156,9 +157,8 @@
* and URLResolvers when mapping/resolving a URI.
*
* This base class specifies the kind of entity for which this URI is being
- * resolved - for instance, a schema URI or a module URI. In the future,
- * there may be kind-specific subclasses containing additional information;
- * as yet however there are none.
+ * resolved - for instance, a schema URI or a module URI. Subclasses of
+ * this class will provide additional data for specific kinds of entities.
*/
class EntityData
{
@@ -178,12 +178,34 @@
SOME_CONTENT
};
+ EntityData(Kind aKind);
+
/**
* @brief Return the Kind of Entity for which this URI is being resolved.
*/
- virtual Kind getKind() const = 0;
-
- virtual ~EntityData() = 0;
+ virtual Kind getKind() const;
+
+ virtual ~EntityData();
+
+private:
+ Kind const theKind;
+};
+
+/**
+ * @brief The class containing additional data for URIMappers and URLResolvers
+ * when mapping/resolving a Thesaurus URI.
+ */
+class ThesaurusEntityData : public EntityData
+{
+public:
+ ThesaurusEntityData(locale::iso639_1::type aLang);
+ /**
+ * @brief Return the language for which a thesaurus is being requested.
+ */
+ virtual locale::iso639_1::type getLanguage() const;
+
+private:
+ locale::iso639_1::type const theLang;
};
/**
=== modified file 'src/functions/external_function.h'
--- src/functions/external_function.h 2011-06-14 17:26:33 +0000
+++ src/functions/external_function.h 2011-11-09 03:20:30 +0000
@@ -57,7 +57,7 @@
const zstring& ns,
const signature& sig,
short scriptingType,
- ExternalFunction* impl);
+ ExternalFunction* internal);
~external_function() { }
=== modified file 'src/runtime/collections/collections_impl.cpp'
--- src/runtime/collections/collections_impl.cpp 2011-11-01 13:47:10 +0000
+++ src/runtime/collections/collections_impl.cpp 2011-11-09 03:20:30 +0000
@@ -114,8 +114,8 @@
{
store::Item_t lURI, resolvedURIItem;
store::Collection_t coll;
- std::auto_ptr<impl::Resource> lResource;
- impl::CollectionResource* lCollResource;
+ std::auto_ptr<internal::Resource> lResource;
+ internal::CollectionResource* lCollResource;
zstring resolvedURIString;
zstring lErrorMessage;
@@ -152,12 +152,17 @@
resolvedURIString = theSctx->resolve_relative_uri(resolvedURIItem->getStringValue());
}
+<<<<<<< TREE
lResource = theSctx->resolve_uri(resolvedURIString,
impl::EntityData::COLLECTION,
lErrorMessage);
lCollResource = dynamic_cast<impl::CollectionResource*>(lResource.get());
+=======
+ lResource = theSctx->resolve_uri( resolvedURIString, internal::EntityData::COLLECTION, lErrorMessage );
+ lCollResource = dynamic_cast<internal::CollectionResource*>(lResource.get());
+>>>>>>> MERGE-SOURCE
if ( lCollResource == 0 || !(coll = lCollResource->getCollection()) )
{
throw XQUERY_EXCEPTION(
=== modified file 'src/runtime/fetch/fetch_impl.cpp'
--- src/runtime/fetch/fetch_impl.cpp 2011-08-05 09:31:11 +0000
+++ src/runtime/fetch/fetch_impl.cpp 2011-11-09 03:20:30 +0000
@@ -43,11 +43,11 @@
{
store::Item_t lUri;
store::Item_t lEntityKind;
- impl::EntityData::Kind lKind;
+ internal::EntityData::Kind lKind;
zstring lKindStr;
zstring lErrorMessage;
- std::auto_ptr<impl::Resource> lRes;
- impl::StreamResource* lStreamRes;
+ std::auto_ptr<internal::Resource> lRes;
+ internal::StreamResource* lStreamRes;
PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
@@ -58,19 +58,19 @@
// Figure out the EntityKind (any better way to do this?)
lKindStr = lEntityKind->getStringValue();
if ( ! lKindStr.compare("SOME_CONTENT")) {
- lKind = impl::EntityData::SOME_CONTENT;
+ lKind = internal::EntityData::SOME_CONTENT;
}
else if ( ! lKindStr.compare("SCHEMA")) {
- lKind = impl::EntityData::SCHEMA;
+ lKind = internal::EntityData::SCHEMA;
}
else if ( ! lKindStr.compare("MODULE")) {
- lKind = impl::EntityData::MODULE;
+ lKind = internal::EntityData::MODULE;
}
else if ( ! lKindStr.compare("THESAURUS")) {
- lKind = impl::EntityData::THESAURUS;
+ lKind = internal::EntityData::THESAURUS;
}
else if ( ! lKindStr.compare("STOP_WORDS")) {
- lKind = impl::EntityData::STOP_WORDS;
+ lKind = internal::EntityData::STOP_WORDS;
}
else {
throw XQUERY_EXCEPTION(
@@ -95,7 +95,7 @@
);
}
- lStreamRes = dynamic_cast<impl::StreamResource*>(lRes.get());
+ lStreamRes = dynamic_cast<internal::StreamResource*>(lRes.get());
if ( !lStreamRes ) {
throw XQUERY_EXCEPTION(
zerr::ZXQP0025_ITEM_CREATION_FAILED,
=== modified file 'src/runtime/full_text/apply.cpp'
--- src/runtime/full_text/apply.cpp 2011-08-31 13:17:59 +0000
+++ src/runtime/full_text/apply.cpp 2011-11-09 03:20:30 +0000
@@ -20,6 +20,7 @@
#include <vector>
#include <zorba/tokenizer.h>
+#include <context/uri_resolver.h>
#include "compiler/expression/ftnode.h"
#include "diagnostics/dict.h"
@@ -1207,14 +1208,17 @@
at_least = 0, at_most = numeric_limits<ft_int>::max();
zstring const &uri = tid.get_uri();
- vector<zstring> comp_uris;
- static_ctx_.get_component_uris( uri, impl::EntityData::THESAURUS, comp_uris );
- if ( comp_uris.size() != 1 )
- throw XQUERY_EXCEPTION( err::FTST0018, ERROR_PARAMS( uri ) );
- internal::Thesaurus::ptr thesaurus(
- static_ctx_.get_thesaurus( comp_uris.front(), qt0.lang() )
- );
+ // CEEJ Need to think about error-handling here: message from
+ // resolve_uri() as well as what happens if the dynamic_cast<>
+ // below returns nullptr.
+ zstring errorMsg;
+ auto_ptr<internal::Resource> lResource =
+ static_ctx_.resolve_uri(uri,
+ internal::ThesaurusEntityData(qt0.lang()),
+ errorMsg);
+ internal::Thesaurus::ptr thesaurus
+ (dynamic_cast<internal::Thesaurus*>(lResource.release()));
internal::Thesaurus::iterator::ptr tresult(
thesaurus->lookup( query_phrase, tid.get_relationship(), at_least, at_most )
=== modified file 'src/runtime/full_text/ft_stop_words_set.cpp'
--- src/runtime/full_text/ft_stop_words_set.cpp 2011-07-22 07:23:17 +0000
+++ src/runtime/full_text/ft_stop_words_set.cpp 2011-11-09 03:20:30 +0000
@@ -127,10 +127,10 @@
}
zstring error_msg;
- std::auto_ptr<impl::Resource> rsrc =
- sctx.resolve_uri(uri, impl::EntityData::STOP_WORDS, error_msg);
- impl::StreamResource* stream_rsrc =
- dynamic_cast<impl::StreamResource*>(rsrc.get());
+ std::auto_ptr<internal::Resource> rsrc =
+ sctx.resolve_uri(uri, internal::EntityData::STOP_WORDS, error_msg);
+ internal::StreamResource* stream_rsrc =
+ dynamic_cast<internal::StreamResource*>(rsrc.get());
if ( !stream_rsrc ) {
// Technically this should be thrown during static analysis.
throw ZORBA_EXCEPTION(err::FTST0008, ERROR_PARAMS(uri));
=== modified file 'src/runtime/full_text/thesaurus.cpp'
--- src/runtime/full_text/thesaurus.cpp 2011-08-31 13:17:59 +0000
+++ src/runtime/full_text/thesaurus.cpp 2011-11-09 03:20:30 +0000
@@ -108,50 +108,50 @@
///////////////////////////////////////////////////////////////////////////////
-ThesaurusProvider::~ThesaurusProvider() {
- // Out-of-line since it's virtual.
-}
-
-ThesaurusProvider const& ThesaurusProvider::get_default_provider() {
- static ThesaurusProvider default_provider;
- return default_provider;
-}
-
-Thesaurus::ptr
-ThesaurusProvider::get_thesaurus( zstring const &in_uri,
- iso639_1::type lang ) const {
- thesaurus_impl::type th_impl;
- zstring uri;
- parse_mapping( in_uri, &th_impl, &uri );
-
- zstring th_path;
- switch ( uri::get_scheme( uri ) ) {
- case uri::file:
- case uri::none:
- th_path = fs::get_normalized_path( uri );
- break;
- default:
- throw XQUERY_EXCEPTION(
- zerr::ZXQP0004_NOT_IMPLEMENTED,
- ERROR_PARAMS( ZED( NonFileThesaurusURI ) )
- );
- }
-
- Thesaurus *result;
- switch ( th_impl ) {
-# ifdef ZORBA_WITH_FILE_ACCESS
- case thesaurus_impl::wordnet:
- result = new wordnet::thesaurus( th_path, lang );
- break;
-# endif /* ZORBA_WITH_FILE_ACCESS */
- case thesaurus_impl::xqftts:
- result = new xqftts::thesaurus( th_path, lang );
- break;
- default:
- throw XQUERY_EXCEPTION( err::FTST0018, ERROR_PARAMS( uri ) );
- }
- return Thesaurus::ptr( result );
-}
+//ThesaurusProvider::~ThesaurusProvider() {
+// // Out-of-line since it's virtual.
+//}
+
+//ThesaurusProvider const& ThesaurusProvider::get_default_provider() {
+// static ThesaurusProvider default_provider;
+// return default_provider;
+//}
+
+//Thesaurus::ptr
+//ThesaurusProvider::get_thesaurus( zstring const &in_uri,
+// iso639_1::type lang ) const {
+// thesaurus_impl::type th_impl;
+// zstring uri;
+// parse_mapping( in_uri, &th_impl, &uri );
+
+// zstring th_path;
+// switch ( uri::get_scheme( uri ) ) {
+// case uri::file:
+// case uri::none:
+// th_path = fs::get_normalized_path( uri );
+// break;
+// default:
+// throw XQUERY_EXCEPTION(
+// zerr::ZXQP0004_NOT_IMPLEMENTED,
+// ERROR_PARAMS( ZED( NonFileThesaurusURI ) )
+// );
+// }
+
+// Thesaurus *result;
+// switch ( th_impl ) {
+//# ifdef ZORBA_WITH_FILE_ACCESS
+// case thesaurus_impl::wordnet:
+// result = new wordnet::thesaurus( th_path, lang );
+// break;
+//# endif /* ZORBA_WITH_FILE_ACCESS */
+// case thesaurus_impl::xqftts:
+// result = new xqftts::thesaurus( th_path, lang );
+// break;
+// default:
+// throw XQUERY_EXCEPTION( err::FTST0018, ERROR_PARAMS( uri ) );
+// }
+// return Thesaurus::ptr( result );
+//}
///////////////////////////////////////////////////////////////////////////////
=== modified file 'src/runtime/full_text/thesaurus.h'
--- src/runtime/full_text/thesaurus.h 2011-08-31 13:17:59 +0000
+++ src/runtime/full_text/thesaurus.h 2011-11-09 03:20:30 +0000
@@ -20,6 +20,7 @@
#include <zorba/locale.h>
#include <zorba/internal/unique_ptr.h>
+#include "context/uri_resolver.h"
#include "util/stl_util.h"
#include "zorbatypes/zstring.h"
@@ -33,7 +34,7 @@
/**
* A %Thesaurus is the abstract base class for thesaurus implementations.
*/
-class Thesaurus {
+class Thesaurus : public internal::Resource {
public:
typedef std::unique_ptr<Thesaurus,ztd::destroy_delete<Thesaurus> > ptr;
@@ -94,32 +95,6 @@
Thesaurus& operator=( Thesaurus const& );
};
-/**
- * A %ThesaurusProvider provides a Thesaurus for a particular language.
- */
-class ThesaurusProvider {
-public:
- virtual ~ThesaurusProvider();
-
- /**
- * Gets the default %ThesaurusProvider.
- *
- * @return Returns said %ThesaurusProvider.
- */
- static ThesaurusProvider const& get_default_provider();
-
- /**
- * Gets and instance of a %Thesaurus for the given language.
- *
- * @param uri The URI provided in the query for the thesaurus.
- * @param lang The language of the thesaurus.
- * @return Returns said Thesaurus or \c NULL if no thesaurus is available for
- * the given language.
- */
- virtual Thesaurus::ptr get_thesaurus( zstring const &uri,
- locale::iso639_1::type lang ) const;
-};
-
///////////////////////////////////////////////////////////////////////////////
} // namespace internal
=== modified file 'src/runtime/sequences/sequences_impl.cpp'
--- src/runtime/sequences/sequences_impl.cpp 2011-10-03 09:18:49 +0000
+++ src/runtime/sequences/sequences_impl.cpp 2011-11-09 03:20:30 +0000
@@ -1819,10 +1819,10 @@
// Resolve URI to a stream
zstring lErrorMessage;
- std::auto_ptr<impl::Resource> lResource = aSctx->resolve_uri
- (lNormUri, impl::EntityData::DOCUMENT, lErrorMessage);
- impl::StreamResource* lStreamResource =
- dynamic_cast<impl::StreamResource*>(lResource.get());
+ std::auto_ptr<internal::Resource> lResource = aSctx->resolve_uri
+ (lNormUri, internal::EntityData::DOCUMENT, lErrorMessage);
+ internal::StreamResource* lStreamResource =
+ dynamic_cast<internal::StreamResource*>(lResource.get());
if (lStreamResource == NULL) {
throw XQUERY_EXCEPTION
(err::FODC0002, ERROR_PARAMS(aUri, lErrorMessage), ERROR_LOC(loc));
=== modified file 'src/runtime/xqdoc/xqdoc_impl.cpp'
--- src/runtime/xqdoc/xqdoc_impl.cpp 2011-08-04 02:14:56 +0000
+++ src/runtime/xqdoc/xqdoc_impl.cpp 2011-11-09 03:20:30 +0000
@@ -52,8 +52,8 @@
zstring strval;
std::string uriStr;
static_context* lSctx;
- std::auto_ptr<impl::Resource> lResource;
- impl::StreamResource* lStream;
+ std::auto_ptr<internal::Resource> lResource;
+ internal::StreamResource* lStream;
std::istream* lFile;
zstring lErrorMessage;
@@ -78,8 +78,8 @@
lSctx = theSctx;
lItem->getStringValue2(strval);
lURI = lSctx->resolve_relative_uri(strval);
- lResource = lSctx->resolve_uri(lURI, impl::EntityData::MODULE, lErrorMessage);
- lStream = static_cast<impl::StreamResource*>(lResource.get());
+ lResource = lSctx->resolve_uri(lURI, internal::EntityData::MODULE, lErrorMessage);
+ lStream = static_cast<internal::StreamResource*>(lResource.get());
if ( ! lStream )
{
throw XQUERY_EXCEPTION(
=== modified file 'src/system/globalenv.cpp'
--- src/system/globalenv.cpp 2011-11-01 13:47:10 +0000
+++ src/system/globalenv.cpp 2011-11-09 03:20:30 +0000
@@ -97,7 +97,11 @@
m_globalEnv->m_compilerSubSys = lSubSystem.release();
+<<<<<<< TREE
m_globalEnv->m_http_resolver = new impl::HTTPURLResolver();
+=======
+ m_globalEnv->m_http_resolver = new internal::HTTPURLResolver();
+>>>>>>> MERGE-SOURCE
}
=== modified file 'src/system/globalenv.h'
--- src/system/globalenv.h 2011-06-26 09:43:12 +0000
+++ src/system/globalenv.h 2011-11-09 03:20:30 +0000
@@ -28,7 +28,7 @@
class root_static_context;
class XQueryXConvertor;
-namespace impl {
+namespace internal {
class HTTPURLResolver;
class FileURLResolver;
class AutoFSURIMapper;
@@ -57,9 +57,9 @@
XQueryXConvertor * xqueryx_convertor;
#endif
- impl::HTTPURLResolver * m_http_resolver;
- impl::FileURLResolver * m_file_resolver;
- impl::AutoFSURIMapper * m_autofs_mapper;
+ internal::HTTPURLResolver * m_http_resolver;
+ internal::FileURLResolver * m_file_resolver;
+ internal::AutoFSURIMapper * m_autofs_mapper;
public:
@@ -92,11 +92,11 @@
store::IteratorFactory* getIteratorFactory();
- impl::HTTPURLResolver* getHTTPURLResolver() const { return m_http_resolver; }
-
- impl::FileURLResolver* getFileURLResolver() const { return m_file_resolver; }
-
- impl::AutoFSURIMapper* getAutoFSURIMapper() const { return m_autofs_mapper; }
+ internal::HTTPURLResolver* getHTTPURLResolver() const { return m_http_resolver; }
+
+ internal::FileURLResolver* getFileURLResolver() const { return m_file_resolver; }
+
+ internal::AutoFSURIMapper* getAutoFSURIMapper() const { return m_autofs_mapper; }
#ifdef ZORBA_XQUERYX
XQueryXConvertor* getXQueryXConvertor();
=== modified file 'src/types/schema/schema.cpp'
--- src/types/schema/schema.cpp 2011-10-26 16:55:08 +0000
+++ src/types/schema/schema.cpp 2011-11-09 03:20:30 +0000
@@ -205,7 +205,7 @@
isSystemId = true;
}
- std::auto_ptr<impl::Resource> lResource;
+ std::auto_ptr<internal::Resource> lResource;
zstring lStrId = StrX(lId).localForm();
zstring lResolved;
@@ -228,9 +228,9 @@
{
TRACE("lId: " << StrX(lId) << " lResolved: " << lResolved);
zstring lErrorMessage;
- lResource = theSctx->resolve_uri(lResolved, impl::EntityData::SCHEMA, lErrorMessage);
- impl::StreamResource* lStream =
- dynamic_cast<impl::StreamResource*>(lResource.get());
+ lResource = theSctx->resolve_uri(lResolved, internal::EntityData::SCHEMA, lErrorMessage);
+ internal::StreamResource* lStream =
+ dynamic_cast<internal::StreamResource*>(lResource.get());
if (lStream != NULL)
{
// Pass memory ownership of this istream to the new IstreamInputSource
@@ -265,7 +265,7 @@
StaticContextEntityResolver(
const XMLCh* const aLogicalURI,
static_context * aSctx,
- impl::StreamResource* aStreamResource)
+ internal::StreamResource* aStreamResource)
: theLogicalURI(aLogicalURI), theSctx(aSctx)
{
// Take memory ownership of the istream
@@ -391,7 +391,7 @@
*******************************************************************************/
void Schema::registerXSD(const char* xsdURL,
static_context * aSctx,
- impl::StreamResource* stream,
+ internal::StreamResource* stream,
const QueryLoc& loc)
{
std::auto_ptr<SAX2XMLReader> parser;
=== modified file 'src/types/schema/schema.h'
--- src/types/schema/schema.h 2011-06-14 17:26:33 +0000
+++ src/types/schema/schema.h 2011-11-09 03:20:30 +0000
@@ -51,7 +51,7 @@
{
// Forward reference
-namespace impl
+namespace internal
{
class StreamResource;
}
@@ -103,7 +103,7 @@
void registerXSD(
const char* xsdURL,
static_context * aSctx,
- impl::StreamResource* aStreamResource,
+ internal::StreamResource* aStreamResource,
const QueryLoc& loc);
void getSubstitutionHeadForElement(
=== modified file 'test/unit/thesaurus.cpp'
--- test/unit/thesaurus.cpp 2011-08-31 13:17:59 +0000
+++ test/unit/thesaurus.cpp 2011-11-09 03:20:30 +0000
@@ -34,7 +34,7 @@
///////////////////////////////////////////////////////////////////////////////
-class TestThesaurus : public Thesaurus {
+class TestThesaurus : public ThesaurusResource {
public:
// inherited
void destroy() const;
@@ -46,7 +46,7 @@
static thesaurus_t const& get_thesaurus();
- class iterator : public Thesaurus::iterator {
+ class iterator : public ThesaurusResource::iterator {
public:
iterator( synonyms_t const &s ) : synonyms_( s ), i_( s.begin() ) { }
void destroy() const;
@@ -74,12 +74,12 @@
destroy_called = true;
}
-Thesaurus::iterator::ptr
+ThesaurusResource::iterator::ptr
TestThesaurus::lookup( String const &phrase, String const &relationship,
range_type at_least, range_type at_most ) const {
static thesaurus_t const &thesaurus = get_thesaurus();
thesaurus_t::const_iterator const i = thesaurus.find( phrase );
- Thesaurus::iterator::ptr result;
+ ThesaurusResource::iterator::ptr result;
if ( i != thesaurus.end() )
result.reset( new iterator( *i->second ) );
return std::move( result );
@@ -100,24 +100,22 @@
///////////////////////////////////////////////////////////////////////////////
-class TestThesaurusProvider : public ThesaurusProvider {
+class TestThesaurusResolver : public URLResolver {
public:
- TestThesaurusProvider( String const &uri ) : uri_( uri ) { }
+ TestThesaurusResolver( String const &uri ) : uri_( uri ) { }
// inherited
- Thesaurus::ptr getThesaurus( String const &uri, iso639_1::type lang ) const;
+ Resource* resolveURL( String const &uri, EntityData const* );
private:
String const uri_;
};
-Thesaurus::ptr
-TestThesaurusProvider::getThesaurus( String const &uri,
- iso639_1::type lang ) const {
+Resource*
+TestThesaurusResolver::resolveURL( String const &uri, EntityData const *ed ) {
static TestThesaurus thesaurus;
- Thesaurus::ptr result;
if ( uri == uri_ )
- result.reset( &thesaurus );
- return std::move( result );
+ return &thesaurus;
+ return 0;
}
///////////////////////////////////////////////////////////////////////////////
@@ -137,8 +135,8 @@
" using thesaurus at \"http://test\" \n";
StaticContext_t sctx = zorba->createStaticContext();
- TestThesaurusProvider provider( "http://test" );
- sctx->addThesaurusProvider( &provider );
+ TestThesaurusResolver resolver( "http://test" );
+ sctx->registerURLResolver( &resolver );
XQuery_t xquery = zorba->compileQuery( query_src, sctx );
Zorba_SerializerOptions ser_options;
Follow ups