Merge lp:~zorba-coders/zorba/feature-thesaurus-uriresolver into lp:zorba
- feature-thesaurus-uriresolver
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Paul J. Lucas |
Approved revision: | 10506 |
Merged at revision: | 10541 |
Proposed branch: | lp:~zorba-coders/zorba/feature-thesaurus-uriresolver |
Merge into: | lp:zorba |
Diff against target: |
2246 lines (+462/-523) 44 files modified
ChangeLog (+1/-1) bin/zorbacmd.cpp (+1/-1) doc/zorba/ft_thesaurus.dox (+34/-33) include/zorba/static_context.h (+0/-8) include/zorba/thesaurus.h (+24/-28) include/zorba/uri_resolvers.h (+18/-3) src/api/collectionimpl.cpp (+2/-0) src/api/staticcontextimpl.cpp (+0/-28) src/api/staticcontextimpl.h (+0/-21) src/api/thesaurus.cpp (+0/-4) src/api/uri_resolver_wrappers.cpp (+55/-31) src/api/uri_resolver_wrappers.h (+6/-6) src/api/uriresolverimpl.cpp (+5/-0) src/api/uriresolverimpl.h (+2/-0) src/compiler/api/compiler_api.cpp (+4/-4) src/compiler/translator/translator.cpp (+9/-9) src/context/default_uri_mappers.cpp (+1/-1) src/context/default_uri_mappers.h (+6/-6) src/context/default_url_resolvers.cpp (+5/-5) src/context/default_url_resolvers.h (+19/-5) src/context/root_static_context.cpp (+10/-7) src/context/static_context.cpp (+41/-82) src/context/static_context.h (+19/-32) src/context/thesaurus_wrappers.cpp (+0/-21) src/context/thesaurus_wrappers.h (+0/-10) src/context/uri_resolver.cpp (+30/-12) src/context/uri_resolver.h (+29/-7) src/functions/external_function.h (+1/-1) src/runtime/collections/collections_impl.cpp (+8/-8) src/runtime/fetch/fetch_impl.cpp (+9/-9) src/runtime/full_text/apply.cpp (+19/-12) src/runtime/full_text/ft_stop_words_set.cpp (+4/-4) src/runtime/full_text/thesaurus.cpp (+22/-27) src/runtime/full_text/thesaurus.h (+2/-27) src/runtime/sequences/sequences_impl.cpp (+4/-4) src/runtime/xqdoc/xqdoc_impl.cpp (+4/-4) src/store/naive/simple_index_general.cpp (+16/-16) src/store/naive/simple_index_general.h (+14/-14) src/system/globalenv.cpp (+1/-1) src/system/globalenv.h (+19/-9) src/types/schema/schema.cpp (+6/-6) src/types/schema/schema.h (+2/-2) test/rbkt/specification.h (+1/-1) test/unit/thesaurus.cpp (+9/-13) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/feature-thesaurus-uriresolver |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Paul J. Lucas | Approve | ||
Matthias Brantner | Approve | ||
Review via email: mp+80979@code.launchpad.net |
Commit message
Support for user-provided Thesauri using standard Zorba URI Resolver mechanism.
Description of the change
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/feature-thesaurus-uriresolver into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job feature-
is finished. The final status was:
4 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 1 Pending.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 10, Disapprove < 1. Got: 1 Pending.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 10, Disapprove < 1. Got: 1 Pending.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 10, Disapprove < 1. Got: 5 Pending.
Matthias Brantner (matthias-brantner) wrote : | # |
- QQQ doc for registerURIMapper and registerURLResolver
- I would have expected the ThesaurusURLRes
- Why isn't the WordNet Thesaurus loaded using the file module (analog to all other file accesses) instead of the ZORBA_WITH_
- Is the error FTST0018 raised at compile time or runtime. I'm asking because it's raised in src/runtime/
Matthias Brantner (matthias-brantner) : | # |
Chris Hillery (ceejatec) wrote : | # |
> - QQQ doc for registerURIMapper and registerURLResolver
That needs to be fixed, but it's not part of this change...
> - I would have expected the ThesaurusURLRes
Speaking for Paul: He felt that it was better to keep the full-text logic together (ie, its "full-text-ness" was more important than its "URI resolver-ness").
> - Why isn't the WordNet Thesaurus loaded using the file module (analog to all other file accesses) instead of the ZORBA_WITH_
Because it's loaded with mmap(), which isn't available through the file module.
> - Is the error FTST0018 raised at compile time or runtime. I'm asking because it's raised in src/runtime/
Those two will need to wait for Paul.
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/feature-thesaurus-uriresolver into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/pilot/
Provide path to Zorba svn enlistment as ctest script arg
Error in read script: /home/pilot/
Paul J. Lucas (paul-lucas) wrote : | # |
> - Is the error FTST0018 raised at compile time or runtime.
Run-time.
> Also, the error doesn't seem to include a error location.
The exception is caught farther up the call stack, the location is added, and the exception is re-thrown.
Matthias Brantner (matthias-brantner) wrote : | # |
> > - Is the error FTST0018 raised at compile time or runtime.
>
> Run-time.
The spec says: "During the dynamic evaluation phase, only dynamic errors or type errors may be raised." Hence, FTST0018 should be raise during compile time.
Matthias Brantner (matthias-brantner) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 1 Approve.
Paul J. Lucas (paul-lucas) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Preview Diff
1 | === modified file 'ChangeLog' |
2 | --- ChangeLog 2011-11-04 11:40:20 +0000 |
3 | +++ ChangeLog 2011-11-08 03:14:35 +0000 |
4 | @@ -2,7 +2,7 @@ |
5 | |
6 | version 2.x |
7 | |
8 | - * Custom Full-text thesaurus. |
9 | + * Custom Full-text thesaurus using Zorba URI resolver mechanism. |
10 | * Fixed bug #3401971 (node-by-reference on dynamic collections) |
11 | * Optimization for positioned sequence access (e.g. $x[$x[1]] where $x is a |
12 | sequence of integers) |
13 | |
14 | === modified file 'bin/zorbacmd.cpp' |
15 | --- bin/zorbacmd.cpp 2011-10-21 08:07:43 +0000 |
16 | +++ bin/zorbacmd.cpp 2011-11-08 03:14:35 +0000 |
17 | @@ -70,7 +70,7 @@ |
18 | |
19 | #ifndef ZORBA_NO_FULL_TEXT |
20 | OneToOneURIMapper theStopWordsMapper(EntityData::STOP_WORDS); |
21 | -OneToOneURIMapper theThesaurusMapper(EntityData::THESAURUS, URIMapper::COMPONENT); |
22 | +OneToOneURIMapper theThesaurusMapper(EntityData::THESAURUS); |
23 | #endif |
24 | |
25 | bool |
26 | |
27 | === modified file 'doc/zorba/ft_thesaurus.dox' |
28 | --- doc/zorba/ft_thesaurus.dox 2011-08-31 13:17:59 +0000 |
29 | +++ doc/zorba/ft_thesaurus.dox 2011-11-08 03:14:35 +0000 |
30 | @@ -438,7 +438,7 @@ |
31 | The \c Thesaurus class is: |
32 | |
33 | \code |
34 | -class Thesaurus { |
35 | +class Thesaurus : public Resource { |
36 | public: |
37 | typedef /* implementation-defined */ ptr; |
38 | typedef /* implementation-defined */ range_type; |
39 | @@ -446,12 +446,15 @@ |
40 | class iterator { |
41 | public: |
42 | typedef /* implementation-defined */ ptr; |
43 | + virtual void destroy() const = 0; |
44 | virtual bool next( String *synonym ) = 0; |
45 | protected: |
46 | virtual ~iterator(); |
47 | }; |
48 | |
49 | virtual iterator::ptr lookup( String const &phrase, String const &relationship, range_type at_least, range_type at_most ) const = 0; |
50 | + |
51 | + virtual void destroy() const = 0; // interited from Resource |
52 | protected: |
53 | virtual ~Thesaurus(); |
54 | }; |
55 | @@ -566,51 +569,49 @@ |
56 | A real thesaurus would load a large number of synonyms, |
57 | of course. |
58 | |
59 | -\subsection ft_class_thesaurus_provider The ThesaurusProvider Class |
60 | +\subsection ft_class_thesaurus_resolver A Thesaurus URL Resolver Class |
61 | |
62 | In addition to a \c Thesaurus, |
63 | -you must also implement a \c ThesaurusProvider |
64 | -that, given a language, provides a \c Thesaurus for that language: |
65 | - |
66 | -\code |
67 | -class ThesaurusProvider { |
68 | -public: |
69 | - virtual ~ThesaurusProvider(); |
70 | - virtual Thesaurus::ptr getThesaurus( String const &uri, locale::iso639_1::type lang ) const = 0; |
71 | -}; |
72 | -\endcode |
73 | - |
74 | -A simple \c ThesaurusProvider for our simple thesaurus can be implemented as: |
75 | - |
76 | -\code |
77 | -class MyThesaurusProvider : public ThesaurusProvider { |
78 | -public: |
79 | - ThesaurusProvider( String const &uri ) : uri_( uri ) { } |
80 | - Thesaurus::ptr getThesaurus( String const &uri, locale::iso639_1::type lang ) const; |
81 | +you must also implement a "thesaurus resolver" class |
82 | +that, |
83 | +given a URL and a language, |
84 | +provides a \c Thesaurus for that language. |
85 | +A simple \c ThesaurusURLResolver |
86 | +for our simple thesaurus can be implemented as: |
87 | + |
88 | +\code |
89 | +class ThesaurusURLResolver : public URLResolver { |
90 | +public: |
91 | + ThesaurusURLResolver( String const &url ) : url_( url ) { } |
92 | + Resource* resolveURL( String const &url, EntityData const* ); // inherited |
93 | private: |
94 | - String const uri_; |
95 | + String const url_; |
96 | }; |
97 | |
98 | -Thesaurus::ptr |
99 | -MyThesaurusProvider::getThesaurus( String const &uri, locale::iso639_1::type lang ) const { |
100 | +Resource* |
101 | +ThesaurusURLResolver::resolveURL( String const &url, EntityData const *data ) const { |
102 | + ThesaurusEntityData const *const t_data = dynamic_cast<ThesaurusEntityData const*>( data ); |
103 | + assert( t_data ); |
104 | static MyThesaurus thesaurus; |
105 | - Thesaurus::ptr result; |
106 | - if ( uri == uri_ ) |
107 | - switch ( lang ) { |
108 | + if ( url == url_ ) |
109 | + switch ( t_data->getLanguage() ) { |
110 | case locale::iso639_1::en: |
111 | case locale::iso639_1::unknown: |
112 | // |
113 | - // Here, we could test to ensure that the language of our thesaurus |
114 | - // matches the language sought, but in our case, we want our thesaurus |
115 | - // to be used for all languages since "foo" and "foobar" are universal. |
116 | + // Here, we could test to ensure that the language of our thesaurus matches the |
117 | + // language sought, but in our case, we want our thesaurus to be used for all |
118 | + // languages since "foo" and "foobar" are universal. |
119 | // |
120 | default: |
121 | - result.reset( &thesaurus ); |
122 | + return &thesaurus; |
123 | } |
124 | - return std::move( result ); |
125 | + return 0; |
126 | } |
127 | \endcode |
128 | |
129 | +For more on \c URLResolver, see |
130 | +\ref uriresolvers. |
131 | + |
132 | \subsection ft_thesaurus_enable Using Your Thesaurus |
133 | |
134 | To enable your thesaurus to be used, |
135 | @@ -618,8 +619,8 @@ |
136 | |
137 | \code |
138 | StaticContext_t sctx = zorba->createStaticContext(); |
139 | -MyThesaurusProvider provider( "http://www.example.com" ); |
140 | -sctx->addThesaurusProvider( &provider ); |
141 | +ThesaurusURLResolver resolver( "http://www.example.com" ); |
142 | +sctx->registerURLResolver( &resolver ); |
143 | \endcode |
144 | |
145 | You can then perform a query using your thesaurus: |
146 | |
147 | === modified file 'include/zorba/static_context.h' |
148 | --- include/zorba/static_context.h 2011-10-21 08:07:43 +0000 |
149 | +++ include/zorba/static_context.h 2011-11-08 03:14:35 +0000 |
150 | @@ -384,14 +384,6 @@ |
151 | virtual TypeIdentifier_t |
152 | getCollectionType(const String& aCollectionUri) const = 0; |
153 | |
154 | -#ifndef ZORBA_NO_FULL_TEXT |
155 | - virtual void |
156 | - addThesaurusProvider( ThesaurusProvider const* ) = 0; |
157 | - |
158 | - virtual void |
159 | - removeThesaurusProvider( ThesaurusProvider const* ) = 0; |
160 | -#endif /* ZORBA_NO_FULL_TEXT */ |
161 | - |
162 | /** \brief Check if a function with the given name and arity are registered in the context. |
163 | */ |
164 | virtual bool |
165 | |
166 | === modified file 'include/zorba/thesaurus.h' |
167 | --- include/zorba/thesaurus.h 2011-09-07 20:08:18 +0000 |
168 | +++ include/zorba/thesaurus.h 2011-11-08 03:14:35 +0000 |
169 | @@ -24,6 +24,7 @@ |
170 | #include <zorba/internal/unique_ptr.h> |
171 | #include <zorba/internal/ztd.h> |
172 | #include <zorba/locale.h> |
173 | +#include <zorba/uri_resolvers.h> |
174 | #include <zorba/zorba_string.h> |
175 | |
176 | namespace zorba { |
177 | @@ -31,9 +32,23 @@ |
178 | /////////////////////////////////////////////////////////////////////////////// |
179 | |
180 | /** |
181 | - * A %Thesaurus is an abstract base class for thesaurus implementations. |
182 | - */ |
183 | -class ZORBA_DLL_PUBLIC Thesaurus { |
184 | + * Contains additional data for URIMappers and URLResolvers |
185 | + * when mapping/resolving a Thesaurus URI. |
186 | + */ |
187 | +class ZORBA_DLL_PUBLIC ThesaurusEntityData : public EntityData { |
188 | +public: |
189 | + /** |
190 | + * Gets the language for which a thesaurus is being requested. |
191 | + * |
192 | + * @return said language. |
193 | + */ |
194 | + virtual locale::iso639_1::type getLanguage() const = 0; |
195 | +}; |
196 | + |
197 | +/** |
198 | + * A %Thesaurus is-a Resource for thesaurus implementations. |
199 | + */ |
200 | +class ZORBA_DLL_PUBLIC Thesaurus : public Resource { |
201 | public: |
202 | typedef std::unique_ptr<Thesaurus,internal::ztd::destroy_delete<Thesaurus> > |
203 | ptr; |
204 | @@ -64,20 +79,20 @@ |
205 | * @return Returns \c true only if there is a next synonym. |
206 | */ |
207 | virtual bool next( String *synonym ) = 0; |
208 | + |
209 | protected: |
210 | - virtual ~iterator() {} |
211 | + virtual ~iterator() { } |
212 | }; |
213 | |
214 | /** |
215 | * Destroys this %Thesaurus. |
216 | * This function is called by Zorba when the %Thesaurus is no longer needed. |
217 | * |
218 | - * If your ThesaurusProvider dynamically allocates %Thesaurus objects, then |
219 | - * the implementation can simply be (and usually is) <code>delete |
220 | - * this</code>. |
221 | + * If your URLResolver dynamically allocates %Thesaurus objects, then the |
222 | + * implementation can simply be (and usually is) <code>delete this</code>. |
223 | * |
224 | - * If your ThesaurusProvider returns a pointer to a static %Thesaurus object, |
225 | - * then the implementation should do nothing. |
226 | + * If your URLResolver returns a pointer to a static %Thesaurus object, then |
227 | + * the implementation should do nothing. |
228 | */ |
229 | virtual void destroy() const = 0; |
230 | |
231 | @@ -102,25 +117,6 @@ |
232 | virtual ~Thesaurus(); |
233 | }; |
234 | |
235 | -/** |
236 | - * A %ThesaurusProvider, given an language, provies a thesaurus for it. |
237 | - */ |
238 | -class ZORBA_DLL_PUBLIC ThesaurusProvider { |
239 | -public: |
240 | - virtual ~ThesaurusProvider(); |
241 | - |
242 | - /** |
243 | - * Gets a Thesaurus for the given language. |
244 | - * |
245 | - * @param uri The URI provided in the query for the thesaurus. |
246 | - * @param lang The language to get a Thesaurus for. |
247 | - * @return The relevant Thesaurus or \c NULL if no thesaurus for the given |
248 | - * language is available. |
249 | - */ |
250 | - virtual Thesaurus::ptr |
251 | - getThesaurus( String const &uri, locale::iso639_1::type lang ) const = 0; |
252 | -}; |
253 | - |
254 | /////////////////////////////////////////////////////////////////////////////// |
255 | |
256 | } // namespace zorba |
257 | |
258 | === modified file 'include/zorba/uri_resolvers.h' |
259 | --- include/zorba/uri_resolvers.h 2011-08-17 15:48:35 +0000 |
260 | +++ include/zorba/uri_resolvers.h 2011-11-08 03:14:35 +0000 |
261 | @@ -25,6 +25,9 @@ |
262 | #include <zorba/item.h> |
263 | #include <zorba/zorba_string.h> |
264 | #include <zorba/streams.h> |
265 | +#include <zorba/locale.h> |
266 | +#include <zorba/internal/unique_ptr.h> |
267 | +#include <zorba/internal/ztd.h> |
268 | |
269 | /** |
270 | * @file uri_resolvers.h |
271 | @@ -47,7 +50,19 @@ |
272 | class ZORBA_DLL_PUBLIC Resource |
273 | { |
274 | public: |
275 | + typedef std::unique_ptr<Resource,internal::ztd::destroy_delete<Resource> > ptr; |
276 | + |
277 | virtual ~Resource() = 0; |
278 | + |
279 | + /** |
280 | + * @brief Destroy/clean up this Resource. |
281 | + * |
282 | + * Zorba will call this method when it no longer needs the Resource. It |
283 | + * is the responsibility of subclasses to clean up appropriate when |
284 | + * this method is called, including calling "delete this" if the Resource |
285 | + * was allocated with "new". |
286 | + */ |
287 | + virtual void destroy() const = 0; |
288 | }; |
289 | |
290 | /** |
291 | @@ -90,9 +105,8 @@ |
292 | * and URLResolvers when mapping/resolving a URI. |
293 | * |
294 | * This base class specifies the kind of entity for which this URI is being |
295 | - * resolved - for instance, a schema URI or a module URI. In the future, |
296 | - * there may be kind-specific subclasses containing additional information; |
297 | - * as yet however there are none. |
298 | + * resolved - for instance, a schema URI or a module URI. Subclasses of |
299 | + * this class will provide additional data for specific kinds of entities. |
300 | */ |
301 | class ZORBA_DLL_PUBLIC EntityData |
302 | { |
303 | @@ -254,6 +268,7 @@ |
304 | * Constructor. Specify the Entity Kind you wish to map. Optionally, |
305 | * specify whether this should be a CANDIDATE or COMPONENT mapper; |
306 | * default is CANDIDATE. |
307 | + * QQQ COMPONENT is no longer used; delete? |
308 | */ |
309 | OneToOneURIMapper(EntityData::Kind aEntityKind, |
310 | URIMapper::Kind aMapperKind = URIMapper::CANDIDATE); |
311 | |
312 | === modified file 'src/api/collectionimpl.cpp' |
313 | --- src/api/collectionimpl.cpp 2011-11-01 13:47:10 +0000 |
314 | +++ src/api/collectionimpl.cpp 2011-11-08 03:14:35 +0000 |
315 | @@ -30,6 +30,7 @@ |
316 | #include "api/zorbaimpl.h" |
317 | #include "api/unmarshaller.h" |
318 | |
319 | +#include "diagnostics/assert.h" |
320 | #include "diagnostics/xquery_diagnostics.h" |
321 | #include "diagnostics/zorba_exception.h" |
322 | |
323 | @@ -45,6 +46,7 @@ |
324 | |
325 | #include "context/static_context.h" |
326 | |
327 | +#include "types/typeimpl.h" |
328 | #include "types/typeops.h" |
329 | |
330 | #include "compiler/xqddf/collection_decl.h" |
331 | |
332 | === modified file 'src/api/staticcontextimpl.cpp' |
333 | --- src/api/staticcontextimpl.cpp 2011-10-21 10:25:18 +0000 |
334 | +++ src/api/staticcontextimpl.cpp 2011-11-08 03:14:35 +0000 |
335 | @@ -749,34 +749,6 @@ |
336 | return TypeOps::get_type_identifier(theCtx->get_typemanager(), *xqType); |
337 | } |
338 | |
339 | - |
340 | -#ifndef ZORBA_NO_FULL_TEXT |
341 | -/******************************************************************************* |
342 | - |
343 | -********************************************************************************/ |
344 | - |
345 | -void StaticContextImpl::addThesaurusProvider( ThesaurusProvider const *p ) { |
346 | - if ( !theThesaurusProviders[ p ] ) { |
347 | - internal::ThesaurusProviderWrapper *const w = |
348 | - new internal::ThesaurusProviderWrapper( p ); |
349 | - theThesaurusProviders[ p ] = w; |
350 | - theCtx->add_thesaurus_provider( w ); |
351 | - } |
352 | -} |
353 | - |
354 | -void StaticContextImpl::removeThesaurusProvider( ThesaurusProvider const *p ) { |
355 | - thesaurus_providers_t::iterator const i = theThesaurusProviders.find( p ); |
356 | - if ( i != theThesaurusProviders.end() ) { |
357 | - internal::ThesaurusProviderWrapper const *const w = i->second; |
358 | - theThesaurusProviders.erase( i ); |
359 | - theCtx->remove_thesaurus_provider( w ); |
360 | - delete w; |
361 | - } |
362 | -} |
363 | - |
364 | -#endif /* ZORBA_NO_FULL_TEXT */ |
365 | - |
366 | - |
367 | /******************************************************************************* |
368 | |
369 | ********************************************************************************/ |
370 | |
371 | === modified file 'src/api/staticcontextimpl.h' |
372 | --- src/api/staticcontextimpl.h 2011-10-19 16:19:45 +0000 |
373 | +++ src/api/staticcontextimpl.h 2011-11-08 03:14:35 +0000 |
374 | @@ -30,11 +30,6 @@ |
375 | class DiagnosticHandler; |
376 | class StaticCollectionManagerImpl; |
377 | class static_context; |
378 | -#ifndef ZORBA_NO_FULL_TEXT |
379 | - namespace internal { |
380 | - class ThesaurusProviderWrapper; |
381 | - } |
382 | -#endif /* ZORBA_NO_FULL_TEXT */ |
383 | |
384 | /******************************************************************************* |
385 | |
386 | @@ -62,14 +57,6 @@ |
387 | DiagnosticHandler * theDiagnosticHandler; |
388 | bool theUserDiagnosticHandler; |
389 | |
390 | -#ifndef ZORBA_NO_FULL_TEXT |
391 | - typedef std::map<ThesaurusProvider const*, |
392 | - internal::ThesaurusProviderWrapper const*> |
393 | - thesaurus_providers_t; |
394 | - |
395 | - thesaurus_providers_t theThesaurusProviders; |
396 | -#endif /* ZORBA_NO_FULL_TEXT */ |
397 | - |
398 | // allow for lazy creation |
399 | mutable StaticCollectionManagerImpl* theCollectionMgr; |
400 | |
401 | @@ -186,14 +173,6 @@ |
402 | virtual TypeIdentifier_t |
403 | getCollectionType(const String& aCollectionUri) const; |
404 | |
405 | -#ifndef ZORBA_NO_FULL_TEXT |
406 | - virtual void |
407 | - addThesaurusProvider( ThesaurusProvider const* ); |
408 | - |
409 | - virtual void |
410 | - removeThesaurusProvider( ThesaurusProvider const* ); |
411 | -#endif /* ZORBA_NO_FULL_TEXT */ |
412 | - |
413 | virtual bool |
414 | containsFunction(const String& aFnNameUri, const String& aFnNameLocal, int arity) const; |
415 | |
416 | |
417 | === modified file 'src/api/thesaurus.cpp' |
418 | --- src/api/thesaurus.cpp 2011-09-07 20:08:18 +0000 |
419 | +++ src/api/thesaurus.cpp 2011-11-08 03:14:35 +0000 |
420 | @@ -29,10 +29,6 @@ |
421 | // // out-of-line since it's virtual |
422 | //} |
423 | |
424 | -ThesaurusProvider::~ThesaurusProvider() { |
425 | - // out-of-line since it's virtual |
426 | -} |
427 | - |
428 | /////////////////////////////////////////////////////////////////////////////// |
429 | |
430 | } // namespace zorba |
431 | |
432 | === modified file 'src/api/uri_resolver_wrappers.cpp' |
433 | --- src/api/uri_resolver_wrappers.cpp 2011-07-22 07:23:17 +0000 |
434 | +++ src/api/uri_resolver_wrappers.cpp 2011-11-08 03:14:35 +0000 |
435 | @@ -18,28 +18,39 @@ |
436 | #include "uri_resolver_wrappers.h" |
437 | #include "uriresolverimpl.h" |
438 | #include "unmarshaller.h" |
439 | +#include <zorba/thesaurus.h> |
440 | +#include <runtime/full_text/thesaurus.h> |
441 | +#include <context/thesaurus_wrappers.h> |
442 | |
443 | namespace zorba |
444 | { |
445 | - |
446 | - class EntityDataWrapper : public EntityData |
447 | + // "Convenience" class for passing an internal EntityData object to |
448 | + // external mappers/resolvers. This can serve as a plain EntityData or |
449 | + // a ThesaurusEntityData. However, when there's another EntityData subclass |
450 | + // in future, this won't work as EntityData becomes an ambiguous base class... |
451 | + class EntityDataWrapper : public ThesaurusEntityData |
452 | { |
453 | public: |
454 | - static EntityDataWrapper const* create(impl::EntityData::Kind aKind) { |
455 | + static EntityDataWrapper const* create(internal::EntityData const* aData) { |
456 | // More ugly: Create a public-API EntityData with the same Entity Kind, |
457 | // but only if it's one of the publicly-supported kinds |
458 | - switch (aKind) { |
459 | - case impl::EntityData::MODULE: |
460 | + switch (aData->getKind()) { |
461 | + case internal::EntityData::MODULE: |
462 | return new EntityDataWrapper(EntityData::MODULE); |
463 | - case impl::EntityData::SCHEMA: |
464 | + case internal::EntityData::SCHEMA: |
465 | return new EntityDataWrapper(EntityData::SCHEMA); |
466 | - case impl::EntityData::THESAURUS: |
467 | - return new EntityDataWrapper(EntityData::THESAURUS); |
468 | - case impl::EntityData::STOP_WORDS: |
469 | + case internal::EntityData::THESAURUS: |
470 | + { |
471 | + EntityDataWrapper* retval = new EntityDataWrapper(EntityData::THESAURUS); |
472 | + retval->theThesaurusLang = |
473 | + dynamic_cast<const internal::ThesaurusEntityData*>(aData)->getLanguage(); |
474 | + return retval; |
475 | + } |
476 | + case internal::EntityData::STOP_WORDS: |
477 | return new EntityDataWrapper(EntityData::STOP_WORDS); |
478 | - case impl::EntityData::COLLECTION: |
479 | + case internal::EntityData::COLLECTION: |
480 | return new EntityDataWrapper(EntityData::COLLECTION); |
481 | - case impl::EntityData::DOCUMENT: |
482 | + case internal::EntityData::DOCUMENT: |
483 | return new EntityDataWrapper(EntityData::DOCUMENT); |
484 | default: |
485 | return NULL; |
486 | @@ -50,12 +61,17 @@ |
487 | return theKind; |
488 | } |
489 | |
490 | + virtual zorba::locale::iso639_1::type getLanguage() const { |
491 | + return theThesaurusLang; |
492 | + } |
493 | + |
494 | private: |
495 | EntityDataWrapper(EntityData::Kind aKind) |
496 | : theKind(aKind) |
497 | {} |
498 | |
499 | EntityData::Kind const theKind; |
500 | + zorba::locale::iso639_1::type theThesaurusLang; |
501 | }; |
502 | |
503 | URIMapperWrapper::URIMapperWrapper(zorba::URIMapper& aUserMapper) |
504 | @@ -68,40 +84,40 @@ |
505 | void |
506 | URIMapperWrapper::mapURI |
507 | (const zstring& aUri, |
508 | - impl::EntityData const* aEntityData, |
509 | + internal::EntityData const* aEntityData, |
510 | static_context const& aSctx, |
511 | std::vector<zstring>& oUris) |
512 | { |
513 | std::auto_ptr<const EntityDataWrapper> lDataWrap |
514 | - (EntityDataWrapper::create(aEntityData->getKind())); |
515 | + (EntityDataWrapper::create(aEntityData)); |
516 | if (lDataWrap.get() == NULL) { |
517 | return; |
518 | } |
519 | |
520 | std::vector<zorba::String> lUserUris; |
521 | // QQQ should public API have a StaticContext on it? |
522 | - theUserMapper.mapURI(zorba::String(aUri.c_str()), |
523 | - lDataWrap.get(), lUserUris); |
524 | + theUserMapper.mapURI(zorba::String(aUri.c_str()), lDataWrap.get(), |
525 | + lUserUris); |
526 | std::vector<zorba::String>::iterator iter; |
527 | for (iter = lUserUris.begin(); iter != lUserUris.end(); iter++) { |
528 | oUris.push_back(Unmarshaller::getInternalString(*iter)); |
529 | } |
530 | } |
531 | |
532 | - impl::URIMapper::Kind |
533 | + internal::URIMapper::Kind |
534 | URIMapperWrapper::mapperKind() |
535 | { |
536 | // Still so ugly. |
537 | switch (theUserMapper.mapperKind()) { |
538 | case URIMapper::COMPONENT: |
539 | - return impl::URIMapper::COMPONENT; |
540 | + return internal::URIMapper::COMPONENT; |
541 | case URIMapper::CANDIDATE: |
542 | - return impl::URIMapper::CANDIDATE; |
543 | + return internal::URIMapper::CANDIDATE; |
544 | } |
545 | |
546 | assert(false); |
547 | // dummy return |
548 | - return impl::URIMapper::COMPONENT; |
549 | + return internal::URIMapper::COMPONENT; |
550 | } |
551 | |
552 | |
553 | @@ -112,39 +128,47 @@ |
554 | URLResolverWrapper::~URLResolverWrapper() |
555 | {} |
556 | |
557 | - impl::Resource* |
558 | + internal::Resource* |
559 | URLResolverWrapper::resolveURL |
560 | (const zstring& aUrl, |
561 | - impl::EntityData const* aEntityData) |
562 | + internal::EntityData const* aEntityData) |
563 | { |
564 | std::auto_ptr<const EntityDataWrapper> lDataWrap |
565 | - (EntityDataWrapper::create(aEntityData->getKind())); |
566 | + (EntityDataWrapper::create(aEntityData)); |
567 | if (lDataWrap.get() == NULL) { |
568 | return NULL; |
569 | } |
570 | |
571 | - impl::StreamResource* lRetval = nullptr; |
572 | - // Get the user's Resource. It's OK to use an auto_ptr here for safety, |
573 | - // because the Resource will have been created by a factory method inside |
574 | - // libzorba (no cross-DLL memory allocation issue). |
575 | - std::auto_ptr<Resource> lUserPtr |
576 | + internal::Resource* lRetval = nullptr; |
577 | + // Get the user's Resource. |
578 | + Resource::ptr lUserPtr |
579 | (theUserResolver.resolveURL(zorba::String(aUrl.c_str()), |
580 | lDataWrap.get())); |
581 | if (lUserPtr.get() != NULL) { |
582 | - // This will get a bit more complicated when we publicly support more than |
583 | - // one kind of Resource subclass. |
584 | + // Sooo ugly... have to try down-casting to each subclass in turn to |
585 | + // figure out what kind of Resource we've got. |
586 | StreamResourceImpl* lUserStream = |
587 | dynamic_cast<StreamResourceImpl*>(lUserPtr.get()); |
588 | if (lUserStream != NULL) { |
589 | // Here we pass memory ownership of the std::istream to the internal |
590 | // StreamResource, by passing the StreamReleaser to it and setting the |
591 | // user's StreamResource's StreamReleaser to nullptr. |
592 | - lRetval = new impl::StreamResource(lUserStream->getStream(), |
593 | + lRetval = new internal::StreamResource(lUserStream->getStream(), |
594 | lUserStream->getStreamReleaser()); |
595 | lUserStream->setStreamReleaser(nullptr); |
596 | } |
597 | else { |
598 | - assert(false); |
599 | + Thesaurus* lUserThesaurus = dynamic_cast<Thesaurus*>(lUserPtr.get()); |
600 | + if (lUserThesaurus != NULL) { |
601 | + // Here we pass memory ownership of the actual Thesaurus to the |
602 | + // internal ThesaurusWrapper. |
603 | + lRetval = new internal::ThesaurusWrapper |
604 | + (Thesaurus::ptr(lUserThesaurus)); |
605 | + lUserPtr.release(); |
606 | + } |
607 | + else { |
608 | + assert(false); |
609 | + } |
610 | } |
611 | } |
612 | return lRetval; |
613 | |
614 | === modified file 'src/api/uri_resolver_wrappers.h' |
615 | --- src/api/uri_resolver_wrappers.h 2011-07-12 20:15:01 +0000 |
616 | +++ src/api/uri_resolver_wrappers.h 2011-11-08 03:14:35 +0000 |
617 | @@ -37,7 +37,7 @@ |
618 | |
619 | namespace zorba { |
620 | |
621 | -class URIMapperWrapper : public zorba::impl::URIMapper |
622 | +class URIMapperWrapper : public zorba::internal::URIMapper |
623 | { |
624 | public: |
625 | |
626 | @@ -46,18 +46,18 @@ |
627 | virtual ~URIMapperWrapper(); |
628 | |
629 | virtual void mapURI(const zstring& aUri, |
630 | - zorba::impl::EntityData const* aEntityData, |
631 | + zorba::internal::EntityData const* aEntityData, |
632 | static_context const& aSctx, |
633 | std::vector<zstring>& oUris); |
634 | |
635 | - virtual zorba::impl::URIMapper::Kind mapperKind(); |
636 | + virtual zorba::internal::URIMapper::Kind mapperKind(); |
637 | |
638 | private: |
639 | |
640 | zorba::URIMapper& theUserMapper; |
641 | }; |
642 | |
643 | -class URLResolverWrapper : public zorba::impl::URLResolver |
644 | +class URLResolverWrapper : public zorba::internal::URLResolver |
645 | { |
646 | public: |
647 | |
648 | @@ -65,8 +65,8 @@ |
649 | |
650 | virtual ~URLResolverWrapper(); |
651 | |
652 | - virtual zorba::impl::Resource* resolveURL(const zstring& aUrl, |
653 | - zorba::impl::EntityData const* aEntityData); |
654 | + virtual zorba::internal::Resource* resolveURL(const zstring& aUrl, |
655 | + zorba::internal::EntityData const* aEntityData); |
656 | |
657 | private: |
658 | |
659 | |
660 | === modified file 'src/api/uriresolverimpl.cpp' |
661 | --- src/api/uriresolverimpl.cpp 2011-08-17 15:48:35 +0000 |
662 | +++ src/api/uriresolverimpl.cpp 2011-11-08 03:14:35 +0000 |
663 | @@ -37,6 +37,11 @@ |
664 | } |
665 | } |
666 | |
667 | + void StreamResourceImpl::destroy() const |
668 | + { |
669 | + delete this; |
670 | + } |
671 | + |
672 | StreamResource* StreamResource::create(std::istream* aStream, |
673 | StreamReleaser aStreamReleaser) |
674 | { |
675 | |
676 | === modified file 'src/api/uriresolverimpl.h' |
677 | --- src/api/uriresolverimpl.h 2011-07-22 07:23:17 +0000 |
678 | +++ src/api/uriresolverimpl.h 2011-11-08 03:14:35 +0000 |
679 | @@ -37,6 +37,8 @@ |
680 | |
681 | virtual ~StreamResourceImpl(); |
682 | |
683 | + virtual void destroy() const; |
684 | + |
685 | private: |
686 | |
687 | StreamResourceImpl(std::istream* aStream, StreamReleaser aStreamReleaser); |
688 | |
689 | === modified file 'src/compiler/api/compiler_api.cpp' |
690 | --- src/compiler/api/compiler_api.cpp 2011-08-19 23:22:48 +0000 |
691 | +++ src/compiler/api/compiler_api.cpp 2011-11-08 03:14:35 +0000 |
692 | @@ -328,7 +328,7 @@ |
693 | "stream URL" hack in StreamResource - this is the only place in the code where |
694 | we use the two-arg StreamResource constructor. |
695 | *******************************************************************************/ |
696 | -class FakeLibraryModuleURLResolver : public impl::URLResolver |
697 | +class FakeLibraryModuleURLResolver : public internal::URLResolver |
698 | { |
699 | public: |
700 | FakeLibraryModuleURLResolver |
701 | @@ -341,8 +341,8 @@ |
702 | virtual ~FakeLibraryModuleURLResolver() |
703 | {} |
704 | |
705 | - virtual impl::Resource* resolveURL |
706 | - (zstring const& aUrl, impl::EntityData const* aEntityData) |
707 | + virtual internal::Resource* resolveURL |
708 | + (zstring const& aUrl, internal::EntityData const* aEntityData) |
709 | { |
710 | if (aUrl != theLibraryModuleNamespace) { |
711 | return NULL; |
712 | @@ -351,7 +351,7 @@ |
713 | // Pass a nullptr StreamReleaser; memory ownership of the istream remains |
714 | // with the caller of this method. |
715 | // QQQ We can remove this third argument when we can compile modules individually |
716 | - return new impl::StreamResource(&theStream, nullptr, |
717 | + return new internal::StreamResource(&theStream, nullptr, |
718 | theLibraryModuleFilename); |
719 | } |
720 | |
721 | |
722 | === modified file 'src/compiler/translator/translator.cpp' |
723 | --- src/compiler/translator/translator.cpp 2011-11-01 19:44:03 +0000 |
724 | +++ src/compiler/translator/translator.cpp 2011-11-08 03:14:35 +0000 |
725 | @@ -2011,16 +2011,16 @@ |
726 | |
727 | try |
728 | { |
729 | - std::auto_ptr<impl::Resource> lSchema; |
730 | - impl::StreamResource* lStream = NULL; |
731 | + std::auto_ptr<internal::Resource> lSchema; |
732 | + internal::StreamResource* lStream = NULL; |
733 | zstring lErrorMessage; |
734 | for (std::vector<zstring>::iterator lIter = lCandidates.begin(); |
735 | lIter != lCandidates.end(); |
736 | ++lIter) |
737 | { |
738 | - lSchema = theSctx->resolve_uri(*lIter, impl::EntityData::SCHEMA, |
739 | + lSchema = theSctx->resolve_uri(*lIter, internal::EntityData::SCHEMA, |
740 | lErrorMessage); |
741 | - lStream = dynamic_cast<impl::StreamResource*>(lSchema.get()); |
742 | + lStream = dynamic_cast<internal::StreamResource*>(lSchema.get()); |
743 | if (lStream != NULL) |
744 | { |
745 | break; |
746 | @@ -2824,7 +2824,7 @@ |
747 | // Note the use of versioned_uri() here, so that the namespace with any |
748 | // version fragment will be passed through to the mappers. |
749 | theSctx->get_component_uris(modVer.versioned_uri(), |
750 | - impl::EntityData::MODULE, compURIs); |
751 | + internal::EntityData::MODULE, compURIs); |
752 | } |
753 | else |
754 | { |
755 | @@ -2898,13 +2898,13 @@ |
756 | // rather than using compURI directly, because we want the version |
757 | // fragment to be passed to the mappers. |
758 | zstring lErrorMessage; |
759 | - std::auto_ptr<impl::Resource> lResource = |
760 | + std::auto_ptr<internal::Resource> lResource = |
761 | theSctx->resolve_uri(compModVer.versioned_uri(), |
762 | - impl::EntityData::MODULE, |
763 | + internal::EntityData::MODULE, |
764 | lErrorMessage); |
765 | |
766 | - impl::StreamResource* lStreamResource = |
767 | - dynamic_cast<impl::StreamResource*> (lResource.get()); |
768 | + internal::StreamResource* lStreamResource = |
769 | + dynamic_cast<internal::StreamResource*> (lResource.get()); |
770 | |
771 | if (lStreamResource != NULL) |
772 | { |
773 | |
774 | === modified file 'src/context/default_uri_mappers.cpp' |
775 | --- src/context/default_uri_mappers.cpp 2011-10-19 16:19:45 +0000 |
776 | +++ src/context/default_uri_mappers.cpp 2011-11-08 03:14:35 +0000 |
777 | @@ -27,7 +27,7 @@ |
778 | |
779 | namespace zorba { |
780 | |
781 | -namespace impl { |
782 | +namespace internal { |
783 | |
784 | /****** |
785 | * Fileize mapper. |
786 | |
787 | === modified file 'src/context/default_uri_mappers.h' |
788 | --- src/context/default_uri_mappers.h 2011-07-12 20:15:01 +0000 |
789 | +++ src/context/default_uri_mappers.h 2011-11-08 03:14:35 +0000 |
790 | @@ -31,14 +31,14 @@ |
791 | |
792 | namespace zorba { |
793 | |
794 | -namespace impl { |
795 | +namespace internal { |
796 | |
797 | /** |
798 | * @brief URI Mapper which ensures URIs look like they point to files. Helpful |
799 | * for deploying modules both to filesystems and webservers; also the module |
800 | * versioning mapper depends on this. |
801 | */ |
802 | -class FileizeURIMapper : public impl::URIMapper |
803 | +class FileizeURIMapper : public internal::URIMapper |
804 | { |
805 | public: |
806 | |
807 | @@ -52,7 +52,7 @@ |
808 | * @brief URI Mapper which mangles non-file: URIs to a standardized location on |
809 | * the filesystem, honoring Zorba's module-path. |
810 | */ |
811 | -class AutoFSURIMapper : public impl::URIMapper |
812 | +class AutoFSURIMapper : public internal::URIMapper |
813 | { |
814 | public: |
815 | |
816 | @@ -66,13 +66,13 @@ |
817 | * @brief A URI mapper which returns a collection |
818 | * ressource from the store. |
819 | */ |
820 | -class ZorbaCollectionURIMapper : public impl::URIMapper |
821 | +class ZorbaCollectionURIMapper : public internal::URIMapper |
822 | { |
823 | public: |
824 | |
825 | virtual ~ZorbaCollectionURIMapper(); |
826 | |
827 | - virtual impl::URIMapper::Kind mapperKind(); |
828 | + virtual internal::URIMapper::Kind mapperKind(); |
829 | |
830 | virtual void mapURI(zstring const& aUri, |
831 | EntityData const* aEntityData, |
832 | @@ -84,7 +84,7 @@ |
833 | /** |
834 | * @brief Module versioning URI Mapper. |
835 | */ |
836 | -class ModuleVersioningURIMapper : public impl::URIMapper |
837 | +class ModuleVersioningURIMapper : public internal::URIMapper |
838 | { |
839 | public: |
840 | |
841 | |
842 | === modified file 'src/context/default_url_resolvers.cpp' |
843 | --- src/context/default_url_resolvers.cpp 2011-10-20 19:50:15 +0000 |
844 | +++ src/context/default_url_resolvers.cpp 2011-11-08 03:14:35 +0000 |
845 | @@ -31,7 +31,7 @@ |
846 | |
847 | namespace zorba { |
848 | |
849 | -namespace impl { |
850 | +namespace internal { |
851 | |
852 | /****** |
853 | * http: (and https: and ftp:) URL resolver. |
854 | @@ -41,7 +41,7 @@ |
855 | HTTPURLResolver::resolveURL |
856 | (zstring const& aUrl, EntityData const* aEntityData) |
857 | { |
858 | - if (aEntityData->getKind() == impl::EntityData::COLLECTION) |
859 | + if (aEntityData->getKind() == EntityData::COLLECTION) |
860 | return NULL; |
861 | |
862 | uri::scheme lScheme = uri::get_scheme(aUrl); |
863 | @@ -82,7 +82,7 @@ |
864 | FileURLResolver::resolveURL |
865 | (zstring const& aUrl, EntityData const* aEntityData) |
866 | { |
867 | - if (aEntityData->getKind() == impl::EntityData::COLLECTION) |
868 | + if (aEntityData->getKind() == EntityData::COLLECTION) |
869 | return NULL; |
870 | |
871 | uri::scheme lScheme = uri::get_scheme(aUrl); |
872 | @@ -109,7 +109,7 @@ |
873 | ZorbaCollectionURLResolver::resolveURL |
874 | (zstring const& aUrl, EntityData const* aEntityData) |
875 | { |
876 | - if (aEntityData->getKind() != impl::EntityData::COLLECTION) |
877 | + if (aEntityData->getKind() != EntityData::COLLECTION) |
878 | return NULL; |
879 | |
880 | store::Item_t lName; |
881 | @@ -122,7 +122,7 @@ |
882 | } |
883 | } |
884 | |
885 | -} /* namespace zorba::impl */ |
886 | +} /* namespace zorba::internal */ |
887 | |
888 | } /* namespace zorba */ |
889 | |
890 | |
891 | === modified file 'src/context/default_url_resolvers.h' |
892 | --- src/context/default_url_resolvers.h 2011-07-11 11:12:23 +0000 |
893 | +++ src/context/default_url_resolvers.h 2011-11-08 03:14:35 +0000 |
894 | @@ -31,12 +31,14 @@ |
895 | |
896 | namespace zorba { |
897 | |
898 | -namespace impl { |
899 | +namespace internal { |
900 | + |
901 | +/////////////////////////////////////////////////////////////////////////////// |
902 | |
903 | /** |
904 | * @brief http: URL Resolver. |
905 | */ |
906 | -class HTTPURLResolver : public impl::URLResolver |
907 | +class HTTPURLResolver : public internal::URLResolver |
908 | { |
909 | public: |
910 | |
911 | @@ -47,7 +49,7 @@ |
912 | /** |
913 | * @brief file: URL Resolver. |
914 | */ |
915 | -class FileURLResolver : public impl::URLResolver |
916 | +class FileURLResolver : public internal::URLResolver |
917 | { |
918 | public: |
919 | |
920 | @@ -57,7 +59,7 @@ |
921 | |
922 | /** |
923 | */ |
924 | -class ZorbaCollectionURLResolver : public impl::URLResolver |
925 | +class ZorbaCollectionURLResolver : public internal::URLResolver |
926 | { |
927 | public: |
928 | |
929 | @@ -67,12 +69,24 @@ |
930 | EntityData const* aEntityData); |
931 | }; |
932 | |
933 | +#ifndef ZORBA_NO_FULL_TEXT |
934 | + |
935 | +class ThesaurusURLResolver : public URLResolver |
936 | +{ |
937 | +public: |
938 | + // inherited |
939 | + Resource* resolveURL( zstring const &aUrl, EntityData const* ); |
940 | +}; |
941 | + |
942 | +#endif /* ZORBA_NO_FULL_TEXT */ |
943 | + |
944 | +/////////////////////////////////////////////////////////////////////////////// |
945 | + |
946 | } /* namespace zorba::impl */ |
947 | |
948 | } /* namespace zorba */ |
949 | |
950 | #endif /* ZORBA_DEFAULT_URL_RESOLVERS_H */ |
951 | - |
952 | /* |
953 | * Local variables: |
954 | * mode: c++ |
955 | |
956 | === modified file 'src/context/root_static_context.cpp' |
957 | --- src/context/root_static_context.cpp 2011-10-21 10:25:18 +0000 |
958 | +++ src/context/root_static_context.cpp 2011-11-08 03:14:35 +0000 |
959 | @@ -106,13 +106,16 @@ |
960 | |
961 | |
962 | // TODO move into globalenv? memory leaks? |
963 | - add_url_resolver(new impl::FileURLResolver()); |
964 | - add_url_resolver(new impl::HTTPURLResolver()); |
965 | - add_uri_mapper(new impl::FileizeURIMapper()); |
966 | - add_uri_mapper(new impl::ModuleVersioningURIMapper()); |
967 | - add_uri_mapper(new impl::AutoFSURIMapper()); |
968 | - add_url_resolver(new impl::ZorbaCollectionURLResolver()); |
969 | - add_uri_mapper(new impl::ZorbaCollectionURIMapper()); |
970 | + add_url_resolver(new internal::FileURLResolver()); |
971 | + add_url_resolver(new internal::HTTPURLResolver()); |
972 | +#ifndef ZORBA_NO_FULL_TEXT |
973 | + add_url_resolver(new internal::ThesaurusURLResolver()); |
974 | +#endif /* ZORBA_NO_FULL_TEXT */ |
975 | + add_uri_mapper(new internal::FileizeURIMapper()); |
976 | + add_uri_mapper(new internal::ModuleVersioningURIMapper()); |
977 | + add_uri_mapper(new internal::AutoFSURIMapper()); |
978 | + add_url_resolver(new internal::ZorbaCollectionURLResolver()); |
979 | + add_uri_mapper(new internal::ZorbaCollectionURIMapper()); |
980 | |
981 | set_validation_mode(StaticContextConsts::lax_validation); |
982 | |
983 | |
984 | === modified file 'src/context/static_context.cpp' |
985 | --- src/context/static_context.cpp 2011-11-04 11:40:20 +0000 |
986 | +++ src/context/static_context.cpp 2011-11-08 03:14:35 +0000 |
987 | @@ -1364,71 +1364,57 @@ |
988 | /***************************************************************************//** |
989 | |
990 | ********************************************************************************/ |
991 | -void static_context::add_uri_mapper(impl::URIMapper* aMapper) |
992 | -{ |
993 | - theURIMappers.push_back(std::auto_ptr<impl::URIMapper>(aMapper)); |
994 | -} |
995 | - |
996 | - |
997 | -/***************************************************************************//** |
998 | - |
999 | -********************************************************************************/ |
1000 | -void static_context::add_url_resolver(impl::URLResolver* aResolver) |
1001 | -{ |
1002 | - theURLResolvers.push_back(std::auto_ptr<impl::URLResolver>(aResolver)); |
1003 | -} |
1004 | - |
1005 | - |
1006 | -/***************************************************************************//** |
1007 | - Helper class for resolve_uri() |
1008 | -********************************************************************************/ |
1009 | -class SimpleEntityData : public impl::EntityData |
1010 | -{ |
1011 | -public: |
1012 | - SimpleEntityData(impl::EntityData::Kind aKind) : theKind(aKind) |
1013 | - { |
1014 | - } |
1015 | - |
1016 | - virtual impl::EntityData::Kind getKind() const |
1017 | - { |
1018 | - return theKind; |
1019 | - } |
1020 | - |
1021 | -private: |
1022 | - impl::EntityData::Kind const theKind; |
1023 | -}; |
1024 | - |
1025 | - |
1026 | -/***************************************************************************//** |
1027 | - |
1028 | -********************************************************************************/ |
1029 | -std::auto_ptr<impl::Resource> static_context::resolve_uri( |
1030 | +void static_context::add_uri_mapper(internal::URIMapper* aMapper) |
1031 | +{ |
1032 | + theURIMappers.push_back(std::auto_ptr<internal::URIMapper>(aMapper)); |
1033 | +} |
1034 | + |
1035 | + |
1036 | +/***************************************************************************//** |
1037 | + |
1038 | +********************************************************************************/ |
1039 | +void static_context::add_url_resolver(internal::URLResolver* aResolver) |
1040 | +{ |
1041 | + theURLResolvers.push_back(std::auto_ptr<internal::URLResolver>(aResolver)); |
1042 | +} |
1043 | + |
1044 | + |
1045 | +/***************************************************************************//** |
1046 | + |
1047 | +********************************************************************************/ |
1048 | +std::auto_ptr<internal::Resource> static_context::resolve_uri( |
1049 | zstring const& aUri, |
1050 | - impl::EntityData::Kind aEntityKind, |
1051 | + internal::EntityData::Kind aEntityKind, |
1052 | zstring& oErrorMessage) const |
1053 | { |
1054 | // Create a simple EntityData that just reports the specified Kind |
1055 | - SimpleEntityData const lData(aEntityKind); |
1056 | + internal::EntityData const lData(aEntityKind); |
1057 | + return this->resolve_uri(aUri, lData, oErrorMessage); |
1058 | +} |
1059 | |
1060 | +std::auto_ptr<internal::Resource> static_context::resolve_uri( |
1061 | + zstring const& aUri, |
1062 | + internal::EntityData const& aEntityData, |
1063 | + zstring& oErrorMessage) const |
1064 | +{ |
1065 | std::vector<zstring> lUris; |
1066 | - apply_uri_mappers(aUri, &lData, impl::URIMapper::CANDIDATE, lUris); |
1067 | + apply_uri_mappers(aUri, &aEntityData, internal::URIMapper::CANDIDATE, lUris); |
1068 | |
1069 | - std::auto_ptr<impl::Resource> lRetval; |
1070 | - apply_url_resolvers(lUris, &lData, lRetval, oErrorMessage); |
1071 | + std::auto_ptr<internal::Resource> lRetval; |
1072 | + apply_url_resolvers(lUris, &aEntityData, lRetval, oErrorMessage); |
1073 | |
1074 | return lRetval; |
1075 | } |
1076 | |
1077 | - |
1078 | void static_context::get_component_uris( |
1079 | zstring const& aUri, |
1080 | - impl::EntityData::Kind aEntityKind, |
1081 | + internal::EntityData::Kind aEntityKind, |
1082 | std::vector<zstring>& oComponents) const |
1083 | { |
1084 | // Create a simple EntityData that just reports the specified Kind |
1085 | - SimpleEntityData const lData(aEntityKind); |
1086 | + internal::EntityData const lData(aEntityKind); |
1087 | |
1088 | - apply_uri_mappers(aUri, &lData, impl::URIMapper::COMPONENT, oComponents); |
1089 | + apply_uri_mappers(aUri, &lData, internal::URIMapper::COMPONENT, oComponents); |
1090 | if (oComponents.size() == 0) |
1091 | { |
1092 | oComponents.push_back(aUri); |
1093 | @@ -1441,8 +1427,8 @@ |
1094 | ********************************************************************************/ |
1095 | void static_context::apply_uri_mappers( |
1096 | zstring const& aUri, |
1097 | - impl::EntityData const* aEntityData, |
1098 | - impl::URIMapper::Kind aMapperKind, |
1099 | + internal::EntityData const* aEntityData, |
1100 | + internal::URIMapper::Kind aMapperKind, |
1101 | std::vector<zstring>& oUris) const |
1102 | { |
1103 | // Initialize list with the one input URI. |
1104 | @@ -1453,7 +1439,7 @@ |
1105 | sctx != NULL; sctx = sctx->theParent) |
1106 | { |
1107 | // Iterate through all available mappers on this static_context... |
1108 | - for (ztd::auto_vector<impl::URIMapper>::const_iterator mapper = |
1109 | + for (ztd::auto_vector<internal::URIMapper>::const_iterator mapper = |
1110 | sctx->theURIMappers.begin(); |
1111 | mapper != sctx->theURIMappers.end(); mapper++) |
1112 | { |
1113 | @@ -1485,7 +1471,7 @@ |
1114 | // Check the new entries for DENY_ACCESS. |
1115 | for (size_t i = lPreNumResultUris; i < lPostNumResultUris; i++) |
1116 | { |
1117 | - if (lResultUris.at(i) == impl::URIMapper::DENY_ACCESS) { |
1118 | + if (lResultUris.at(i) == internal::URIMapper::DENY_ACCESS) { |
1119 | throw XQUERY_EXCEPTION(zerr::ZXQP0029_URI_ACCESS_DENIED, |
1120 | ERROR_PARAMS(aUri)); |
1121 | } |
1122 | @@ -1506,8 +1492,8 @@ |
1123 | ********************************************************************************/ |
1124 | void static_context::apply_url_resolvers( |
1125 | std::vector<zstring>& aUrls, |
1126 | - impl::EntityData const* aEntityData, |
1127 | - std::auto_ptr<impl::Resource>& oResource, |
1128 | + internal::EntityData const* aEntityData, |
1129 | + std::auto_ptr<internal::Resource>& oResource, |
1130 | zstring& oErrorMessage) const |
1131 | { |
1132 | oErrorMessage = ""; |
1133 | @@ -1528,7 +1514,7 @@ |
1134 | sctx != NULL; sctx = sctx->theParent) |
1135 | { |
1136 | // Iterate through all available resolvers on this static_context... |
1137 | - for (ztd::auto_vector<impl::URLResolver>::const_iterator resolver = |
1138 | + for (ztd::auto_vector<internal::URLResolver>::const_iterator resolver = |
1139 | sctx->theURLResolvers.begin(); |
1140 | resolver != sctx->theURLResolvers.end(); resolver++) |
1141 | { |
1142 | @@ -4001,32 +3987,5 @@ |
1143 | } |
1144 | } |
1145 | |
1146 | - |
1147 | -#ifndef ZORBA_NO_FULL_TEXT |
1148 | - |
1149 | -internal::Thesaurus::ptr |
1150 | -static_context::get_thesaurus( zstring const &uri, iso639_1::type lang ) const { |
1151 | - FOR_EACH( thesaurus_providers_t, p, theThesaurusProviders ) { |
1152 | - internal::Thesaurus::ptr t( (*p)->get_thesaurus( uri, lang ) ); |
1153 | - if ( t.get() ) |
1154 | - return std::move( t ); |
1155 | - } |
1156 | - return theParent ? |
1157 | - theParent->get_thesaurus( uri, lang ) : |
1158 | - internal::ThesaurusProvider::get_default_provider() |
1159 | - .get_thesaurus( uri, lang ); |
1160 | -} |
1161 | - |
1162 | -void static_context::remove_thesaurus_provider( |
1163 | - internal::ThesaurusProvider const *p ) { |
1164 | - ztd::erase_1st_if( |
1165 | - theThesaurusProviders, |
1166 | - std::bind2nd( std::equal_to<internal::ThesaurusProvider const*>(), p ) |
1167 | - ); |
1168 | -} |
1169 | - |
1170 | -#endif /* ZORBA_NO_FULL_TEXT */ |
1171 | - |
1172 | - |
1173 | } // namespace zorba |
1174 | /* vim:set et sw=2 ts=2: */ |
1175 | |
1176 | === modified file 'src/context/static_context.h' |
1177 | --- src/context/static_context.h 2011-11-04 11:40:20 +0000 |
1178 | +++ src/context/static_context.h 2011-11-08 03:14:35 +0000 |
1179 | @@ -40,10 +40,6 @@ |
1180 | |
1181 | #include "zorbautils/hashmap_zstring.h" |
1182 | |
1183 | -#ifndef ZORBA_NO_FULL_TEXT |
1184 | -#include "runtime/full_text/thesaurus.h" |
1185 | -#endif /* ZORBA_NO_FULL_TEXT */ |
1186 | - |
1187 | #include "common/shared_types.h" |
1188 | #include "util/stl_util.h" |
1189 | #include "util/auto_vector.h" |
1190 | @@ -498,14 +494,9 @@ |
1191 | |
1192 | BaseUriInfo * theBaseUriInfo; |
1193 | |
1194 | - ztd::auto_vector<impl::URIMapper> theURIMappers; |
1195 | - |
1196 | - ztd::auto_vector<impl::URLResolver> theURLResolvers; |
1197 | - |
1198 | -#ifndef ZORBA_NO_FULL_TEXT |
1199 | - typedef std::deque<internal::ThesaurusProvider const*> thesaurus_providers_t; |
1200 | - thesaurus_providers_t theThesaurusProviders; |
1201 | -#endif /* ZORBA_NO_FULL_TEXT */ |
1202 | + ztd::auto_vector<internal::URIMapper> theURIMappers; |
1203 | + |
1204 | + ztd::auto_vector<internal::URLResolver> theURLResolvers; |
1205 | |
1206 | checked_vector<zstring> theURIPath; |
1207 | |
1208 | @@ -668,20 +659,27 @@ |
1209 | * Add a URIMapper to be used by this static context when resolving |
1210 | * URIs to resources. |
1211 | */ |
1212 | - void add_uri_mapper(impl::URIMapper* aMapper); |
1213 | + void add_uri_mapper(internal::URIMapper* aMapper); |
1214 | |
1215 | /** |
1216 | * Add a URLResolver to be used by this static context when |
1217 | * resolving URIs to resources. |
1218 | */ |
1219 | - void add_url_resolver(impl::URLResolver* aResolver); |
1220 | + void add_url_resolver(internal::URLResolver* aResolver); |
1221 | |
1222 | /** |
1223 | * Given a URI, return a Resource for that URI. |
1224 | * @param aEntityKind the expected kind of entity expected at this aUri |
1225 | */ |
1226 | - std::auto_ptr<impl::Resource> resolve_uri |
1227 | - (zstring const& aUri, impl::EntityData::Kind aEntityKind, zstring& oErrorMessage) const; |
1228 | + std::auto_ptr<internal::Resource> resolve_uri |
1229 | + (zstring const& aUri, internal::EntityData::Kind aEntityKind, zstring& oErrorMessage) const; |
1230 | + |
1231 | + /** |
1232 | + * Given a URI, return a Resource for that URI. |
1233 | + * @param aEntityData an EntityData object to pass to the mappers/resolvers. |
1234 | + */ |
1235 | + std::auto_ptr<internal::Resource> resolve_uri |
1236 | + (zstring const& aUri, internal::EntityData const& aEntityData, zstring& oErrorMessage) const; |
1237 | |
1238 | /** |
1239 | * Given a URI, populate a vector with a list of component URIs. If |
1240 | @@ -689,20 +687,9 @@ |
1241 | * with (only) the input URI. |
1242 | */ |
1243 | void get_component_uris |
1244 | - (zstring const& aUri, impl::EntityData::Kind aEntityKind, |
1245 | + (zstring const& aUri, internal::EntityData::Kind aEntityKind, |
1246 | std::vector<zstring>& oComponents) const; |
1247 | |
1248 | -#ifndef ZORBA_NO_FULL_TEXT |
1249 | - void add_thesaurus_provider( internal::ThesaurusProvider const *p ) { |
1250 | - theThesaurusProviders.push_front( p ); |
1251 | - } |
1252 | - |
1253 | - internal::Thesaurus::ptr get_thesaurus( zstring const &uri, |
1254 | - locale::iso639_1::type lang ) const; |
1255 | - |
1256 | - void remove_thesaurus_provider( internal::ThesaurusProvider const *p ); |
1257 | -#endif /* ZORBA_NO_FULL_TEXT */ |
1258 | - |
1259 | void set_uri_path(const std::vector<zstring>& aURIPath); |
1260 | |
1261 | void get_uri_path(std::vector<zstring>& oURIPath) const; |
1262 | @@ -1032,13 +1019,13 @@ |
1263 | private: |
1264 | |
1265 | void apply_uri_mappers(zstring const& aUri, |
1266 | - impl::EntityData const* aEntityData, |
1267 | - impl::URIMapper::Kind aMapperKind, |
1268 | + internal::EntityData const* aEntityData, |
1269 | + internal::URIMapper::Kind aMapperKind, |
1270 | std::vector<zstring>& oUris) const; |
1271 | |
1272 | void apply_url_resolvers(std::vector<zstring>& aUrls, |
1273 | - impl::EntityData const* aEntityData, |
1274 | - std::auto_ptr<impl::Resource>& oResource, |
1275 | + internal::EntityData const* aEntityData, |
1276 | + std::auto_ptr<internal::Resource>& oResource, |
1277 | zstring& oErrorMessage) const; |
1278 | |
1279 | public: |
1280 | |
1281 | === modified file 'src/context/thesaurus_wrappers.cpp' |
1282 | --- src/context/thesaurus_wrappers.cpp 2011-08-31 13:17:59 +0000 |
1283 | +++ src/context/thesaurus_wrappers.cpp 2011-11-08 03:14:35 +0000 |
1284 | @@ -87,27 +87,6 @@ |
1285 | |
1286 | /////////////////////////////////////////////////////////////////////////////// |
1287 | |
1288 | -ThesaurusProviderWrapper:: |
1289 | -ThesaurusProviderWrapper( zorba::ThesaurusProvider const *p ) : |
1290 | - api_thesaurus_provider_( p ) |
1291 | -{ |
1292 | - ZORBA_ASSERT( api_thesaurus_provider_ ); |
1293 | -} |
1294 | - |
1295 | -Thesaurus::ptr ThesaurusProviderWrapper:: |
1296 | -get_thesaurus( zstring const &uri, iso639_1::type lang ) const { |
1297 | - String const api_uri( Unmarshaller::newString( uri ) ); |
1298 | - zorba::Thesaurus::ptr t( |
1299 | - api_thesaurus_provider_->getThesaurus( api_uri, lang ) |
1300 | - ); |
1301 | - Thesaurus::ptr result( |
1302 | - t.get() ? new ThesaurusWrapper( std::move( t ) ) : nullptr |
1303 | - ); |
1304 | - return std::move( result ); |
1305 | -} |
1306 | - |
1307 | -/////////////////////////////////////////////////////////////////////////////// |
1308 | - |
1309 | } // namespace internal |
1310 | } // namespace zorba |
1311 | |
1312 | |
1313 | === modified file 'src/context/thesaurus_wrappers.h' |
1314 | --- src/context/thesaurus_wrappers.h 2011-08-31 13:17:59 +0000 |
1315 | +++ src/context/thesaurus_wrappers.h 2011-11-08 03:14:35 +0000 |
1316 | @@ -54,16 +54,6 @@ |
1317 | zorba::Thesaurus::ptr api_thesaurus_; |
1318 | }; |
1319 | |
1320 | -class ThesaurusProviderWrapper : public ThesaurusProvider { |
1321 | -public: |
1322 | - ThesaurusProviderWrapper( zorba::ThesaurusProvider const *p ); |
1323 | - |
1324 | - Thesaurus::ptr get_thesaurus( zstring const &uri, |
1325 | - locale::iso639_1::type lang ) const; |
1326 | -private: |
1327 | - zorba::ThesaurusProvider const *const api_thesaurus_provider_; |
1328 | -}; |
1329 | - |
1330 | /////////////////////////////////////////////////////////////////////////////// |
1331 | |
1332 | } // namespace internal |
1333 | |
1334 | === modified file 'src/context/uri_resolver.cpp' |
1335 | --- src/context/uri_resolver.cpp 2011-08-20 01:30:48 +0000 |
1336 | +++ src/context/uri_resolver.cpp 2011-11-08 03:14:35 +0000 |
1337 | @@ -26,13 +26,13 @@ |
1338 | // We avoid the "static initialization order fiasco" by initializing both of |
1339 | // these constants here in the same file. This also makes it easy to ensure |
1340 | // both strings have the same value. |
1341 | -const zorba::zstring zorba::impl::URIMapper::DENY_ACCESS("[~~Deny Access~~]"); |
1342 | -const zorba::String zorba::URIMapper::DENY_ACCESS(zorba::impl::URIMapper::DENY_ACCESS.c_str()); |
1343 | +const zorba::zstring zorba::internal::URIMapper::DENY_ACCESS("[~~Deny Access~~]"); |
1344 | +const zorba::String zorba::URIMapper::DENY_ACCESS(zorba::internal::URIMapper::DENY_ACCESS.c_str()); |
1345 | |
1346 | |
1347 | namespace zorba { |
1348 | |
1349 | -namespace impl { |
1350 | +namespace internal { |
1351 | |
1352 | /************* |
1353 | * Implementation of the Resource class hierarchy. |
1354 | @@ -100,6 +100,33 @@ |
1355 | return theCollection; |
1356 | } |
1357 | |
1358 | +/************* |
1359 | + * Implementation of EntityData hierarchy. |
1360 | + *************/ |
1361 | + EntityData::EntityData(EntityData::Kind aKind) |
1362 | + : theKind(aKind) |
1363 | + { |
1364 | + } |
1365 | + |
1366 | + EntityData::Kind EntityData::getKind() const |
1367 | + { |
1368 | + return theKind; |
1369 | + } |
1370 | + |
1371 | + EntityData::~EntityData() |
1372 | + { |
1373 | + } |
1374 | + |
1375 | + ThesaurusEntityData::ThesaurusEntityData(locale::iso639_1::type aLang) |
1376 | + : EntityData(EntityData::THESAURUS), |
1377 | + theLang(aLang) |
1378 | + { |
1379 | + } |
1380 | + |
1381 | + locale::iso639_1::type ThesaurusEntityData::getLanguage() const |
1382 | + { |
1383 | + return theLang; |
1384 | + } |
1385 | |
1386 | /************* |
1387 | * URIMapper is an abstract class, but we have to define its vtbl and |
1388 | @@ -117,15 +144,6 @@ |
1389 | URLResolver::~URLResolver() |
1390 | {} |
1391 | |
1392 | - /************* |
1393 | - * EntityData is an abstract class, but we have to define its vtbl |
1394 | - * and base destructor somewhere. |
1395 | - *************/ |
1396 | - |
1397 | - EntityData::~EntityData() |
1398 | - {} |
1399 | - |
1400 | - |
1401 | } /* namespace zorba::impl */ |
1402 | |
1403 | } /* namespace zorba */ |
1404 | |
1405 | === modified file 'src/context/uri_resolver.h' |
1406 | --- src/context/uri_resolver.h 2011-08-20 01:30:48 +0000 |
1407 | +++ src/context/uri_resolver.h 2011-11-08 03:14:35 +0000 |
1408 | @@ -34,13 +34,14 @@ |
1409 | #include <util/auto_vector.h> |
1410 | #include <store/api/shared_types.h> |
1411 | #include <zorba/streams.h> |
1412 | +#include <zorba/locale.h> |
1413 | |
1414 | namespace zorba { |
1415 | |
1416 | // Forward declaration |
1417 | class static_context; |
1418 | |
1419 | -namespace impl { |
1420 | +namespace internal { |
1421 | |
1422 | /** |
1423 | * @brief The class representing the result of URL resolution. |
1424 | @@ -156,9 +157,8 @@ |
1425 | * and URLResolvers when mapping/resolving a URI. |
1426 | * |
1427 | * This base class specifies the kind of entity for which this URI is being |
1428 | - * resolved - for instance, a schema URI or a module URI. In the future, |
1429 | - * there may be kind-specific subclasses containing additional information; |
1430 | - * as yet however there are none. |
1431 | + * resolved - for instance, a schema URI or a module URI. Subclasses of |
1432 | + * this class will provide additional data for specific kinds of entities. |
1433 | */ |
1434 | class EntityData |
1435 | { |
1436 | @@ -178,12 +178,34 @@ |
1437 | SOME_CONTENT |
1438 | }; |
1439 | |
1440 | + EntityData(Kind aKind); |
1441 | + |
1442 | /** |
1443 | * @brief Return the Kind of Entity for which this URI is being resolved. |
1444 | */ |
1445 | - virtual Kind getKind() const = 0; |
1446 | - |
1447 | - virtual ~EntityData() = 0; |
1448 | + virtual Kind getKind() const; |
1449 | + |
1450 | + virtual ~EntityData(); |
1451 | + |
1452 | +private: |
1453 | + Kind const theKind; |
1454 | +}; |
1455 | + |
1456 | +/** |
1457 | + * @brief The class containing additional data for URIMappers and URLResolvers |
1458 | + * when mapping/resolving a Thesaurus URI. |
1459 | + */ |
1460 | +class ThesaurusEntityData : public EntityData |
1461 | +{ |
1462 | +public: |
1463 | + ThesaurusEntityData(locale::iso639_1::type aLang); |
1464 | + /** |
1465 | + * @brief Return the language for which a thesaurus is being requested. |
1466 | + */ |
1467 | + virtual locale::iso639_1::type getLanguage() const; |
1468 | + |
1469 | +private: |
1470 | + locale::iso639_1::type const theLang; |
1471 | }; |
1472 | |
1473 | /** |
1474 | |
1475 | === modified file 'src/functions/external_function.h' |
1476 | --- src/functions/external_function.h 2011-06-14 17:26:33 +0000 |
1477 | +++ src/functions/external_function.h 2011-11-08 03:14:35 +0000 |
1478 | @@ -57,7 +57,7 @@ |
1479 | const zstring& ns, |
1480 | const signature& sig, |
1481 | short scriptingType, |
1482 | - ExternalFunction* impl); |
1483 | + ExternalFunction* internal); |
1484 | |
1485 | ~external_function() { } |
1486 | |
1487 | |
1488 | === modified file 'src/runtime/collections/collections_impl.cpp' |
1489 | --- src/runtime/collections/collections_impl.cpp 2011-11-01 13:47:10 +0000 |
1490 | +++ src/runtime/collections/collections_impl.cpp 2011-11-08 03:14:35 +0000 |
1491 | @@ -114,8 +114,8 @@ |
1492 | { |
1493 | store::Item_t lURI, resolvedURIItem; |
1494 | store::Collection_t coll; |
1495 | - std::auto_ptr<impl::Resource> lResource; |
1496 | - impl::CollectionResource* lCollResource; |
1497 | + std::auto_ptr<internal::Resource> lResource; |
1498 | + internal::CollectionResource* lCollResource; |
1499 | zstring resolvedURIString; |
1500 | zstring lErrorMessage; |
1501 | |
1502 | @@ -153,10 +153,10 @@ |
1503 | } |
1504 | |
1505 | lResource = theSctx->resolve_uri(resolvedURIString, |
1506 | - impl::EntityData::COLLECTION, |
1507 | + internal::EntityData::COLLECTION, |
1508 | lErrorMessage); |
1509 | |
1510 | - lCollResource = dynamic_cast<impl::CollectionResource*>(lResource.get()); |
1511 | + lCollResource = dynamic_cast<internal::CollectionResource*>(lResource.get()); |
1512 | |
1513 | if ( lCollResource == 0 || !(coll = lCollResource->getCollection()) ) |
1514 | { |
1515 | @@ -236,8 +236,8 @@ |
1516 | { |
1517 | store::Item_t lURI; |
1518 | store::Collection_t coll; |
1519 | - std::auto_ptr<impl::Resource> lResource; |
1520 | - impl::CollectionResource* lCollResource; |
1521 | + std::auto_ptr<internal::Resource> lResource; |
1522 | + internal::CollectionResource* lCollResource; |
1523 | zstring resolvedURIString; |
1524 | zstring lErrorMessage; |
1525 | |
1526 | @@ -274,10 +274,10 @@ |
1527 | |
1528 | |
1529 | lResource = theSctx->resolve_uri(resolvedURIString, |
1530 | - impl::EntityData::COLLECTION, |
1531 | + internal::EntityData::COLLECTION, |
1532 | lErrorMessage); |
1533 | |
1534 | - lCollResource = dynamic_cast<impl::CollectionResource*>(lResource.get()); |
1535 | + lCollResource = dynamic_cast<internal::CollectionResource*>(lResource.get()); |
1536 | |
1537 | if ( lCollResource == 0 || !(coll = lCollResource->getCollection()) ) |
1538 | { |
1539 | |
1540 | === modified file 'src/runtime/fetch/fetch_impl.cpp' |
1541 | --- src/runtime/fetch/fetch_impl.cpp 2011-08-05 09:31:11 +0000 |
1542 | +++ src/runtime/fetch/fetch_impl.cpp 2011-11-08 03:14:35 +0000 |
1543 | @@ -43,11 +43,11 @@ |
1544 | { |
1545 | store::Item_t lUri; |
1546 | store::Item_t lEntityKind; |
1547 | - impl::EntityData::Kind lKind; |
1548 | + internal::EntityData::Kind lKind; |
1549 | zstring lKindStr; |
1550 | zstring lErrorMessage; |
1551 | - std::auto_ptr<impl::Resource> lRes; |
1552 | - impl::StreamResource* lStreamRes; |
1553 | + std::auto_ptr<internal::Resource> lRes; |
1554 | + internal::StreamResource* lStreamRes; |
1555 | |
1556 | PlanIteratorState* state; |
1557 | DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); |
1558 | @@ -58,19 +58,19 @@ |
1559 | // Figure out the EntityKind (any better way to do this?) |
1560 | lKindStr = lEntityKind->getStringValue(); |
1561 | if ( ! lKindStr.compare("SOME_CONTENT")) { |
1562 | - lKind = impl::EntityData::SOME_CONTENT; |
1563 | + lKind = internal::EntityData::SOME_CONTENT; |
1564 | } |
1565 | else if ( ! lKindStr.compare("SCHEMA")) { |
1566 | - lKind = impl::EntityData::SCHEMA; |
1567 | + lKind = internal::EntityData::SCHEMA; |
1568 | } |
1569 | else if ( ! lKindStr.compare("MODULE")) { |
1570 | - lKind = impl::EntityData::MODULE; |
1571 | + lKind = internal::EntityData::MODULE; |
1572 | } |
1573 | else if ( ! lKindStr.compare("THESAURUS")) { |
1574 | - lKind = impl::EntityData::THESAURUS; |
1575 | + lKind = internal::EntityData::THESAURUS; |
1576 | } |
1577 | else if ( ! lKindStr.compare("STOP_WORDS")) { |
1578 | - lKind = impl::EntityData::STOP_WORDS; |
1579 | + lKind = internal::EntityData::STOP_WORDS; |
1580 | } |
1581 | else { |
1582 | throw XQUERY_EXCEPTION( |
1583 | @@ -95,7 +95,7 @@ |
1584 | ); |
1585 | } |
1586 | |
1587 | - lStreamRes = dynamic_cast<impl::StreamResource*>(lRes.get()); |
1588 | + lStreamRes = dynamic_cast<internal::StreamResource*>(lRes.get()); |
1589 | if ( !lStreamRes ) { |
1590 | throw XQUERY_EXCEPTION( |
1591 | zerr::ZXQP0025_ITEM_CREATION_FAILED, |
1592 | |
1593 | === modified file 'src/runtime/full_text/apply.cpp' |
1594 | --- src/runtime/full_text/apply.cpp 2011-08-31 13:17:59 +0000 |
1595 | +++ src/runtime/full_text/apply.cpp 2011-11-08 03:14:35 +0000 |
1596 | @@ -20,6 +20,7 @@ |
1597 | #include <vector> |
1598 | |
1599 | #include <zorba/tokenizer.h> |
1600 | +#include <context/uri_resolver.h> |
1601 | |
1602 | #include "compiler/expression/ftnode.h" |
1603 | #include "diagnostics/dict.h" |
1604 | @@ -34,9 +35,9 @@ |
1605 | #include "zorbamisc/ns_consts.h" |
1606 | |
1607 | #ifndef NDEBUG |
1608 | -#include "system/properties.h" |
1609 | -#define DOUT Properties::instance()->debug_out() |
1610 | -#define TRACE_FULL_TEXT Properties::instance()->traceFulltext() |
1611 | +# include "system/properties.h" |
1612 | +# define DOUT Properties::instance()->debug_out() |
1613 | +# define TRACE_FULL_TEXT Properties::instance()->traceFulltext() |
1614 | #endif /* NDEBUG */ |
1615 | |
1616 | #include "apply.h" |
1617 | @@ -49,9 +50,9 @@ |
1618 | |
1619 | #ifdef WIN32 |
1620 | // Windows annoyingly defines these as macros. |
1621 | -#undef max |
1622 | -#undef min |
1623 | -#endif |
1624 | +# undef max |
1625 | +# undef min |
1626 | +#endif /* WIN32 */ |
1627 | |
1628 | using namespace std; |
1629 | using namespace zorba::locale; |
1630 | @@ -1207,19 +1208,25 @@ |
1631 | at_least = 0, at_most = numeric_limits<ft_int>::max(); |
1632 | |
1633 | zstring const &uri = tid.get_uri(); |
1634 | - vector<zstring> comp_uris; |
1635 | - static_ctx_.get_component_uris( uri, impl::EntityData::THESAURUS, comp_uris ); |
1636 | - if ( comp_uris.size() != 1 ) |
1637 | + |
1638 | + zstring error_msg; |
1639 | + auto_ptr<internal::Resource> rsrc = static_ctx_.resolve_uri( |
1640 | + uri, internal::ThesaurusEntityData( qt0.lang() ), error_msg |
1641 | + ); |
1642 | + if ( !rsrc.get() ) |
1643 | throw XQUERY_EXCEPTION( err::FTST0018, ERROR_PARAMS( uri ) ); |
1644 | |
1645 | internal::Thesaurus::ptr thesaurus( |
1646 | - static_ctx_.get_thesaurus( comp_uris.front(), qt0.lang() ) |
1647 | + dynamic_cast<internal::Thesaurus*>( rsrc.release() ) |
1648 | ); |
1649 | + ZORBA_ASSERT( thesaurus ); |
1650 | |
1651 | internal::Thesaurus::iterator::ptr tresult( |
1652 | - thesaurus->lookup( query_phrase, tid.get_relationship(), at_least, at_most ) |
1653 | + thesaurus->lookup( |
1654 | + query_phrase, tid.get_relationship(), at_least, at_most |
1655 | + ) |
1656 | ); |
1657 | - if ( !tresult.get() ) |
1658 | + if ( !tresult ) |
1659 | return; |
1660 | |
1661 | FTTokenSeqIterator::FTTokens synonyms; |
1662 | |
1663 | === modified file 'src/runtime/full_text/ft_stop_words_set.cpp' |
1664 | --- src/runtime/full_text/ft_stop_words_set.cpp 2011-07-22 07:23:17 +0000 |
1665 | +++ src/runtime/full_text/ft_stop_words_set.cpp 2011-11-08 03:14:35 +0000 |
1666 | @@ -127,10 +127,10 @@ |
1667 | } |
1668 | |
1669 | zstring error_msg; |
1670 | - std::auto_ptr<impl::Resource> rsrc = |
1671 | - sctx.resolve_uri(uri, impl::EntityData::STOP_WORDS, error_msg); |
1672 | - impl::StreamResource* stream_rsrc = |
1673 | - dynamic_cast<impl::StreamResource*>(rsrc.get()); |
1674 | + std::auto_ptr<internal::Resource> rsrc = |
1675 | + sctx.resolve_uri(uri, internal::EntityData::STOP_WORDS, error_msg); |
1676 | + internal::StreamResource* stream_rsrc = |
1677 | + dynamic_cast<internal::StreamResource*>(rsrc.get()); |
1678 | if ( !stream_rsrc ) { |
1679 | // Technically this should be thrown during static analysis. |
1680 | throw ZORBA_EXCEPTION(err::FTST0008, ERROR_PARAMS(uri)); |
1681 | |
1682 | === modified file 'src/runtime/full_text/thesaurus.cpp' |
1683 | --- src/runtime/full_text/thesaurus.cpp 2011-08-31 13:17:59 +0000 |
1684 | +++ src/runtime/full_text/thesaurus.cpp 2011-11-08 03:14:35 +0000 |
1685 | @@ -34,6 +34,8 @@ |
1686 | #endif |
1687 | #include "thesauri/xqftts_thesaurus.h" |
1688 | |
1689 | +#include "context/default_url_resolvers.h" |
1690 | + |
1691 | using namespace std; |
1692 | using namespace zorba::locale; |
1693 | |
1694 | @@ -108,27 +110,23 @@ |
1695 | |
1696 | /////////////////////////////////////////////////////////////////////////////// |
1697 | |
1698 | -ThesaurusProvider::~ThesaurusProvider() { |
1699 | - // Out-of-line since it's virtual. |
1700 | -} |
1701 | - |
1702 | -ThesaurusProvider const& ThesaurusProvider::get_default_provider() { |
1703 | - static ThesaurusProvider default_provider; |
1704 | - return default_provider; |
1705 | -} |
1706 | - |
1707 | -Thesaurus::ptr |
1708 | -ThesaurusProvider::get_thesaurus( zstring const &in_uri, |
1709 | - iso639_1::type lang ) const { |
1710 | - thesaurus_impl::type th_impl; |
1711 | - zstring uri; |
1712 | - parse_mapping( in_uri, &th_impl, &uri ); |
1713 | - |
1714 | - zstring th_path; |
1715 | - switch ( uri::get_scheme( uri ) ) { |
1716 | +Resource* |
1717 | +ThesaurusURLResolver::resolveURL( zstring const &url, EntityData const *data ) { |
1718 | + if ( data->getKind() != internal::EntityData::THESAURUS ) |
1719 | + return nullptr; |
1720 | + ThesaurusEntityData const *const t_data = |
1721 | + dynamic_cast<ThesaurusEntityData const*>( data ); |
1722 | + iso639_1::type const lang = t_data->getLanguage(); |
1723 | + |
1724 | + thesaurus_impl::type t_impl; |
1725 | + zstring mapped_url; |
1726 | + parse_mapping( url, &t_impl, &mapped_url ); |
1727 | + |
1728 | + zstring t_path; |
1729 | + switch ( uri::get_scheme( mapped_url ) ) { |
1730 | case uri::file: |
1731 | case uri::none: |
1732 | - th_path = fs::get_normalized_path( uri ); |
1733 | + t_path = fs::get_normalized_path( mapped_url ); |
1734 | break; |
1735 | default: |
1736 | throw XQUERY_EXCEPTION( |
1737 | @@ -137,20 +135,17 @@ |
1738 | ); |
1739 | } |
1740 | |
1741 | - Thesaurus *result; |
1742 | - switch ( th_impl ) { |
1743 | + switch ( t_impl ) { |
1744 | # ifdef ZORBA_WITH_FILE_ACCESS |
1745 | case thesaurus_impl::wordnet: |
1746 | - result = new wordnet::thesaurus( th_path, lang ); |
1747 | - break; |
1748 | + return new wordnet::thesaurus( t_path, lang ); |
1749 | # endif /* ZORBA_WITH_FILE_ACCESS */ |
1750 | case thesaurus_impl::xqftts: |
1751 | - result = new xqftts::thesaurus( th_path, lang ); |
1752 | - break; |
1753 | + return new xqftts::thesaurus( t_path, lang ); |
1754 | default: |
1755 | - throw XQUERY_EXCEPTION( err::FTST0018, ERROR_PARAMS( uri ) ); |
1756 | + throw XQUERY_EXCEPTION( err::FTST0018, ERROR_PARAMS( url ) ); |
1757 | } |
1758 | - return Thesaurus::ptr( result ); |
1759 | + return nullptr; |
1760 | } |
1761 | |
1762 | /////////////////////////////////////////////////////////////////////////////// |
1763 | |
1764 | === modified file 'src/runtime/full_text/thesaurus.h' |
1765 | --- src/runtime/full_text/thesaurus.h 2011-08-31 13:17:59 +0000 |
1766 | +++ src/runtime/full_text/thesaurus.h 2011-11-08 03:14:35 +0000 |
1767 | @@ -20,6 +20,7 @@ |
1768 | #include <zorba/locale.h> |
1769 | #include <zorba/internal/unique_ptr.h> |
1770 | |
1771 | +#include "context/uri_resolver.h" |
1772 | #include "util/stl_util.h" |
1773 | #include "zorbatypes/zstring.h" |
1774 | |
1775 | @@ -33,7 +34,7 @@ |
1776 | /** |
1777 | * A %Thesaurus is the abstract base class for thesaurus implementations. |
1778 | */ |
1779 | -class Thesaurus { |
1780 | +class Thesaurus : public internal::Resource { |
1781 | public: |
1782 | typedef std::unique_ptr<Thesaurus,ztd::destroy_delete<Thesaurus> > ptr; |
1783 | |
1784 | @@ -94,32 +95,6 @@ |
1785 | Thesaurus& operator=( Thesaurus const& ); |
1786 | }; |
1787 | |
1788 | -/** |
1789 | - * A %ThesaurusProvider provides a Thesaurus for a particular language. |
1790 | - */ |
1791 | -class ThesaurusProvider { |
1792 | -public: |
1793 | - virtual ~ThesaurusProvider(); |
1794 | - |
1795 | - /** |
1796 | - * Gets the default %ThesaurusProvider. |
1797 | - * |
1798 | - * @return Returns said %ThesaurusProvider. |
1799 | - */ |
1800 | - static ThesaurusProvider const& get_default_provider(); |
1801 | - |
1802 | - /** |
1803 | - * Gets and instance of a %Thesaurus for the given language. |
1804 | - * |
1805 | - * @param uri The URI provided in the query for the thesaurus. |
1806 | - * @param lang The language of the thesaurus. |
1807 | - * @return Returns said Thesaurus or \c NULL if no thesaurus is available for |
1808 | - * the given language. |
1809 | - */ |
1810 | - virtual Thesaurus::ptr get_thesaurus( zstring const &uri, |
1811 | - locale::iso639_1::type lang ) const; |
1812 | -}; |
1813 | - |
1814 | /////////////////////////////////////////////////////////////////////////////// |
1815 | |
1816 | } // namespace internal |
1817 | |
1818 | === modified file 'src/runtime/sequences/sequences_impl.cpp' |
1819 | --- src/runtime/sequences/sequences_impl.cpp 2011-10-03 09:18:49 +0000 |
1820 | +++ src/runtime/sequences/sequences_impl.cpp 2011-11-08 03:14:35 +0000 |
1821 | @@ -1819,10 +1819,10 @@ |
1822 | |
1823 | // Resolve URI to a stream |
1824 | zstring lErrorMessage; |
1825 | - std::auto_ptr<impl::Resource> lResource = aSctx->resolve_uri |
1826 | - (lNormUri, impl::EntityData::DOCUMENT, lErrorMessage); |
1827 | - impl::StreamResource* lStreamResource = |
1828 | - dynamic_cast<impl::StreamResource*>(lResource.get()); |
1829 | + std::auto_ptr<internal::Resource> lResource = aSctx->resolve_uri |
1830 | + (lNormUri, internal::EntityData::DOCUMENT, lErrorMessage); |
1831 | + internal::StreamResource* lStreamResource = |
1832 | + dynamic_cast<internal::StreamResource*>(lResource.get()); |
1833 | if (lStreamResource == NULL) { |
1834 | throw XQUERY_EXCEPTION |
1835 | (err::FODC0002, ERROR_PARAMS(aUri, lErrorMessage), ERROR_LOC(loc)); |
1836 | |
1837 | === modified file 'src/runtime/xqdoc/xqdoc_impl.cpp' |
1838 | --- src/runtime/xqdoc/xqdoc_impl.cpp 2011-08-04 02:14:56 +0000 |
1839 | +++ src/runtime/xqdoc/xqdoc_impl.cpp 2011-11-08 03:14:35 +0000 |
1840 | @@ -52,8 +52,8 @@ |
1841 | zstring strval; |
1842 | std::string uriStr; |
1843 | static_context* lSctx; |
1844 | - std::auto_ptr<impl::Resource> lResource; |
1845 | - impl::StreamResource* lStream; |
1846 | + std::auto_ptr<internal::Resource> lResource; |
1847 | + internal::StreamResource* lStream; |
1848 | std::istream* lFile; |
1849 | zstring lErrorMessage; |
1850 | |
1851 | @@ -78,8 +78,8 @@ |
1852 | lSctx = theSctx; |
1853 | lItem->getStringValue2(strval); |
1854 | lURI = lSctx->resolve_relative_uri(strval); |
1855 | - lResource = lSctx->resolve_uri(lURI, impl::EntityData::MODULE, lErrorMessage); |
1856 | - lStream = static_cast<impl::StreamResource*>(lResource.get()); |
1857 | + lResource = lSctx->resolve_uri(lURI, internal::EntityData::MODULE, lErrorMessage); |
1858 | + lStream = static_cast<internal::StreamResource*>(lResource.get()); |
1859 | if ( ! lStream ) |
1860 | { |
1861 | throw XQUERY_EXCEPTION( |
1862 | |
1863 | === modified file 'src/store/naive/simple_index_general.cpp' |
1864 | --- src/store/naive/simple_index_general.cpp 2011-11-07 06:04:55 +0000 |
1865 | +++ src/store/naive/simple_index_general.cpp 2011-11-08 03:14:35 +0000 |
1866 | @@ -71,7 +71,7 @@ |
1867 | /****************************************************************************** |
1868 | |
1869 | ********************************************************************************/ |
1870 | -uint32_t GeneralIndexCompareFunction::hash(const store::Item* key) const |
1871 | +uint32_t GeneralIndexCompareFunction::hash(const store::Item_t& key) const |
1872 | { |
1873 | uint32_t hval = FNV_32_INIT; |
1874 | |
1875 | @@ -86,8 +86,8 @@ |
1876 | |
1877 | ********************************************************************************/ |
1878 | bool GeneralIndexCompareFunction::equal( |
1879 | - const store::Item* key1, |
1880 | - const store::Item* key2) const |
1881 | + const store::Item_t& key1, |
1882 | + const store::Item_t& key2) const |
1883 | { |
1884 | if (key1 == NULL && key2 == NULL) |
1885 | return true; |
1886 | @@ -95,7 +95,7 @@ |
1887 | if (key1 == NULL || key2 == NULL) |
1888 | return false; |
1889 | |
1890 | - if (! key1->equals(key2, theTimezone, theCollator)) |
1891 | + if (! key1->equals(key2.getp(), theTimezone, theCollator)) |
1892 | return false; |
1893 | |
1894 | return true; |
1895 | @@ -106,8 +106,8 @@ |
1896 | |
1897 | ********************************************************************************/ |
1898 | long GeneralIndexCompareFunction::compare( |
1899 | - const store::Item* key1, |
1900 | - const store::Item* key2) const |
1901 | + const store::Item_t& key1, |
1902 | + const store::Item_t& key2) const |
1903 | { |
1904 | long result; |
1905 | |
1906 | @@ -669,7 +669,7 @@ |
1907 | //std::cout << "Index Entry Delete [" << (*ite).first << "," |
1908 | // << (*ite).second << "]" << std::endl; |
1909 | |
1910 | - const_cast<store::Item*>((*ite).first)->removeReference(); |
1911 | + (*ite).first->removeReference(); |
1912 | delete (*ite).second; |
1913 | } |
1914 | |
1915 | @@ -832,7 +832,7 @@ |
1916 | //std::cout << "Index Entry Delete [" << (*ite).first << "," |
1917 | // << (*ite).second << "]" << std::endl; |
1918 | |
1919 | - const_cast<store::Item*>((*ite).first)->removeReference(); |
1920 | + (*ite).first->removeReference(); |
1921 | delete (*ite).second; |
1922 | } |
1923 | |
1924 | @@ -1842,8 +1842,8 @@ |
1925 | ********************************************************************************/ |
1926 | void ProbeGeneralIndexIterator::probeMap( |
1927 | SchemaTypeCode targetMap, |
1928 | - const store::Item* lowerKey, |
1929 | - const store::Item* upperKey) |
1930 | + const AtomicItem_t& lowerKey, |
1931 | + const AtomicItem_t& upperKey) |
1932 | { |
1933 | static_cast<ProbeGeneralTreeIndexIterator*>(this)-> |
1934 | probeMap(static_cast<GeneralTreeIndex*>(theIndex.getp())->theMaps[targetMap], |
1935 | @@ -2095,8 +2095,8 @@ |
1936 | ********************************************************************************/ |
1937 | void ProbeGeneralTreeIndexIterator::probeMap( |
1938 | const GeneralTreeIndex::IndexMap* map, |
1939 | - const store::Item* lowerKey, |
1940 | - const store::Item* upperKey) |
1941 | + const AtomicItem_t& lowerKey, |
1942 | + const AtomicItem_t& upperKey) |
1943 | { |
1944 | if (map == NULL) |
1945 | return; |
1946 | @@ -2125,9 +2125,9 @@ |
1947 | if (haveLower) |
1948 | { |
1949 | if (lowerIncl) |
1950 | - theMapBegins.push_back(map->lower_bound(lowerKey)); |
1951 | + theMapBegins.push_back(map->lower_bound(lowerKey.getp())); |
1952 | else |
1953 | - theMapBegins.push_back(map->upper_bound(lowerKey)); |
1954 | + theMapBegins.push_back(map->upper_bound(lowerKey.getp())); |
1955 | } |
1956 | else |
1957 | { |
1958 | @@ -2137,9 +2137,9 @@ |
1959 | if (haveUpper) |
1960 | { |
1961 | if (upperIncl) |
1962 | - theMapEnds.push_back(map->upper_bound(upperKey)); |
1963 | + theMapEnds.push_back(map->upper_bound(upperKey.getp())); |
1964 | else |
1965 | - theMapEnds.push_back(map->lower_bound(upperKey)); |
1966 | + theMapEnds.push_back(map->lower_bound(upperKey.getp())); |
1967 | } |
1968 | else |
1969 | { |
1970 | |
1971 | === modified file 'src/store/naive/simple_index_general.h' |
1972 | --- src/store/naive/simple_index_general.h 2011-11-07 06:04:55 +0000 |
1973 | +++ src/store/naive/simple_index_general.h 2011-11-08 03:14:35 +0000 |
1974 | @@ -47,13 +47,13 @@ |
1975 | |
1976 | const XQPCollator* getCollator() const { return theCollator; } |
1977 | |
1978 | - uint32_t hash(const store::Item* key) const; |
1979 | - |
1980 | - bool equal(const store::Item* key1, const store::Item* key2) const; |
1981 | - |
1982 | - long compare(const store::Item* key1, const store::Item* key2) const; |
1983 | - |
1984 | - bool operator()(const store::Item* key1, const store::Item* key2) const |
1985 | + uint32_t hash(const store::Item_t& key) const; |
1986 | + |
1987 | + bool equal(const store::Item_t& key1, const store::Item_t& key2) const; |
1988 | + |
1989 | + long compare(const store::Item_t& key1, const store::Item_t& key2) const; |
1990 | + |
1991 | + bool operator()(const store::Item_t& key1, const store::Item_t& key2) const |
1992 | { |
1993 | return compare(key1, key2) < 0; |
1994 | } |
1995 | @@ -129,7 +129,7 @@ |
1996 | friend class ProbeGeneralIndexIterator; |
1997 | friend class ProbeGeneralTreeIndexIterator; |
1998 | |
1999 | - typedef std::pair<const store::Item*, GeneralIndexValue*> IndexMapPair; |
2000 | + typedef std::pair<store::Item*, GeneralIndexValue*> IndexMapPair; |
2001 | |
2002 | private: |
2003 | static const int64_t theMaxLong; |
2004 | @@ -197,7 +197,7 @@ |
2005 | friend class ProbeGeneralIndexIterator; |
2006 | friend class ProbeGeneralHashIndexIterator; |
2007 | |
2008 | - typedef HashMap<const store::Item*, |
2009 | + typedef HashMap<store::Item*, |
2010 | GeneralIndexValue*, |
2011 | GeneralIndexCompareFunction> IndexMap; |
2012 | |
2013 | @@ -248,7 +248,7 @@ |
2014 | friend class ProbeGeneralIndexIterator; |
2015 | friend class ProbeGeneralTreeIndexIterator; |
2016 | |
2017 | - typedef std::map<const store::Item*, |
2018 | + typedef std::map<store::Item*, |
2019 | GeneralIndexValue*, |
2020 | GeneralIndexCompareFunction> IndexMap; |
2021 | |
2022 | @@ -410,8 +410,8 @@ |
2023 | |
2024 | void probeMap( |
2025 | const SchemaTypeCode targetMap, |
2026 | - const store::Item* lowerKey, |
2027 | - const store::Item* upperKey); |
2028 | + const AtomicItem_t& lowerKey, |
2029 | + const AtomicItem_t& upperKey); |
2030 | |
2031 | void checkStringKeyType(const AtomicItem* keyItem) const; |
2032 | |
2033 | @@ -467,8 +467,8 @@ |
2034 | |
2035 | void probeMap( |
2036 | const GeneralTreeIndex::IndexMap* targetMap, |
2037 | - const store::Item* lowerKey, |
2038 | - const store::Item* upperKey); |
2039 | + const AtomicItem_t& lowerKey, |
2040 | + const AtomicItem_t& upperKey); |
2041 | |
2042 | public: |
2043 | ProbeGeneralTreeIndexIterator(const store::Index_t& index); |
2044 | |
2045 | === modified file 'src/system/globalenv.cpp' |
2046 | --- src/system/globalenv.cpp 2011-11-01 13:47:10 +0000 |
2047 | +++ src/system/globalenv.cpp 2011-11-08 03:14:35 +0000 |
2048 | @@ -97,7 +97,7 @@ |
2049 | |
2050 | m_globalEnv->m_compilerSubSys = lSubSystem.release(); |
2051 | |
2052 | - m_globalEnv->m_http_resolver = new impl::HTTPURLResolver(); |
2053 | + m_globalEnv->m_http_resolver = new internal::HTTPURLResolver(); |
2054 | } |
2055 | |
2056 | |
2057 | |
2058 | === modified file 'src/system/globalenv.h' |
2059 | --- src/system/globalenv.h 2011-06-26 09:43:12 +0000 |
2060 | +++ src/system/globalenv.h 2011-11-08 03:14:35 +0000 |
2061 | @@ -28,10 +28,13 @@ |
2062 | class root_static_context; |
2063 | class XQueryXConvertor; |
2064 | |
2065 | -namespace impl { |
2066 | +namespace internal { |
2067 | class HTTPURLResolver; |
2068 | class FileURLResolver; |
2069 | class AutoFSURIMapper; |
2070 | +#ifndef ZORBA_NO_FULL_TEXT |
2071 | +class ThesaurusURLResolver; |
2072 | +#endif /* ZORBA_NO_FULL_TEXT */ |
2073 | } |
2074 | |
2075 | namespace store { |
2076 | @@ -57,9 +60,12 @@ |
2077 | XQueryXConvertor * xqueryx_convertor; |
2078 | #endif |
2079 | |
2080 | - impl::HTTPURLResolver * m_http_resolver; |
2081 | - impl::FileURLResolver * m_file_resolver; |
2082 | - impl::AutoFSURIMapper * m_autofs_mapper; |
2083 | + internal::HTTPURLResolver * m_http_resolver; |
2084 | + internal::FileURLResolver * m_file_resolver; |
2085 | + internal::AutoFSURIMapper * m_autofs_mapper; |
2086 | +#ifndef ZORBA_NO_FULL_TEXT |
2087 | + internal::ThesaurusURLResolver * m_thesaurus_resolver; |
2088 | +#endif /* ZORBA_NO_FULL_TEXT */ |
2089 | |
2090 | public: |
2091 | |
2092 | @@ -92,11 +98,15 @@ |
2093 | |
2094 | store::IteratorFactory* getIteratorFactory(); |
2095 | |
2096 | - impl::HTTPURLResolver* getHTTPURLResolver() const { return m_http_resolver; } |
2097 | - |
2098 | - impl::FileURLResolver* getFileURLResolver() const { return m_file_resolver; } |
2099 | - |
2100 | - impl::AutoFSURIMapper* getAutoFSURIMapper() const { return m_autofs_mapper; } |
2101 | + internal::HTTPURLResolver* getHTTPURLResolver() const { return m_http_resolver; } |
2102 | + |
2103 | + internal::FileURLResolver* getFileURLResolver() const { return m_file_resolver; } |
2104 | + |
2105 | + internal::AutoFSURIMapper* getAutoFSURIMapper() const { return m_autofs_mapper; } |
2106 | + |
2107 | +#ifndef ZORBA_NO_FULL_TEXT |
2108 | + internal::ThesaurusURLResolver* getThesaurusURLResolver() const { return m_thesaurus_resolver; } |
2109 | +#endif /* ZORBA_NO_FULL_TEXT */ |
2110 | |
2111 | #ifdef ZORBA_XQUERYX |
2112 | XQueryXConvertor* getXQueryXConvertor(); |
2113 | |
2114 | === modified file 'src/types/schema/schema.cpp' |
2115 | --- src/types/schema/schema.cpp 2011-10-26 16:55:08 +0000 |
2116 | +++ src/types/schema/schema.cpp 2011-11-08 03:14:35 +0000 |
2117 | @@ -205,7 +205,7 @@ |
2118 | isSystemId = true; |
2119 | } |
2120 | |
2121 | - std::auto_ptr<impl::Resource> lResource; |
2122 | + std::auto_ptr<internal::Resource> lResource; |
2123 | |
2124 | zstring lStrId = StrX(lId).localForm(); |
2125 | zstring lResolved; |
2126 | @@ -228,9 +228,9 @@ |
2127 | { |
2128 | TRACE("lId: " << StrX(lId) << " lResolved: " << lResolved); |
2129 | zstring lErrorMessage; |
2130 | - lResource = theSctx->resolve_uri(lResolved, impl::EntityData::SCHEMA, lErrorMessage); |
2131 | - impl::StreamResource* lStream = |
2132 | - dynamic_cast<impl::StreamResource*>(lResource.get()); |
2133 | + lResource = theSctx->resolve_uri(lResolved, internal::EntityData::SCHEMA, lErrorMessage); |
2134 | + internal::StreamResource* lStream = |
2135 | + dynamic_cast<internal::StreamResource*>(lResource.get()); |
2136 | if (lStream != NULL) |
2137 | { |
2138 | // Pass memory ownership of this istream to the new IstreamInputSource |
2139 | @@ -265,7 +265,7 @@ |
2140 | StaticContextEntityResolver( |
2141 | const XMLCh* const aLogicalURI, |
2142 | static_context * aSctx, |
2143 | - impl::StreamResource* aStreamResource) |
2144 | + internal::StreamResource* aStreamResource) |
2145 | : theLogicalURI(aLogicalURI), theSctx(aSctx) |
2146 | { |
2147 | // Take memory ownership of the istream |
2148 | @@ -391,7 +391,7 @@ |
2149 | *******************************************************************************/ |
2150 | void Schema::registerXSD(const char* xsdURL, |
2151 | static_context * aSctx, |
2152 | - impl::StreamResource* stream, |
2153 | + internal::StreamResource* stream, |
2154 | const QueryLoc& loc) |
2155 | { |
2156 | std::auto_ptr<SAX2XMLReader> parser; |
2157 | |
2158 | === modified file 'src/types/schema/schema.h' |
2159 | --- src/types/schema/schema.h 2011-06-14 17:26:33 +0000 |
2160 | +++ src/types/schema/schema.h 2011-11-08 03:14:35 +0000 |
2161 | @@ -51,7 +51,7 @@ |
2162 | { |
2163 | |
2164 | // Forward reference |
2165 | -namespace impl |
2166 | +namespace internal |
2167 | { |
2168 | class StreamResource; |
2169 | } |
2170 | @@ -103,7 +103,7 @@ |
2171 | void registerXSD( |
2172 | const char* xsdURL, |
2173 | static_context * aSctx, |
2174 | - impl::StreamResource* aStreamResource, |
2175 | + internal::StreamResource* aStreamResource, |
2176 | const QueryLoc& loc); |
2177 | |
2178 | void getSubstitutionHeadForElement( |
2179 | |
2180 | === modified file 'test/rbkt/specification.h' |
2181 | --- test/rbkt/specification.h 2011-07-14 00:03:05 +0000 |
2182 | +++ test/rbkt/specification.h 2011-11-08 03:14:35 +0000 |
2183 | @@ -59,7 +59,7 @@ |
2184 | #ifndef ZORBA_NO_FULL_TEXT |
2185 | , |
2186 | theStopWordsMapper(zorba::EntityData::STOP_WORDS), |
2187 | - theThesaurusMapper(zorba::EntityData::THESAURUS, zorba::URIMapper::COMPONENT) |
2188 | + theThesaurusMapper(zorba::EntityData::THESAURUS) |
2189 | #endif /* ZORBA_NO_FULL_TEXT */ |
2190 | {} |
2191 | |
2192 | |
2193 | === modified file 'test/unit/thesaurus.cpp' |
2194 | --- test/unit/thesaurus.cpp 2011-08-31 13:17:59 +0000 |
2195 | +++ test/unit/thesaurus.cpp 2011-11-08 03:14:35 +0000 |
2196 | @@ -100,24 +100,20 @@ |
2197 | |
2198 | /////////////////////////////////////////////////////////////////////////////// |
2199 | |
2200 | -class TestThesaurusProvider : public ThesaurusProvider { |
2201 | +class TestThesaurusResolver : public URLResolver { |
2202 | public: |
2203 | - TestThesaurusProvider( String const &uri ) : uri_( uri ) { } |
2204 | + TestThesaurusResolver( String const &uri ) : uri_( uri ) { } |
2205 | |
2206 | // inherited |
2207 | - Thesaurus::ptr getThesaurus( String const &uri, iso639_1::type lang ) const; |
2208 | + Resource* resolveURL( String const &uri, EntityData const* ); |
2209 | private: |
2210 | String const uri_; |
2211 | }; |
2212 | |
2213 | -Thesaurus::ptr |
2214 | -TestThesaurusProvider::getThesaurus( String const &uri, |
2215 | - iso639_1::type lang ) const { |
2216 | +Resource* |
2217 | +TestThesaurusResolver::resolveURL( String const &uri, EntityData const *ed ) { |
2218 | static TestThesaurus thesaurus; |
2219 | - Thesaurus::ptr result; |
2220 | - if ( uri == uri_ ) |
2221 | - result.reset( &thesaurus ); |
2222 | - return std::move( result ); |
2223 | + return uri == uri_ ? &thesaurus : 0; |
2224 | } |
2225 | |
2226 | /////////////////////////////////////////////////////////////////////////////// |
2227 | @@ -137,8 +133,8 @@ |
2228 | " using thesaurus at \"http://test\" \n"; |
2229 | |
2230 | StaticContext_t sctx = zorba->createStaticContext(); |
2231 | - TestThesaurusProvider provider( "http://test" ); |
2232 | - sctx->addThesaurusProvider( &provider ); |
2233 | + TestThesaurusResolver resolver( "http://test" ); |
2234 | + sctx->registerURLResolver( &resolver ); |
2235 | XQuery_t xquery = zorba->compileQuery( query_src, sctx ); |
2236 | |
2237 | Zorba_SerializerOptions ser_options; |
2238 | @@ -154,7 +150,7 @@ |
2239 | } |
2240 | catch ( ZorbaException const &e ) { |
2241 | cerr << e << endl; |
2242 | - result = 2; |
2243 | + result = 3; |
2244 | } |
2245 | |
2246 | zorba->shutdown(); |
Attempt to merge into lp:zorba failed due to conflicts:
text conflict in src/system/ globalenv. cpp