Merge lp:~zorba-coders/zorba/bug931580 into lp:zorba
- bug931580
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Rodolfo Ochoa | ||||
Approved revision: | 10674 | ||||
Merged at revision: | 10733 | ||||
Proposed branch: | lp:~zorba-coders/zorba/bug931580 | ||||
Merge into: | lp:zorba | ||||
Diff against target: |
5310 lines (+3914/-530) 80 files modified
ChangeLog (+6/-1) doc/php/examples/CMakeLists.txt (+5/-1) doc/php/examples/zorba_api.php (+1/-1) doc/ruby/examples/CMakeLists.txt (+6/-1) swig/Collection.h (+47/-0) swig/Collection.i (+91/-0) swig/CollectionManager.h (+37/-0) swig/CollectionManager.i (+47/-0) swig/DocumentManager.h (+36/-0) swig/DocumentManager.i (+46/-0) swig/DynamicContext.h (+45/-0) swig/DynamicContext.i (+59/-0) swig/Item.h (+68/-0) swig/Item.i (+114/-0) swig/ItemFactory.h (+34/-5) swig/ItemFactory.i (+44/-10) swig/ItemSequence.h (+32/-0) swig/ItemSequence.i (+26/-0) swig/Iterator.h (+57/-0) swig/Iterator.i (+69/-0) swig/SerializationOptions.h (+114/-0) swig/SerializationOptions.i (+125/-0) swig/StaticContext.h (+122/-47) swig/StaticContext.i (+224/-70) swig/Store.i (+2/-0) swig/TypeIdentifier.h (+97/-0) swig/TypeIdentifier.i (+197/-0) swig/XQuery.h (+47/-0) swig/XQuery.i (+23/-295) swig/XmlDataManager.h (+35/-0) swig/XmlDataManager.i (+12/-67) swig/Zorba.i (+40/-8) swig/java/CMakeLists.txt (+15/-2) swig/java/zorba_api.i (+2/-1) swig/php/CMakeLists.txt (+14/-0) swig/php/tests/CMakeLists.txt (+90/-0) swig/php/tests/books.xml (+11/-0) swig/php/tests/compilerHints.xq (+4/-0) swig/php/tests/php.ini.in (+3/-0) swig/php/tests/test01.php (+29/-0) swig/php/tests/test02.php (+44/-0) swig/php/tests/test03.php (+48/-0) swig/php/tests/test04.php (+43/-0) swig/php/tests/test04.xq (+4/-0) swig/php/tests/test05.php (+43/-0) swig/php/tests/test05.xq (+7/-0) swig/php/tests/test06.php (+43/-0) swig/php/tests/test06.xq (+7/-0) swig/php/tests/test07.php (+56/-0) swig/php/tests/test08.php (+120/-0) swig/php/tests/test09.php (+92/-0) swig/php/tests/test10.php (+55/-0) swig/php/tests/test11.php (+52/-0) swig/php/tests/test12.php (+52/-0) swig/php/tests/test13.php (+53/-0) swig/php/tests/test14.php (+53/-0) swig/php/tests/zorba_api.php (+178/-0) swig/python/CMakeLists.txt (+19/-9) swig/ruby/CMakeLists.txt (+16/-2) swig/ruby/tests/CMakeLists.txt (+83/-0) swig/ruby/tests/books.xml (+11/-0) swig/ruby/tests/compilerHints.xq (+4/-0) swig/ruby/tests/test01.rb (+24/-0) swig/ruby/tests/test02.rb (+39/-0) swig/ruby/tests/test03.rb (+43/-0) swig/ruby/tests/test04.rb (+35/-0) swig/ruby/tests/test04.xq (+4/-0) swig/ruby/tests/test05.rb (+35/-0) swig/ruby/tests/test05.xq (+7/-0) swig/ruby/tests/test06.rb (+35/-0) swig/ruby/tests/test06.xq (+7/-0) swig/ruby/tests/test07.rb (+48/-0) swig/ruby/tests/test08.rb (+108/-0) swig/ruby/tests/test09.rb (+81/-0) swig/ruby/tests/test10.rb (+46/-0) swig/ruby/tests/test11.rb (+49/-0) swig/ruby/tests/test12.rb (+49/-0) swig/ruby/tests/test13.rb (+50/-0) swig/ruby/tests/test14.rb (+50/-0) swig/zorba_api.i (+45/-10) |
||||
To merge this branch: | bzr merge lp:~zorba-coders/zorba/bug931580 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matthias Brantner | Approve | ||
Rodolfo Ochoa | Approve | ||
Cezar Andrei | Approve | ||
Review via email: mp+92818@code.launchpad.net |
Commit message
This upgrade supply the required objects and methods for basic XQJ support.
Description of the change
This upgrade supply the required objects and methods for basic XQJ support.
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/bug931580 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug931580-2012-02-
final status was:
No tests were run - build or configure step must have failed.
Not commiting changes.
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 : | # |
The attempt to merge lp:~zorba-coders/zorba/bug931580 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug931580-2012-02-
final status was:
No tests were run - build or configure step must have failed.
Not commiting changes.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
Cezar Andrei (cezar-andrei) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job bug931580-2012-02-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 1 Approve, 2 Pending.
Matthias Brantner (matthias-brantner) wrote : | # |
The change provides a great extension to all of Zorba's language bindings.
Two things:
- it currently doesn't build on my machine (Ubuntu 11.04 with gcc 4.5.2)
[ 97%] Building CXX object swig/python/
In file included from /usr/include/
/usr/include/
/usr/include/
/usr/include/
/usr/include/
/home/mbrantner
/home/mbrantner
/home/mbrantner
/home/mbrantner
/home/mbrantner
/home/mbrantner
/home/mbrantner
/home/mbrantner
In file included from /home/mbrantner
/home/mbrantner
/home/mbrantner
/home/mbrantner
/home/mbrantner
/home/mbrantner
/home/mbrantner
- Also, I'm a little bit worried about the absence of tests for the language bindings other than Java. We should at least have some testing for them (e.g. PHP, Python, and Ruby).
Rodolfo Ochoa (rodolfo-ochoa) wrote : | # |
- Ruby, PHP and Python tests are working
- Python error is fixed
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/bug931580 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug931580-2012-03-
final status was:
8 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 bug931580-2012-03-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 2 Approve, 1 Needs Fixing.
Matthias Brantner (matthias-brantner) wrote : | # |
- Why does the CollectionManager exist? It doesn't seem to be accessible from anywhere?
- The ChangeLog needs to be updated to reflect the new features.
Matthias Brantner (matthias-brantner) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Attempt to merge into lp:zorba failed due to conflicts:
text conflict in ChangeLog
- 10674. By Rodolfo Ochoa
-
-Solved conflict with Changelog
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job bug931580-2012-03-
All tests succeeded!
Preview Diff
1 | === modified file 'ChangeLog' | |||
2 | --- ChangeLog 2012-03-26 19:41:44 +0000 | |||
3 | +++ ChangeLog 2012-03-26 20:16:18 +0000 | |||
4 | @@ -1,10 +1,15 @@ | |||
5 | 1 | Zorba - The XQuery Processor | 1 | Zorba - The XQuery Processor |
6 | 2 | 2 | ||
7 | 3 | version 2.5 | 3 | version 2.5 |
8 | 4 | |||
9 | 5 | New Features: | ||
10 | 6 | * Extended API for Python, Java, PHP and Ruby. | ||
11 | 7 | |||
12 | 8 | Bug Fixes/Other Changes: | ||
13 | 4 | * Fixed bug in window iterator | 9 | * Fixed bug in window iterator |
14 | 5 | * Fixed bug #872234 (prevent a rewritting to take place in case of sequential expr) | 10 | * Fixed bug #872234 (prevent a rewritting to take place in case of sequential expr) |
15 | 6 | 11 | ||
17 | 7 | 12 | ||
18 | 8 | version 2.2 | 13 | version 2.2 |
19 | 9 | 14 | ||
20 | 10 | New Features: | 15 | New Features: |
21 | 11 | 16 | ||
22 | === modified file 'doc/php/examples/CMakeLists.txt' | |||
23 | --- doc/php/examples/CMakeLists.txt 2012-03-23 17:32:07 +0000 | |||
24 | +++ doc/php/examples/CMakeLists.txt 2012-03-26 20:16:18 +0000 | |||
25 | @@ -18,7 +18,11 @@ | |||
26 | 18 | 18 | ||
27 | 19 | SET(phpPath ${CMAKE_BINARY_DIR}/swig/php) | 19 | SET(phpPath ${CMAKE_BINARY_DIR}/swig/php) |
28 | 20 | MESSAGE(STATUS "PHP Path:" ${phpPath}) | 20 | MESSAGE(STATUS "PHP Path:" ${phpPath}) |
30 | 21 | SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php) | 21 | IF (MSVC_IDE) |
31 | 22 | SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php/@CMAKE_BUILD_TYPE@) | ||
32 | 23 | ELSE (MSVC_IDE) | ||
33 | 24 | SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php) | ||
34 | 25 | ENDIF (MSVC_IDE) | ||
35 | 22 | MESSAGE(STATUS "PHP Extension Path: " ${phpExtensionPath}) | 26 | MESSAGE(STATUS "PHP Extension Path: " ${phpExtensionPath}) |
36 | 23 | SET(phpIncludePath ${CMAKE_BINARY_DIR}/swig/php) | 27 | SET(phpIncludePath ${CMAKE_BINARY_DIR}/swig/php) |
37 | 24 | MESSAGE(STATUS "PHP Include Path: " ${phpExtensionPath}) | 28 | MESSAGE(STATUS "PHP Include Path: " ${phpExtensionPath}) |
38 | 25 | 29 | ||
39 | === modified file 'doc/php/examples/zorba_api.php' | |||
40 | --- doc/php/examples/zorba_api.php 2012-03-23 17:32:07 +0000 | |||
41 | +++ doc/php/examples/zorba_api.php 2012-03-26 20:16:18 +0000 | |||
42 | @@ -18,7 +18,7 @@ | |||
43 | 18 | // Try to load our extension if it's not already loaded. | 18 | // Try to load our extension if it's not already loaded. |
44 | 19 | if (!extension_loaded("zorba_api")) { | 19 | if (!extension_loaded("zorba_api")) { |
45 | 20 | if (strtolower(substr(PHP_OS, 0, 3)) === 'win') { | 20 | if (strtolower(substr(PHP_OS, 0, 3)) === 'win') { |
47 | 21 | if (!dl('php_zorba_api.dll')) return; | 21 | if (!dl('zorba_api.dll')) return; |
48 | 22 | } else { | 22 | } else { |
49 | 23 | // PHP_SHLIB_SUFFIX is available as of PHP 4.3.0, for older PHP assume 'so'. | 23 | // PHP_SHLIB_SUFFIX is available as of PHP 4.3.0, for older PHP assume 'so'. |
50 | 24 | // It gives 'dylib' on MacOS X which is for libraries, modules are 'so'. | 24 | // It gives 'dylib' on MacOS X which is for libraries, modules are 'so'. |
51 | 25 | 25 | ||
52 | === modified file 'doc/ruby/examples/CMakeLists.txt' | |||
53 | --- doc/ruby/examples/CMakeLists.txt 2012-03-23 17:32:07 +0000 | |||
54 | +++ doc/ruby/examples/CMakeLists.txt 2012-03-26 20:16:18 +0000 | |||
55 | @@ -18,7 +18,12 @@ | |||
56 | 18 | IF (NOT RUBY_EXECUTABLE) | 18 | IF (NOT RUBY_EXECUTABLE) |
57 | 19 | MESSAGE(STATUS "Ruby test not added because Ruby Interpreter not found.") | 19 | MESSAGE(STATUS "Ruby test not added because Ruby Interpreter not found.") |
58 | 20 | ELSE (NOT RUBY_EXECUTABLE) | 20 | ELSE (NOT RUBY_EXECUTABLE) |
60 | 21 | SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby) | 21 | MESSAGE(STATUS "RUBY_EXECUTABLE: " ${RUBY_EXECUTABLE}) |
61 | 22 | IF (MSVC_IDE) | ||
62 | 23 | SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby/@CMAKE_BUILD_TYPE@) | ||
63 | 24 | ELSE (MSVC_IDE) | ||
64 | 25 | SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby) | ||
65 | 26 | ENDIF (MSVC_IDE) | ||
66 | 22 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/ruby_test.rb.in ${CMAKE_CURRENT_BINARY_DIR}/ruby_test.rb) | 27 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/ruby_test.rb.in ${CMAKE_CURRENT_BINARY_DIR}/ruby_test.rb) |
67 | 23 | ADD_TEST("ruby" ${RUBY_EXECUTABLE} ruby_test.rb) | 28 | ADD_TEST("ruby" ${RUBY_EXECUTABLE} ruby_test.rb) |
68 | 24 | ENDIF(NOT RUBY_EXECUTABLE) | 29 | ENDIF(NOT RUBY_EXECUTABLE) |
69 | 25 | 30 | ||
70 | === added file 'swig/Collection.h' | |||
71 | --- swig/Collection.h 1970-01-01 00:00:00 +0000 | |||
72 | +++ swig/Collection.h 2012-03-26 20:16:18 +0000 | |||
73 | @@ -0,0 +1,47 @@ | |||
74 | 1 | /* | ||
75 | 2 | * Copyright 2006-2012 The FLWOR Foundation. | ||
76 | 3 | * | ||
77 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
78 | 5 | * you may not use this file except in compliance with the License. | ||
79 | 6 | * You may obtain a copy of the License at | ||
80 | 7 | * | ||
81 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
82 | 9 | * | ||
83 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
84 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
85 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
86 | 13 | * See the License for the specific language governing permissions and | ||
87 | 14 | * limitations under the License. | ||
88 | 15 | */ | ||
89 | 16 | #ifndef API_COLLECTION_H | ||
90 | 17 | #define API_COLLECTION_H | ||
91 | 18 | |||
92 | 19 | class Collection | ||
93 | 20 | { | ||
94 | 21 | private: | ||
95 | 22 | zorba::Collection* theCollection; | ||
96 | 23 | |||
97 | 24 | public: | ||
98 | 25 | Collection() : theCollection(0) {} | ||
99 | 26 | Collection(const Collection& aMgr) : theCollection(aMgr.theCollection) {} | ||
100 | 27 | Collection(zorba::Collection* aMgr) : theCollection(aMgr) {} | ||
101 | 28 | |||
102 | 29 | ItemSequence contents(); | ||
103 | 30 | void deleteNodeFirst(); | ||
104 | 31 | void deleteNodeLast(); | ||
105 | 32 | void deleteNodes(const ItemSequence &aNodes ); | ||
106 | 33 | void deleteNodesFirst(unsigned long aNumNodes ); | ||
107 | 34 | void deleteNodesLast(unsigned long aNumNodes ); | ||
108 | 35 | //std::vector< Annotation > getAnnotations(): | ||
109 | 36 | Item getName(); | ||
110 | 37 | TypeIdentifier getType(); | ||
111 | 38 | long long indexOf(const Item &aNode ); | ||
112 | 39 | void insertNodesAfter(const Item &aTarget, const ItemSequence &aNodes ); | ||
113 | 40 | void insertNodesBefore(const Item &aTarget, const ItemSequence &aNodes ); | ||
114 | 41 | void insertNodesFirst(const ItemSequence &aNodes ); | ||
115 | 42 | void insertNodesLast(const ItemSequence &aNodes ); | ||
116 | 43 | bool isStatic(); | ||
117 | 44 | //void registerDiagnosticHandler(DiagnosticHandler *aDiagnosticHandler ); | ||
118 | 45 | }; | ||
119 | 46 | |||
120 | 47 | #endif | ||
121 | 0 | \ No newline at end of file | 48 | \ No newline at end of file |
122 | 1 | 49 | ||
123 | === added file 'swig/Collection.i' | |||
124 | --- swig/Collection.i 1970-01-01 00:00:00 +0000 | |||
125 | +++ swig/Collection.i 2012-03-26 20:16:18 +0000 | |||
126 | @@ -0,0 +1,91 @@ | |||
127 | 1 | /* | ||
128 | 2 | * Copyright 2006-2012 The FLWOR Foundation. | ||
129 | 3 | * | ||
130 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
131 | 5 | * you may not use this file except in compliance with the License. | ||
132 | 6 | * You may obtain a copy of the License at | ||
133 | 7 | * | ||
134 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
135 | 9 | * | ||
136 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
137 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
138 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
139 | 13 | * See the License for the specific language governing permissions and | ||
140 | 14 | * limitations under the License. | ||
141 | 15 | */ | ||
142 | 16 | |||
143 | 17 | %{ // start Implementation | ||
144 | 18 | |||
145 | 19 | ItemSequence Collection::contents() | ||
146 | 20 | { | ||
147 | 21 | return ItemSequence( theCollection->contents() ); | ||
148 | 22 | } | ||
149 | 23 | |||
150 | 24 | void Collection::deleteNodeFirst() | ||
151 | 25 | { | ||
152 | 26 | theCollection->deleteNodeFirst(); | ||
153 | 27 | } | ||
154 | 28 | |||
155 | 29 | void Collection::deleteNodeLast() | ||
156 | 30 | { | ||
157 | 31 | theCollection->deleteNodeLast(); | ||
158 | 32 | } | ||
159 | 33 | |||
160 | 34 | void Collection::deleteNodes(const ItemSequence &aNodes ) | ||
161 | 35 | { | ||
162 | 36 | theCollection->deleteNodes( aNodes.theItemSequence ); | ||
163 | 37 | } | ||
164 | 38 | |||
165 | 39 | void Collection::deleteNodesFirst(unsigned long aNumNodes ) | ||
166 | 40 | { | ||
167 | 41 | theCollection->deleteNodesFirst(aNumNodes); | ||
168 | 42 | } | ||
169 | 43 | |||
170 | 44 | void Collection::deleteNodesLast(unsigned long aNumNodes ) | ||
171 | 45 | { | ||
172 | 46 | theCollection->deleteNodesLast(aNumNodes); | ||
173 | 47 | } | ||
174 | 48 | |||
175 | 49 | Item Collection::getName() | ||
176 | 50 | { | ||
177 | 51 | return Item( theCollection->getName() ); | ||
178 | 52 | } | ||
179 | 53 | |||
180 | 54 | TypeIdentifier Collection::getType() | ||
181 | 55 | { | ||
182 | 56 | return TypeIdentifier( theCollection->getType() ); | ||
183 | 57 | } | ||
184 | 58 | |||
185 | 59 | long long Collection::indexOf(const Item &aNode ) | ||
186 | 60 | { | ||
187 | 61 | return theCollection->indexOf( aNode.theItem ); | ||
188 | 62 | } | ||
189 | 63 | |||
190 | 64 | void Collection::insertNodesAfter(const Item &aTarget, const ItemSequence &aNodes ) | ||
191 | 65 | { | ||
192 | 66 | theCollection->insertNodesAfter( aTarget.theItem, aNodes.theItemSequence ); | ||
193 | 67 | } | ||
194 | 68 | |||
195 | 69 | void Collection::insertNodesBefore(const Item &aTarget, const ItemSequence &aNodes ) | ||
196 | 70 | { | ||
197 | 71 | theCollection->insertNodesBefore( aTarget.theItem, aNodes.theItemSequence ); | ||
198 | 72 | } | ||
199 | 73 | |||
200 | 74 | void Collection::insertNodesFirst(const ItemSequence &aNodes ) | ||
201 | 75 | { | ||
202 | 76 | theCollection->insertNodesFirst( aNodes.theItemSequence ); | ||
203 | 77 | } | ||
204 | 78 | |||
205 | 79 | void Collection::insertNodesLast(const ItemSequence &aNodes ) | ||
206 | 80 | { | ||
207 | 81 | theCollection->insertNodesLast( aNodes.theItemSequence ); | ||
208 | 82 | } | ||
209 | 83 | |||
210 | 84 | bool Collection::isStatic() | ||
211 | 85 | { | ||
212 | 86 | return theCollection->isStatic(); | ||
213 | 87 | } | ||
214 | 88 | |||
215 | 89 | %} // end Implementation | ||
216 | 90 | |||
217 | 91 | %include "Collection.h" | ||
218 | 0 | 92 | ||
219 | === added file 'swig/CollectionManager.h' | |||
220 | --- swig/CollectionManager.h 1970-01-01 00:00:00 +0000 | |||
221 | +++ swig/CollectionManager.h 2012-03-26 20:16:18 +0000 | |||
222 | @@ -0,0 +1,37 @@ | |||
223 | 1 | /* | ||
224 | 2 | * Copyright 2006-2012 The FLWOR Foundation. | ||
225 | 3 | * | ||
226 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
227 | 5 | * you may not use this file except in compliance with the License. | ||
228 | 6 | * You may obtain a copy of the License at | ||
229 | 7 | * | ||
230 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
231 | 9 | * | ||
232 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
233 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
234 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
235 | 13 | * See the License for the specific language governing permissions and | ||
236 | 14 | * limitations under the License. | ||
237 | 15 | */ | ||
238 | 16 | #ifndef API_COLLECTION_MANAGER_H | ||
239 | 17 | #define API_COLLECTION_MANAGER_H | ||
240 | 18 | |||
241 | 19 | class CollectionManager | ||
242 | 20 | { | ||
243 | 21 | private: | ||
244 | 22 | zorba::CollectionManager* theManager; | ||
245 | 23 | |||
246 | 24 | public: | ||
247 | 25 | CollectionManager() : theManager(0) {} | ||
248 | 26 | CollectionManager(const CollectionManager& aMgr) : theManager(aMgr.theManager) {} | ||
249 | 27 | CollectionManager(zorba::CollectionManager* aMgr) : theManager(aMgr) {} | ||
250 | 28 | |||
251 | 29 | ItemSequence availableCollections(); | ||
252 | 30 | void createCollection(const Item &aName ); | ||
253 | 31 | void deleteCollection(const Item &aName ); | ||
254 | 32 | Collection getCollection(const Item &aName ); | ||
255 | 33 | bool isAvailableCollection(const Item &aName ); | ||
256 | 34 | //virtual void registerDiagnosticHandler(DiagnosticHandler *aDiagnosticHandler ) | ||
257 | 35 | }; | ||
258 | 36 | |||
259 | 37 | #endif | ||
260 | 0 | \ No newline at end of file | 38 | \ No newline at end of file |
261 | 1 | 39 | ||
262 | === added file 'swig/CollectionManager.i' | |||
263 | --- swig/CollectionManager.i 1970-01-01 00:00:00 +0000 | |||
264 | +++ swig/CollectionManager.i 2012-03-26 20:16:18 +0000 | |||
265 | @@ -0,0 +1,47 @@ | |||
266 | 1 | /* | ||
267 | 2 | * Copyright 2006-2012 The FLWOR Foundation. | ||
268 | 3 | * | ||
269 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
270 | 5 | * you may not use this file except in compliance with the License. | ||
271 | 6 | * You may obtain a copy of the License at | ||
272 | 7 | * | ||
273 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
274 | 9 | * | ||
275 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
276 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
277 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
278 | 13 | * See the License for the specific language governing permissions and | ||
279 | 14 | * limitations under the License. | ||
280 | 15 | */ | ||
281 | 16 | |||
282 | 17 | %{ // start Implementation | ||
283 | 18 | |||
284 | 19 | ItemSequence CollectionManager::availableCollections() | ||
285 | 20 | { | ||
286 | 21 | return ItemSequence( theManager->availableCollections() ); | ||
287 | 22 | } | ||
288 | 23 | |||
289 | 24 | void CollectionManager::createCollection(const Item &aName ) | ||
290 | 25 | { | ||
291 | 26 | theManager->createCollection(aName.theItem ); | ||
292 | 27 | } | ||
293 | 28 | |||
294 | 29 | void CollectionManager::deleteCollection(const Item &aName ) | ||
295 | 30 | { | ||
296 | 31 | theManager->deleteCollection(aName.theItem ); | ||
297 | 32 | } | ||
298 | 33 | |||
299 | 34 | Collection CollectionManager::getCollection(const Item &aName ) | ||
300 | 35 | { | ||
301 | 36 | return Collection(theManager->getCollection(aName.theItem )); | ||
302 | 37 | } | ||
303 | 38 | |||
304 | 39 | bool CollectionManager::isAvailableCollection(const Item &aName ) | ||
305 | 40 | { | ||
306 | 41 | return theManager->isAvailableCollection(aName.theItem ); | ||
307 | 42 | } | ||
308 | 43 | |||
309 | 44 | |||
310 | 45 | %} // end Implementation | ||
311 | 46 | |||
312 | 47 | %include "CollectionManager.h" | ||
313 | 0 | 48 | ||
314 | === added file 'swig/DocumentManager.h' | |||
315 | --- swig/DocumentManager.h 1970-01-01 00:00:00 +0000 | |||
316 | +++ swig/DocumentManager.h 2012-03-26 20:16:18 +0000 | |||
317 | @@ -0,0 +1,36 @@ | |||
318 | 1 | /* | ||
319 | 2 | * Copyright 2006-2012 The FLWOR Foundation. | ||
320 | 3 | * | ||
321 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
322 | 5 | * you may not use this file except in compliance with the License. | ||
323 | 6 | * You may obtain a copy of the License at | ||
324 | 7 | * | ||
325 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
326 | 9 | * | ||
327 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
328 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
329 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
330 | 13 | * See the License for the specific language governing permissions and | ||
331 | 14 | * limitations under the License. | ||
332 | 15 | */ | ||
333 | 16 | #ifndef API_DOCUMENT_MANAGER_H | ||
334 | 17 | #define API_DOCUMENT_MANAGER_H | ||
335 | 18 | |||
336 | 19 | class DocumentManager | ||
337 | 20 | { | ||
338 | 21 | private: | ||
339 | 22 | zorba::DocumentManager* theManager; | ||
340 | 23 | |||
341 | 24 | public: | ||
342 | 25 | DocumentManager() : theManager(0) {} | ||
343 | 26 | DocumentManager(const DocumentManager& aMgr) : theManager(aMgr.theManager) {} | ||
344 | 27 | DocumentManager(zorba::DocumentManager* aMgr) : theManager(aMgr) {} | ||
345 | 28 | |||
346 | 29 | void put(const std::string& aName, Item aDoc); | ||
347 | 30 | void remove(const std::string& aName); | ||
348 | 31 | Item document(const std::string& aName); | ||
349 | 32 | bool isAvailableDocument(const std::string& aName); | ||
350 | 33 | ItemSequence availableDocuments(); | ||
351 | 34 | }; | ||
352 | 35 | |||
353 | 36 | #endif | ||
354 | 0 | \ No newline at end of file | 37 | \ No newline at end of file |
355 | 1 | 38 | ||
356 | === added file 'swig/DocumentManager.i' | |||
357 | --- swig/DocumentManager.i 1970-01-01 00:00:00 +0000 | |||
358 | +++ swig/DocumentManager.i 2012-03-26 20:16:18 +0000 | |||
359 | @@ -0,0 +1,46 @@ | |||
360 | 1 | /* | ||
361 | 2 | * Copyright 2006-2012 The FLWOR Foundation. | ||
362 | 3 | * | ||
363 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
364 | 5 | * you may not use this file except in compliance with the License. | ||
365 | 6 | * You may obtain a copy of the License at | ||
366 | 7 | * | ||
367 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
368 | 9 | * | ||
369 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
370 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
371 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
372 | 13 | * See the License for the specific language governing permissions and | ||
373 | 14 | * limitations under the License. | ||
374 | 15 | */ | ||
375 | 16 | |||
376 | 17 | %{ // start Implementation | ||
377 | 18 | void DocumentManager::put(const std::string& aName, Item aDoc) | ||
378 | 19 | { | ||
379 | 20 | theManager->put(aName, aDoc.theItem); | ||
380 | 21 | } | ||
381 | 22 | |||
382 | 23 | void DocumentManager::remove(const std::string& aName) | ||
383 | 24 | { | ||
384 | 25 | theManager->remove(aName); | ||
385 | 26 | } | ||
386 | 27 | |||
387 | 28 | Item DocumentManager::document(const std::string& aName) | ||
388 | 29 | { | ||
389 | 30 | return theManager->document(aName); | ||
390 | 31 | } | ||
391 | 32 | |||
392 | 33 | bool DocumentManager::isAvailableDocument(const std::string& aName) | ||
393 | 34 | { | ||
394 | 35 | return theManager->isAvailableDocument(aName); | ||
395 | 36 | } | ||
396 | 37 | |||
397 | 38 | ItemSequence DocumentManager::availableDocuments() | ||
398 | 39 | { | ||
399 | 40 | return ItemSequence( theManager->availableDocuments() ); | ||
400 | 41 | } | ||
401 | 42 | |||
402 | 43 | |||
403 | 44 | %} // end Implementation | ||
404 | 45 | |||
405 | 46 | %include "DocumentManager.h" | ||
406 | 0 | 47 | ||
407 | === added file 'swig/DynamicContext.h' | |||
408 | --- swig/DynamicContext.h 1970-01-01 00:00:00 +0000 | |||
409 | +++ swig/DynamicContext.h 2012-03-26 20:16:18 +0000 | |||
410 | @@ -0,0 +1,45 @@ | |||
411 | 1 | /* | ||
412 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
413 | 3 | * | ||
414 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
415 | 5 | * you may not use this file except in compliance with the License. | ||
416 | 6 | * You may obtain a copy of the License at | ||
417 | 7 | * | ||
418 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
419 | 9 | * | ||
420 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
421 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
422 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
423 | 13 | * See the License for the specific language governing permissions and | ||
424 | 14 | * limitations under the License. | ||
425 | 15 | */ | ||
426 | 16 | #ifndef API_DYNAMIC_CONTEXT_H | ||
427 | 17 | #define API_DYNAMIC_CONTEXT_H | ||
428 | 18 | |||
429 | 19 | class DynamicContext | ||
430 | 20 | { | ||
431 | 21 | private: | ||
432 | 22 | zorba::DynamicContext* theContext; | ||
433 | 23 | public: | ||
434 | 24 | |||
435 | 25 | DynamicContext():theContext(0) {} | ||
436 | 26 | DynamicContext(const DynamicContext& aCtx):theContext(aCtx.theContext) {} | ||
437 | 27 | DynamicContext(zorba::DynamicContext* aCtx):theContext(aCtx) {} | ||
438 | 28 | |||
439 | 29 | bool getContextItem (Item& aItem); | ||
440 | 30 | Item getCurrentDateTime (); | ||
441 | 31 | Item getDefaultCollection (); | ||
442 | 32 | int getImplicitTimezone (); | ||
443 | 33 | bool getVariable (const std::string& aNamespace, const std::string& aLocalname, Item& aItem, Iterator& aIterator); | ||
444 | 34 | |||
445 | 35 | bool setContextItem (Item& aItem); | ||
446 | 36 | bool setCurrentDateTime (Item& aDateTimeItem); | ||
447 | 37 | bool setDefaultCollection (Item& aCollectionUri); | ||
448 | 38 | bool setImplicitTimezone (int aTimezone); | ||
449 | 39 | bool setVariable (const std::string& aNamespace, const std::string& aLocalname, Iterator& aIter); | ||
450 | 40 | bool setVariable (const std::string& aQName, Item& aItem); | ||
451 | 41 | bool setVariable (const std::string& aQName, Iterator& aIterator); | ||
452 | 42 | |||
453 | 43 | }; | ||
454 | 44 | |||
455 | 45 | #endif | ||
456 | 0 | \ No newline at end of file | 46 | \ No newline at end of file |
457 | 1 | 47 | ||
458 | === added file 'swig/DynamicContext.i' | |||
459 | --- swig/DynamicContext.i 1970-01-01 00:00:00 +0000 | |||
460 | +++ swig/DynamicContext.i 2012-03-26 20:16:18 +0000 | |||
461 | @@ -0,0 +1,59 @@ | |||
462 | 1 | /* | ||
463 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
464 | 3 | * | ||
465 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
466 | 5 | * you may not use this file except in compliance with the License. | ||
467 | 6 | * You may obtain a copy of the License at | ||
468 | 7 | * | ||
469 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
470 | 9 | * | ||
471 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
472 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
473 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
474 | 13 | * See the License for the specific language governing permissions and | ||
475 | 14 | * limitations under the License. | ||
476 | 15 | */ | ||
477 | 16 | |||
478 | 17 | %{ // start Implementation | ||
479 | 18 | |||
480 | 19 | bool DynamicContext::getContextItem (Item& aItem) { | ||
481 | 20 | return theContext->getContextItem(aItem.theItem); | ||
482 | 21 | } | ||
483 | 22 | Item DynamicContext::getCurrentDateTime (){ | ||
484 | 23 | return Item(theContext->getCurrentDateTime()); | ||
485 | 24 | } | ||
486 | 25 | Item DynamicContext::getDefaultCollection () { | ||
487 | 26 | return Item(theContext->getDefaultCollection()); | ||
488 | 27 | } | ||
489 | 28 | int DynamicContext::getImplicitTimezone (){ | ||
490 | 29 | return theContext->getImplicitTimezone(); | ||
491 | 30 | } | ||
492 | 31 | bool DynamicContext::getVariable (const std::string& aNamespace, const std::string& aLocalname, Item& aItem, Iterator& aIterator) { | ||
493 | 32 | return theContext->getVariable(aNamespace, aLocalname, aItem.theItem, aIterator.theIterator); | ||
494 | 33 | } | ||
495 | 34 | |||
496 | 35 | bool DynamicContext::setContextItem (Item& aItem) { | ||
497 | 36 | return theContext->setContextItem(aItem.theItem); | ||
498 | 37 | } | ||
499 | 38 | bool DynamicContext::setCurrentDateTime (Item& aDateTimeItem) { | ||
500 | 39 | return theContext->setCurrentDateTime(aDateTimeItem.theItem); | ||
501 | 40 | } | ||
502 | 41 | bool DynamicContext::setDefaultCollection (Item& aCollectionUri) { | ||
503 | 42 | return theContext->setDefaultCollection(aCollectionUri.theItem); | ||
504 | 43 | } | ||
505 | 44 | bool DynamicContext::setImplicitTimezone (int aTimezone) { | ||
506 | 45 | return theContext->setImplicitTimezone(aTimezone); | ||
507 | 46 | } | ||
508 | 47 | bool DynamicContext::setVariable(const std::string& aNamespace, const std::string& aLocalname, Iterator& aIter) { | ||
509 | 48 | return theContext->setVariable(aNamespace, aLocalname, aIter.theIterator); | ||
510 | 49 | } | ||
511 | 50 | bool DynamicContext::setVariable (const std::string& aQName, Item& aItem) { | ||
512 | 51 | return theContext->setVariable (aQName, aItem.theItem); | ||
513 | 52 | } | ||
514 | 53 | bool DynamicContext::setVariable (const std::string& aQName, Iterator& aIterator) { | ||
515 | 54 | return theContext->setVariable (aQName, aIterator.theIterator); | ||
516 | 55 | } | ||
517 | 56 | |||
518 | 57 | %} // end Implementation | ||
519 | 58 | |||
520 | 59 | %include "DynamicContext.h" | ||
521 | 0 | 60 | ||
522 | === added file 'swig/Item.h' | |||
523 | --- swig/Item.h 1970-01-01 00:00:00 +0000 | |||
524 | +++ swig/Item.h 2012-03-26 20:16:18 +0000 | |||
525 | @@ -0,0 +1,68 @@ | |||
526 | 1 | /* | ||
527 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
528 | 3 | * | ||
529 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
530 | 5 | * you may not use this file except in compliance with the License. | ||
531 | 6 | * You may obtain a copy of the License at | ||
532 | 7 | * | ||
533 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
534 | 9 | * | ||
535 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
536 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
537 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
538 | 13 | * See the License for the specific language governing permissions and | ||
539 | 14 | * limitations under the License. | ||
540 | 15 | */ | ||
541 | 16 | |||
542 | 17 | #ifndef API_ITEM_H | ||
543 | 18 | #define API_ITEM_H | ||
544 | 19 | |||
545 | 20 | class Item | ||
546 | 21 | { | ||
547 | 22 | friend class Iterator; | ||
548 | 23 | friend class StaticContext; | ||
549 | 24 | friend class DocumentManager; | ||
550 | 25 | friend class SingletonIterator; | ||
551 | 26 | friend class DynamicContext; | ||
552 | 27 | friend class ItemFactory; | ||
553 | 28 | friend class Collection; | ||
554 | 29 | friend class CollectionManager; | ||
555 | 30 | private: | ||
556 | 31 | zorba::Item theItem; | ||
557 | 32 | |||
558 | 33 | public: | ||
559 | 34 | Item() {} | ||
560 | 35 | Item(const Item& aItem) : theItem(aItem.theItem) {} | ||
561 | 36 | Item(const zorba::Item& aZItem) : theItem(aZItem) {} | ||
562 | 37 | |||
563 | 38 | static Item createEmptyItem(); | ||
564 | 39 | std::string getStringValue() const; | ||
565 | 40 | std::string serialize() const; | ||
566 | 41 | std::string serialize(SerializationOptions serOptions) const; | ||
567 | 42 | Iterator getAtomizationValue () const; | ||
568 | 43 | Iterator getAttributes () const; | ||
569 | 44 | bool getBooleanValue () const; | ||
570 | 45 | Iterator getChildren () const; | ||
571 | 46 | Item getEBV () const; | ||
572 | 47 | int getIntValue () const; | ||
573 | 48 | double getDoubleValue () const; | ||
574 | 49 | long long getLongValue () const; | ||
575 | 50 | std::string getLocalName () const; | ||
576 | 51 | std::string getNamespace () const; | ||
577 | 52 | bool getNodeName (Item &aNodeName) const; | ||
578 | 53 | Item getParent () const; | ||
579 | 54 | std::string getPrefix () const; | ||
580 | 55 | Item getType () const; | ||
581 | 56 | unsigned int getUnsignedIntValue () const; | ||
582 | 57 | |||
583 | 58 | int getNodeKind() const; | ||
584 | 59 | bool isAtomic () const; | ||
585 | 60 | bool isNaN () const; | ||
586 | 61 | bool isNode () const; | ||
587 | 62 | bool isNull () const; | ||
588 | 63 | bool isPosOrNegInf () const; | ||
589 | 64 | |||
590 | 65 | void close(); | ||
591 | 66 | }; // class Item | ||
592 | 67 | |||
593 | 68 | #endif | ||
594 | 0 | 69 | ||
595 | === added file 'swig/Item.i' | |||
596 | --- swig/Item.i 1970-01-01 00:00:00 +0000 | |||
597 | +++ swig/Item.i 2012-03-26 20:16:18 +0000 | |||
598 | @@ -0,0 +1,114 @@ | |||
599 | 1 | /* | ||
600 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
601 | 3 | * | ||
602 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
603 | 5 | * you may not use this file except in compliance with the License. | ||
604 | 6 | * You may obtain a copy of the License at | ||
605 | 7 | * | ||
606 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
607 | 9 | * | ||
608 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
609 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
610 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
611 | 13 | * See the License for the specific language governing permissions and | ||
612 | 14 | * limitations under the License. | ||
613 | 15 | */ | ||
614 | 16 | |||
615 | 17 | %{ // start Implementation | ||
616 | 18 | |||
617 | 19 | Item Item::createEmptyItem() | ||
618 | 20 | { return Item(); } | ||
619 | 21 | |||
620 | 22 | std::string Item::getStringValue() const | ||
621 | 23 | { return std::string(theItem.getStringValue().c_str()); } | ||
622 | 24 | |||
623 | 25 | std::string Item::serialize() const | ||
624 | 26 | { | ||
625 | 27 | std::stringstream lStream; | ||
626 | 28 | Zorba_SerializerOptions_t lOptions; | ||
627 | 29 | lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES; | ||
628 | 30 | zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(lOptions); | ||
629 | 31 | zorba::SingletonItemSequence lSequence(theItem); | ||
630 | 32 | lSerializer->serialize(&lSequence, lStream); | ||
631 | 33 | return lStream.str(); | ||
632 | 34 | } | ||
633 | 35 | std::string Item::serialize(SerializationOptions serOptions) const | ||
634 | 36 | { | ||
635 | 37 | std::stringstream lStream; | ||
636 | 38 | serOptions.lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES; | ||
637 | 39 | zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(serOptions.lOptions); | ||
638 | 40 | zorba::SingletonItemSequence lSequence(theItem); | ||
639 | 41 | lSerializer->serialize(&lSequence, lStream); | ||
640 | 42 | return lStream.str(); | ||
641 | 43 | } | ||
642 | 44 | |||
643 | 45 | Iterator Item::getAtomizationValue () const | ||
644 | 46 | { return Iterator(theItem.getAtomizationValue()); } | ||
645 | 47 | |||
646 | 48 | Iterator Item::getAttributes () const | ||
647 | 49 | { return Iterator(theItem.getAttributes()); } | ||
648 | 50 | |||
649 | 51 | bool Item::getBooleanValue () const | ||
650 | 52 | { return theItem.getBooleanValue(); } | ||
651 | 53 | |||
652 | 54 | Iterator Item::getChildren () const | ||
653 | 55 | { return Iterator(theItem.getChildren()); } | ||
654 | 56 | |||
655 | 57 | Item Item::getEBV () const | ||
656 | 58 | { return Item(theItem.getEBV()); } | ||
657 | 59 | |||
658 | 60 | int Item::getIntValue () const | ||
659 | 61 | { return theItem.getIntValue(); } | ||
660 | 62 | |||
661 | 63 | double Item::getDoubleValue () const | ||
662 | 64 | { return theItem.getDoubleValue(); } | ||
663 | 65 | |||
664 | 66 | long long Item::getLongValue () const | ||
665 | 67 | { return theItem.getLongValue(); } | ||
666 | 68 | |||
667 | 69 | std::string Item::getLocalName () const | ||
668 | 70 | { return std::string(theItem.getLocalName().c_str()); } | ||
669 | 71 | |||
670 | 72 | std::string Item::getNamespace () const | ||
671 | 73 | { return std::string(theItem.getNamespace().c_str()); } | ||
672 | 74 | |||
673 | 75 | bool Item::getNodeName (Item &aNodeName) const | ||
674 | 76 | { return theItem.getNodeName( aNodeName.theItem ); } | ||
675 | 77 | |||
676 | 78 | Item Item::getParent () const | ||
677 | 79 | { return theItem.getParent(); } | ||
678 | 80 | |||
679 | 81 | std::string Item::getPrefix () const | ||
680 | 82 | { return std::string(theItem.getPrefix().c_str()); } | ||
681 | 83 | |||
682 | 84 | Item Item::getType () const | ||
683 | 85 | { return Item( theItem.getType() ); } | ||
684 | 86 | |||
685 | 87 | unsigned int Item::getUnsignedIntValue () const | ||
686 | 88 | { return theItem.getUnsignedIntValue(); } | ||
687 | 89 | |||
688 | 90 | bool Item::isAtomic () const | ||
689 | 91 | { return theItem.isAtomic(); } | ||
690 | 92 | |||
691 | 93 | bool Item::isNaN () const | ||
692 | 94 | { return theItem.isNaN(); } | ||
693 | 95 | |||
694 | 96 | bool Item::isNode () const | ||
695 | 97 | { return theItem.isNode(); } | ||
696 | 98 | |||
697 | 99 | bool Item::isNull () const | ||
698 | 100 | { return theItem.isNull(); } | ||
699 | 101 | |||
700 | 102 | bool Item::isPosOrNegInf () const | ||
701 | 103 | { return theItem.isPosOrNegInf(); } | ||
702 | 104 | |||
703 | 105 | int Item::getNodeKind () const | ||
704 | 106 | { return theItem.getNodeKind(); } | ||
705 | 107 | |||
706 | 108 | void Item::close() | ||
707 | 109 | { theItem.close(); } | ||
708 | 110 | |||
709 | 111 | %} // end Implementation | ||
710 | 112 | |||
711 | 113 | |||
712 | 114 | %include "Item.h" | ||
713 | 0 | 115 | ||
714 | === modified file 'swig/ItemFactory.h' | |||
715 | --- swig/ItemFactory.h 2012-03-23 17:32:07 +0000 | |||
716 | +++ swig/ItemFactory.h 2012-03-26 20:16:18 +0000 | |||
717 | @@ -1,4 +1,21 @@ | |||
719 | 1 | // Interface | 1 | /* |
720 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
721 | 3 | * | ||
722 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
723 | 5 | * you may not use this file except in compliance with the License. | ||
724 | 6 | * You may obtain a copy of the License at | ||
725 | 7 | * | ||
726 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
727 | 9 | * | ||
728 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
729 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
730 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
731 | 13 | * See the License for the specific language governing permissions and | ||
732 | 14 | * limitations under the License. | ||
733 | 15 | */ | ||
734 | 16 | |||
735 | 17 | #ifndef API_ITEM_FACTORY_H | ||
736 | 18 | #define API_ITEM_FACTORY_H | ||
737 | 2 | 19 | ||
738 | 3 | class ItemFactory | 20 | class ItemFactory |
739 | 4 | { | 21 | { |
740 | @@ -11,13 +28,16 @@ | |||
741 | 11 | ItemFactory(const ItemFactory& aItemFactory) : theItemFactory(aItemFactory.theItemFactory) {} | 28 | ItemFactory(const ItemFactory& aItemFactory) : theItemFactory(aItemFactory.theItemFactory) {} |
742 | 12 | 29 | ||
743 | 13 | Item createAnyURI (const std::string &aURI); | 30 | Item createAnyURI (const std::string &aURI); |
746 | 14 | Item createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, Item aTypedValue); | 31 | Item createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, Item& aTypedValue); |
747 | 15 | Item createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, std::vector< Item > aTypedValue); | 32 | #ifndef SWIGRUBY |
748 | 33 | Item createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, std::vector< Item > aTypedValue); | ||
749 | 34 | #endif | ||
750 | 16 | Item createBase64Binary (const char *aBinData, size_t aLength); | 35 | Item createBase64Binary (const char *aBinData, size_t aLength); |
751 | 17 | Item createBase64Binary (std::istream &aStream); | 36 | Item createBase64Binary (std::istream &aStream); |
752 | 18 | Item createBase64Binary (const unsigned char *aBinData, size_t aLength); | 37 | Item createBase64Binary (const unsigned char *aBinData, size_t aLength); |
753 | 19 | Item createBoolean (bool aValue); | 38 | Item createBoolean (bool aValue); |
754 | 20 | Item createByte (char aByte); | 39 | Item createByte (char aByte); |
755 | 40 | Item createCommentNode (Item &aParent, const std::string &aContent); | ||
756 | 21 | Item createDate (const std::string &aDate); | 41 | Item createDate (const std::string &aDate); |
757 | 22 | Item createDate (short aYear, short aMonth, short aDay); | 42 | Item createDate (short aYear, short aMonth, short aDay); |
758 | 23 | Item createDateTime (const std::string &aDateTimeValue); | 43 | Item createDateTime (const std::string &aDateTimeValue); |
759 | @@ -29,7 +49,13 @@ | |||
760 | 29 | Item createDouble (double aValue); | 49 | Item createDouble (double aValue); |
761 | 30 | Item createDuration (const std::string &aValue); | 50 | Item createDuration (const std::string &aValue); |
762 | 31 | Item createDuration (short aYear, short aMonths, short aDays, short aHours, short aMinutes, double aSeconds); | 51 | Item createDuration (short aYear, short aMonths, short aDays, short aHours, short aMinutes, double aSeconds); |
764 | 32 | //Item createElementNode (Item &aParent, Item aNodeName, Item aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings); | 52 | Item createDayTimeDuration (const std::string &aValue); |
765 | 53 | Item createYearMonthDuration (const std::string &aValue); | ||
766 | 54 | Item createDocumentNode (const std::string &aBaseUri, const std::string &aDocUri); | ||
767 | 55 | #ifndef SWIGRUBY | ||
768 | 56 | Item createElementNode (Item &aParent, Item &aNodeName, Item &aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings); | ||
769 | 57 | #endif | ||
770 | 58 | Item createElementNode (Item &aParent, Item &aNodeName, Item &aTypeName, bool aHasTypedValue, bool aHasEmptyValue); | ||
771 | 33 | Item createFloat (const std::string &aValue); | 59 | Item createFloat (const std::string &aValue); |
772 | 34 | Item createFloat (float aValue); | 60 | Item createFloat (float aValue); |
773 | 35 | Item createGDay (const std::string &aValue); | 61 | Item createGDay (const std::string &aValue); |
774 | @@ -51,6 +77,7 @@ | |||
775 | 51 | Item createNegativeInteger (long long aValue); | 77 | Item createNegativeInteger (long long aValue); |
776 | 52 | Item createNonNegativeInteger (unsigned long long aValue); | 78 | Item createNonNegativeInteger (unsigned long long aValue); |
777 | 53 | Item createNonPositiveInteger (long long aValue); | 79 | Item createNonPositiveInteger (long long aValue); |
778 | 80 | Item createPiNode (Item &aParent, const std::string &aTarget, const std::string &aContent, const std::string &aBaseUri); | ||
779 | 54 | Item createPositiveInteger (unsigned long long aValue); | 81 | Item createPositiveInteger (unsigned long long aValue); |
780 | 55 | Item createQName (const std::string &aNamespace, const std::string &aPrefix, const std::string &aLocalname); | 82 | Item createQName (const std::string &aNamespace, const std::string &aPrefix, const std::string &aLocalname); |
781 | 56 | Item createQName (const std::string &aNamespace, const std::string &aLocalname); | 83 | Item createQName (const std::string &aNamespace, const std::string &aLocalname); |
782 | @@ -58,7 +85,7 @@ | |||
783 | 58 | Item createShort (short aShort); | 85 | Item createShort (short aShort); |
784 | 59 | //Item createStreamableString (std::istream &stream, StreamReleaser streamReleaser, bool seekable=false); | 86 | //Item createStreamableString (std::istream &stream, StreamReleaser streamReleaser, bool seekable=false); |
785 | 60 | Item createString (const std::string &aString); | 87 | Item createString (const std::string &aString); |
787 | 61 | Item createTextNode (Item parent, std::string content); | 88 | Item createTextNode (Item &aParent, const std::string &aContent); |
788 | 62 | Item createTime (short aHour, short aMinute, double aSecond, short aTimeZone_hours); | 89 | Item createTime (short aHour, short aMinute, double aSecond, short aTimeZone_hours); |
789 | 63 | Item createTime (short aHour, short aMinute, double aSecond); | 90 | Item createTime (short aHour, short aMinute, double aSecond); |
790 | 64 | Item createTime (const std::string &aValue); | 91 | Item createTime (const std::string &aValue); |
791 | @@ -67,3 +94,5 @@ | |||
792 | 67 | Item createUnsignedLong (unsigned long long aValue); | 94 | Item createUnsignedLong (unsigned long long aValue); |
793 | 68 | Item createUnsignedShort (unsigned short aValue); | 95 | Item createUnsignedShort (unsigned short aValue); |
794 | 69 | }; // class ItemFactory | 96 | }; // class ItemFactory |
795 | 97 | |||
796 | 98 | #endif | ||
797 | 70 | \ No newline at end of file | 99 | \ No newline at end of file |
798 | 71 | 100 | ||
799 | === modified file 'swig/ItemFactory.i' | |||
800 | --- swig/ItemFactory.i 2012-03-23 17:32:07 +0000 | |||
801 | +++ swig/ItemFactory.i 2012-03-26 20:16:18 +0000 | |||
802 | @@ -7,11 +7,12 @@ | |||
803 | 7 | return Item(theItemFactory->createAnyURI(aURI)); | 7 | return Item(theItemFactory->createAnyURI(aURI)); |
804 | 8 | } | 8 | } |
805 | 9 | 9 | ||
807 | 10 | Item ItemFactory::createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, Item aTypedValue){ | 10 | Item ItemFactory::createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, Item& aTypedValue){ |
808 | 11 | return Item( theItemFactory->createAttributeNode( aParent.theItem, aNodeName.theItem, aTypeName.theItem, aTypedValue.theItem )); | 11 | return Item( theItemFactory->createAttributeNode( aParent.theItem, aNodeName.theItem, aTypeName.theItem, aTypedValue.theItem )); |
809 | 12 | } | 12 | } |
810 | 13 | 13 | ||
812 | 14 | Item ItemFactory::createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, std::vector< Item > aTypedValue){ | 14 | #ifndef SWIGRUBY |
813 | 15 | Item ItemFactory::createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, std::vector< Item > aTypedValue){ | ||
814 | 15 | 16 | ||
815 | 16 | std::vector< zorba::Item > typedValue; | 17 | std::vector< zorba::Item > typedValue; |
816 | 17 | typedValue.reserve(aTypedValue.size()); | 18 | typedValue.reserve(aTypedValue.size()); |
817 | @@ -21,6 +22,7 @@ | |||
818 | 21 | } | 22 | } |
819 | 22 | return Item( theItemFactory->createAttributeNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, typedValue )); | 23 | return Item( theItemFactory->createAttributeNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, typedValue )); |
820 | 23 | } | 24 | } |
821 | 25 | #endif | ||
822 | 24 | 26 | ||
823 | 25 | Item ItemFactory::createBase64Binary (const char *aBinData, size_t aLength){ | 27 | Item ItemFactory::createBase64Binary (const char *aBinData, size_t aLength){ |
824 | 26 | return Item( theItemFactory->createBase64Binary(aBinData, aLength)); | 28 | return Item( theItemFactory->createBase64Binary(aBinData, aLength)); |
825 | @@ -37,6 +39,10 @@ | |||
826 | 37 | Item ItemFactory::createByte (char aByte){ | 39 | Item ItemFactory::createByte (char aByte){ |
827 | 38 | return Item( theItemFactory->createByte(aByte)); | 40 | return Item( theItemFactory->createByte(aByte)); |
828 | 39 | } | 41 | } |
829 | 42 | Item ItemFactory::createCommentNode (Item &aParent, const std::string &aContent){ | ||
830 | 43 | zorba::String lContent = zorba::String(aContent); | ||
831 | 44 | return Item( theItemFactory->createCommentNode (aParent.theItem, lContent)); | ||
832 | 45 | } | ||
833 | 40 | Item ItemFactory::createDate (const std::string &aDate){ | 46 | Item ItemFactory::createDate (const std::string &aDate){ |
834 | 41 | return Item( theItemFactory->createDate(aDate)); | 47 | return Item( theItemFactory->createDate(aDate)); |
835 | 42 | } | 48 | } |
836 | @@ -70,11 +76,32 @@ | |||
837 | 70 | Item ItemFactory::createDuration (short aYear, short aMonths, short aDays, short aHours, short aMinutes, double aSeconds){ | 76 | Item ItemFactory::createDuration (short aYear, short aMonths, short aDays, short aHours, short aMinutes, double aSeconds){ |
838 | 71 | return Item( theItemFactory->createDuration (aYear, aMonths, aDays, aHours, aMinutes, aSeconds)); | 77 | return Item( theItemFactory->createDuration (aYear, aMonths, aDays, aHours, aMinutes, aSeconds)); |
839 | 72 | } | 78 | } |
845 | 73 | /* | 79 | Item ItemFactory::createDayTimeDuration (const std::string &aValue){ |
846 | 74 | Item ItemFactory::createElementNode (Item &aParent, Item aNodeName, Item aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings){ | 80 | return Item( theItemFactory->createDayTimeDuration (aValue)); |
847 | 75 | return Item( theItemFactory->createElementNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, aHasTypedValue, aHasEmptyValue, aNsBindings)); | 81 | } |
848 | 76 | } | 82 | Item ItemFactory::createYearMonthDuration (const std::string &aValue){ |
849 | 77 | */ | 83 | return Item( theItemFactory->createYearMonthDuration (aValue)); |
850 | 84 | } | ||
851 | 85 | Item ItemFactory::createDocumentNode (const std::string &aBaseUri, const std::string &aDocUri){ | ||
852 | 86 | return Item( theItemFactory->createDocumentNode (aBaseUri, aDocUri)); | ||
853 | 87 | } | ||
854 | 88 | #ifndef SWIGRUBY | ||
855 | 89 | Item ItemFactory::createElementNode (Item &aParent, Item& aNodeName, Item& aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings){ | ||
856 | 90 | std::vector< std::pair< zorba::String, zorba::String > > items; | ||
857 | 91 | items.reserve(aNsBindings.size()); | ||
858 | 92 | std::vector< std::pair< std::string, std::string > >::iterator iter; | ||
859 | 93 | for(iter = aNsBindings.begin(); iter != aNsBindings.end(); iter++) { | ||
860 | 94 | std::pair< zorba::String, zorba::String > pair; | ||
861 | 95 | pair.first = (*iter).first; | ||
862 | 96 | pair.second = (*iter).second; | ||
863 | 97 | items.push_back(pair); | ||
864 | 98 | } | ||
865 | 99 | return Item( theItemFactory->createElementNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, aHasTypedValue, aHasEmptyValue, items)); | ||
866 | 100 | } | ||
867 | 101 | #endif | ||
868 | 102 | Item ItemFactory::createElementNode (Item &aParent, Item& aNodeName, Item& aTypeName, bool aHasTypedValue, bool aHasEmptyValue){ | ||
869 | 103 | return Item( theItemFactory->createElementNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, aHasTypedValue, aHasEmptyValue, std::vector<std::pair<zorba::String, zorba::String> >())); | ||
870 | 104 | } | ||
871 | 78 | Item ItemFactory::createFloat (const std::string &aValue){ | 105 | Item ItemFactory::createFloat (const std::string &aValue){ |
872 | 79 | return Item( theItemFactory->createFloat (aValue)); | 106 | return Item( theItemFactory->createFloat (aValue)); |
873 | 80 | } | 107 | } |
874 | @@ -138,6 +165,12 @@ | |||
875 | 138 | Item ItemFactory::createNonPositiveInteger (long long aValue){ | 165 | Item ItemFactory::createNonPositiveInteger (long long aValue){ |
876 | 139 | return Item( theItemFactory->createNonPositiveInteger (aValue)); | 166 | return Item( theItemFactory->createNonPositiveInteger (aValue)); |
877 | 140 | } | 167 | } |
878 | 168 | Item ItemFactory::createPiNode (Item &aParent, const std::string &aTarget, const std::string &aContent, const std::string &aBaseUri){ | ||
879 | 169 | zorba::String lTarget = zorba::String(aTarget); | ||
880 | 170 | zorba::String lContent = zorba::String(aContent); | ||
881 | 171 | zorba::String lBaseUri = zorba::String(aBaseUri); | ||
882 | 172 | return Item( theItemFactory->createPiNode (aParent.theItem, lTarget, lContent, lBaseUri)); | ||
883 | 173 | } | ||
884 | 141 | Item ItemFactory::createPositiveInteger (unsigned long long aValue){ | 174 | Item ItemFactory::createPositiveInteger (unsigned long long aValue){ |
885 | 142 | return Item( theItemFactory->createPositiveInteger (aValue)); | 175 | return Item( theItemFactory->createPositiveInteger (aValue)); |
886 | 143 | } | 176 | } |
887 | @@ -161,8 +194,9 @@ | |||
888 | 161 | Item ItemFactory::createString (const std::string &aString){ | 194 | Item ItemFactory::createString (const std::string &aString){ |
889 | 162 | return Item( theItemFactory->createString (aString)); | 195 | return Item( theItemFactory->createString (aString)); |
890 | 163 | } | 196 | } |
893 | 164 | Item ItemFactory::createTextNode (Item parent, std::string content){ | 197 | Item ItemFactory::createTextNode (Item &aParent, const std::string &aContent){ |
894 | 165 | return Item( theItemFactory->createTextNode (parent.theItem, content)); | 198 | zorba::String lContent = zorba::String(aContent); |
895 | 199 | return Item( theItemFactory->createTextNode (aParent.theItem, lContent)); | ||
896 | 166 | } | 200 | } |
897 | 167 | Item ItemFactory::createTime (short aHour, short aMinute, double aSecond, short aTimeZone_hours){ | 201 | Item ItemFactory::createTime (short aHour, short aMinute, double aSecond, short aTimeZone_hours){ |
898 | 168 | return Item( theItemFactory->createTime (aHour, aMinute, aSecond, aTimeZone_hours)); | 202 | return Item( theItemFactory->createTime (aHour, aMinute, aSecond, aTimeZone_hours)); |
899 | @@ -189,4 +223,4 @@ | |||
900 | 189 | 223 | ||
901 | 190 | %} // end Implementation | 224 | %} // end Implementation |
902 | 191 | 225 | ||
903 | 192 | %include "ItemFactory.h" | ||
904 | 193 | \ No newline at end of file | 226 | \ No newline at end of file |
905 | 227 | %include "ItemFactory.h" | ||
906 | 194 | 228 | ||
907 | === added file 'swig/ItemSequence.h' | |||
908 | --- swig/ItemSequence.h 1970-01-01 00:00:00 +0000 | |||
909 | +++ swig/ItemSequence.h 2012-03-26 20:16:18 +0000 | |||
910 | @@ -0,0 +1,32 @@ | |||
911 | 1 | /* | ||
912 | 2 | * Copyright 2006-2012 The FLWOR Foundation. | ||
913 | 3 | * | ||
914 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
915 | 5 | * you may not use this file except in compliance with the License. | ||
916 | 6 | * You may obtain a copy of the License at | ||
917 | 7 | * | ||
918 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
919 | 9 | * | ||
920 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
921 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
922 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
923 | 13 | * See the License for the specific language governing permissions and | ||
924 | 14 | * limitations under the License. | ||
925 | 15 | */ | ||
926 | 16 | #ifndef API_ITEM_SEQUENCE_H | ||
927 | 17 | #define API_ITEM_SEQUENCE_H | ||
928 | 18 | |||
929 | 19 | class ItemSequence | ||
930 | 20 | { | ||
931 | 21 | friend class Collection; | ||
932 | 22 | private: | ||
933 | 23 | zorba::ItemSequence_t theItemSequence; | ||
934 | 24 | |||
935 | 25 | public: | ||
936 | 26 | ItemSequence(const ItemSequence& aItemSequence) : theItemSequence(aItemSequence.theItemSequence) {} | ||
937 | 27 | ItemSequence(zorba::ItemSequence_t aItemSequence) : theItemSequence(aItemSequence) {} | ||
938 | 28 | Iterator getIterator(); | ||
939 | 29 | |||
940 | 30 | }; | ||
941 | 31 | |||
942 | 32 | #endif | ||
943 | 0 | \ No newline at end of file | 33 | \ No newline at end of file |
944 | 1 | 34 | ||
945 | === added file 'swig/ItemSequence.i' | |||
946 | --- swig/ItemSequence.i 1970-01-01 00:00:00 +0000 | |||
947 | +++ swig/ItemSequence.i 2012-03-26 20:16:18 +0000 | |||
948 | @@ -0,0 +1,26 @@ | |||
949 | 1 | /* | ||
950 | 2 | * Copyright 2006-2012 The FLWOR Foundation. | ||
951 | 3 | * | ||
952 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
953 | 5 | * you may not use this file except in compliance with the License. | ||
954 | 6 | * You may obtain a copy of the License at | ||
955 | 7 | * | ||
956 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
957 | 9 | * | ||
958 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
959 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
960 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
961 | 13 | * See the License for the specific language governing permissions and | ||
962 | 14 | * limitations under the License. | ||
963 | 15 | */ | ||
964 | 16 | |||
965 | 17 | %{ // start Implementation | ||
966 | 18 | |||
967 | 19 | Iterator ItemSequence::getIterator() | ||
968 | 20 | { | ||
969 | 21 | return Iterator( theItemSequence->getIterator() ); | ||
970 | 22 | } | ||
971 | 23 | |||
972 | 24 | %} // end Implementation | ||
973 | 25 | |||
974 | 26 | %include "ItemSequence.h" | ||
975 | 0 | 27 | ||
976 | === added file 'swig/Iterator.h' | |||
977 | --- swig/Iterator.h 1970-01-01 00:00:00 +0000 | |||
978 | +++ swig/Iterator.h 2012-03-26 20:16:18 +0000 | |||
979 | @@ -0,0 +1,57 @@ | |||
980 | 1 | /* | ||
981 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
982 | 3 | * | ||
983 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
984 | 5 | * you may not use this file except in compliance with the License. | ||
985 | 6 | * You may obtain a copy of the License at | ||
986 | 7 | * | ||
987 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
988 | 9 | * | ||
989 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
990 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
991 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
992 | 13 | * See the License for the specific language governing permissions and | ||
993 | 14 | * limitations under the License. | ||
994 | 15 | */ | ||
995 | 16 | #ifndef API_ITERATOR_H | ||
996 | 17 | #define API_ITERATOR_H | ||
997 | 18 | |||
998 | 19 | class Iterator | ||
999 | 20 | { | ||
1000 | 21 | protected: | ||
1001 | 22 | friend class DynamicContext; | ||
1002 | 23 | friend class DocumentManager; | ||
1003 | 24 | friend class CollectionManager; | ||
1004 | 25 | friend class Collection; | ||
1005 | 26 | friend class StaticContext; | ||
1006 | 27 | friend class XQuery; | ||
1007 | 28 | friend class ItemSequence; | ||
1008 | 29 | zorba::Iterator_t theIterator; | ||
1009 | 30 | zorba::Item theItem; | ||
1010 | 31 | bool theConsumed; | ||
1011 | 32 | public: | ||
1012 | 33 | // constructors | ||
1013 | 34 | Iterator() {} | ||
1014 | 35 | Iterator(const Iterator& anIterator) | ||
1015 | 36 | : theIterator(anIterator.theIterator), | ||
1016 | 37 | theItem(anIterator.theItem), | ||
1017 | 38 | theConsumed(false) | ||
1018 | 39 | {} | ||
1019 | 40 | Iterator(zorba::Iterator_t anIterator) | ||
1020 | 41 | : theIterator(anIterator), | ||
1021 | 42 | theConsumed(false) | ||
1022 | 43 | {} | ||
1023 | 44 | Iterator(zorba::Item& aItem) | ||
1024 | 45 | : theIterator(0), | ||
1025 | 46 | theItem(aItem), | ||
1026 | 47 | theConsumed(false) | ||
1027 | 48 | {} | ||
1028 | 49 | |||
1029 | 50 | void open(); | ||
1030 | 51 | bool isOpen(); | ||
1031 | 52 | bool next(Item&); | ||
1032 | 53 | void close(); | ||
1033 | 54 | void destroy(); | ||
1034 | 55 | }; // class Iterator | ||
1035 | 56 | |||
1036 | 57 | #endif | ||
1037 | 0 | \ No newline at end of file | 58 | \ No newline at end of file |
1038 | 1 | 59 | ||
1039 | === added file 'swig/Iterator.i' | |||
1040 | --- swig/Iterator.i 1970-01-01 00:00:00 +0000 | |||
1041 | +++ swig/Iterator.i 2012-03-26 20:16:18 +0000 | |||
1042 | @@ -0,0 +1,69 @@ | |||
1043 | 1 | /* | ||
1044 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
1045 | 3 | * | ||
1046 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1047 | 5 | * you may not use this file except in compliance with the License. | ||
1048 | 6 | * You may obtain a copy of the License at | ||
1049 | 7 | * | ||
1050 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1051 | 9 | * | ||
1052 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
1053 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1054 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1055 | 13 | * See the License for the specific language governing permissions and | ||
1056 | 14 | * limitations under the License. | ||
1057 | 15 | */ | ||
1058 | 16 | |||
1059 | 17 | %{ // start Implementation | ||
1060 | 18 | |||
1061 | 19 | void Iterator::open() | ||
1062 | 20 | { | ||
1063 | 21 | if (theIterator) | ||
1064 | 22 | theIterator->open(); | ||
1065 | 23 | theConsumed = false; | ||
1066 | 24 | } | ||
1067 | 25 | |||
1068 | 26 | bool Iterator::isOpen() | ||
1069 | 27 | { | ||
1070 | 28 | if (theIterator) | ||
1071 | 29 | return theIterator->isOpen(); | ||
1072 | 30 | else | ||
1073 | 31 | return !theConsumed; | ||
1074 | 32 | } | ||
1075 | 33 | |||
1076 | 34 | void Iterator::close() | ||
1077 | 35 | { | ||
1078 | 36 | if (theIterator) | ||
1079 | 37 | theIterator->close(); | ||
1080 | 38 | theConsumed = true; | ||
1081 | 39 | } | ||
1082 | 40 | |||
1083 | 41 | void Iterator::destroy() | ||
1084 | 42 | { | ||
1085 | 43 | theIterator = 0; | ||
1086 | 44 | } | ||
1087 | 45 | |||
1088 | 46 | bool Iterator::next(Item& aItem) | ||
1089 | 47 | { | ||
1090 | 48 | if (theIterator) | ||
1091 | 49 | { | ||
1092 | 50 | return theIterator->next(aItem.theItem); | ||
1093 | 51 | } | ||
1094 | 52 | else | ||
1095 | 53 | { | ||
1096 | 54 | if (!theConsumed) | ||
1097 | 55 | { | ||
1098 | 56 | aItem = theItem; | ||
1099 | 57 | return true; | ||
1100 | 58 | } | ||
1101 | 59 | else | ||
1102 | 60 | { | ||
1103 | 61 | return false; | ||
1104 | 62 | } | ||
1105 | 63 | } | ||
1106 | 64 | } | ||
1107 | 65 | |||
1108 | 66 | |||
1109 | 67 | %} // end Implementation | ||
1110 | 68 | |||
1111 | 69 | %include "Iterator.h" | ||
1112 | 0 | 70 | ||
1113 | === added file 'swig/SerializationOptions.h' | |||
1114 | --- swig/SerializationOptions.h 1970-01-01 00:00:00 +0000 | |||
1115 | +++ swig/SerializationOptions.h 2012-03-26 20:16:18 +0000 | |||
1116 | @@ -0,0 +1,114 @@ | |||
1117 | 1 | /* | ||
1118 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
1119 | 3 | * | ||
1120 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1121 | 5 | * you may not use this file except in compliance with the License. | ||
1122 | 6 | * You may obtain a copy of the License at | ||
1123 | 7 | * | ||
1124 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1125 | 9 | * | ||
1126 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
1127 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1128 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1129 | 13 | * See the License for the specific language governing permissions and | ||
1130 | 14 | * limitations under the License. | ||
1131 | 15 | */ | ||
1132 | 16 | |||
1133 | 17 | #ifndef API_SERIALIZATION_OPTIONS_H | ||
1134 | 18 | #define API_SERIALIZATION_OPTIONS_H | ||
1135 | 19 | |||
1136 | 20 | class SerializationOptions | ||
1137 | 21 | { | ||
1138 | 22 | friend class Item; | ||
1139 | 23 | |||
1140 | 24 | public: | ||
1141 | 25 | typedef enum | ||
1142 | 26 | { | ||
1143 | 27 | ZORBA_API_SERIALIZATION_METHOD_XML, | ||
1144 | 28 | ZORBA_API_SERIALIZATION_METHOD_HTML, | ||
1145 | 29 | ZORBA_API_SERIALIZATION_METHOD_XHTML, | ||
1146 | 30 | ZORBA_API_SERIALIZATION_METHOD_TEXT, | ||
1147 | 31 | ZORBA_API_SERIALIZATION_METHOD_BINARY | ||
1148 | 32 | } SerializationMethod; | ||
1149 | 33 | |||
1150 | 34 | typedef enum | ||
1151 | 35 | { | ||
1152 | 36 | ZORBA_API_BYTE_ORDER_MARK_YES, | ||
1153 | 37 | ZORBA_API_BYTE_ORDER_MARK_NO | ||
1154 | 38 | } ByteOrderMark; | ||
1155 | 39 | |||
1156 | 40 | |||
1157 | 41 | typedef enum | ||
1158 | 42 | { | ||
1159 | 43 | ZORBA_API_ESCAPE_URI_ATTRIBUTES_YES, | ||
1160 | 44 | ZORBA_API_ESCAPE_URI_ATTRIBUTES_NO | ||
1161 | 45 | } EscapeUriAttributes; | ||
1162 | 46 | |||
1163 | 47 | typedef enum { | ||
1164 | 48 | ZORBA_API_INCLUDE_CONTENT_TYPE_YES, | ||
1165 | 49 | ZORBA_API_INCLUDE_CONTENT_TYPE_NO | ||
1166 | 50 | } IncludeContentType; | ||
1167 | 51 | |||
1168 | 52 | typedef enum { | ||
1169 | 53 | ZORBA_API_INDENT_YES, | ||
1170 | 54 | ZORBA_API_INDENT_NO | ||
1171 | 55 | } Indent; | ||
1172 | 56 | |||
1173 | 57 | typedef enum { | ||
1174 | 58 | ZORBA_API_NORMALIZATION_FORM_NFC, | ||
1175 | 59 | ZORBA_API_NORMALIZATION_FORM_NFD, | ||
1176 | 60 | ZORBA_API_NORMALIZATION_FORM_NFKC, | ||
1177 | 61 | ZORBA_API_NORMALIZATION_FORM_NFKD, | ||
1178 | 62 | ZORBA_API_NORMALIZATION_FORM_FULLY_normalized, | ||
1179 | 63 | ZORBA_API_NORMALIZATION_FORM_NONE | ||
1180 | 64 | } NormalizationForm; | ||
1181 | 65 | |||
1182 | 66 | typedef enum { | ||
1183 | 67 | ZORBA_API_OMIT_XML_DECLARATION_YES, | ||
1184 | 68 | ZORBA_API_OMIT_XML_DECLARATION_NO | ||
1185 | 69 | } OmitXMLDeclaration; | ||
1186 | 70 | |||
1187 | 71 | typedef enum { | ||
1188 | 72 | ZORBA_API_STANDALONE_YES, | ||
1189 | 73 | ZORBA_API_STANDALONE_NO, | ||
1190 | 74 | ZORBA_API_STANDALONE_OMIT | ||
1191 | 75 | } Standalone; | ||
1192 | 76 | |||
1193 | 77 | typedef enum { | ||
1194 | 78 | ZORBA_API_UNDECLARE_PREFIXES_YES, | ||
1195 | 79 | ZORBA_API_UNDECLARE_PREFIXES_NO | ||
1196 | 80 | } UndeclarePrefixes; | ||
1197 | 81 | |||
1198 | 82 | |||
1199 | 83 | private: | ||
1200 | 84 | Zorba_SerializerOptions_t lOptions; | ||
1201 | 85 | |||
1202 | 86 | public: | ||
1203 | 87 | /* | ||
1204 | 88 | * Default values: | ||
1205 | 89 | * - serialization method: XML | ||
1206 | 90 | * - byte order mark: NO | ||
1207 | 91 | * - esacpe uri attributes: NO | ||
1208 | 92 | * - include content type: NO | ||
1209 | 93 | * - indent: NO | ||
1210 | 94 | * - normalization form: none | ||
1211 | 95 | * - omit xml declaration: NO | ||
1212 | 96 | * - standalone: omit | ||
1213 | 97 | * - undeclare prefixes: NO | ||
1214 | 98 | */ | ||
1215 | 99 | |||
1216 | 100 | |||
1217 | 101 | void setSerializationMethod ( SerializationMethod aSerializationMethod ); | ||
1218 | 102 | void setByteOrderMark ( ByteOrderMark aByteOrderMark ); | ||
1219 | 103 | void setEscapeUriAttributes ( EscapeUriAttributes aEscapeUriAttributes ); | ||
1220 | 104 | void setIncludeContentType ( IncludeContentType aIncludeContentType ); | ||
1221 | 105 | void setIndent ( Indent aIndent ); | ||
1222 | 106 | void setNormalizationForm ( NormalizationForm aNormalizationForm ); | ||
1223 | 107 | void setOmitXMLDeclaration ( OmitXMLDeclaration aOmitXMLDeclaration ); | ||
1224 | 108 | void setStandalone ( Standalone aStandalone ); | ||
1225 | 109 | void setUndeclarePrefixes ( UndeclarePrefixes aUndeclarePrefixes ); | ||
1226 | 110 | void setSerializerOption(const std::string ¶meter, const std::string &value); | ||
1227 | 111 | |||
1228 | 112 | }; // class SerializationOptions | ||
1229 | 113 | |||
1230 | 114 | #endif | ||
1231 | 0 | 115 | ||
1232 | === added file 'swig/SerializationOptions.i' | |||
1233 | --- swig/SerializationOptions.i 1970-01-01 00:00:00 +0000 | |||
1234 | +++ swig/SerializationOptions.i 2012-03-26 20:16:18 +0000 | |||
1235 | @@ -0,0 +1,125 @@ | |||
1236 | 1 | /* | ||
1237 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
1238 | 3 | * | ||
1239 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1240 | 5 | * you may not use this file except in compliance with the License. | ||
1241 | 6 | * You may obtain a copy of the License at | ||
1242 | 7 | * | ||
1243 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1244 | 9 | * | ||
1245 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
1246 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1247 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1248 | 13 | * See the License for the specific language governing permissions and | ||
1249 | 14 | * limitations under the License. | ||
1250 | 15 | */ | ||
1251 | 16 | |||
1252 | 17 | %{ // start Implementation | ||
1253 | 18 | |||
1254 | 19 | void SerializationOptions::setSerializationMethod ( SerializationMethod aSerializationMethod ) { | ||
1255 | 20 | switch (aSerializationMethod) { | ||
1256 | 21 | case ZORBA_API_SERIALIZATION_METHOD_HTML: | ||
1257 | 22 | lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_HTML; | ||
1258 | 23 | break; | ||
1259 | 24 | case ZORBA_API_SERIALIZATION_METHOD_XHTML: | ||
1260 | 25 | lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_XHTML; | ||
1261 | 26 | break; | ||
1262 | 27 | case ZORBA_API_SERIALIZATION_METHOD_TEXT: | ||
1263 | 28 | lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_TEXT; | ||
1264 | 29 | break; | ||
1265 | 30 | case ZORBA_API_SERIALIZATION_METHOD_BINARY: | ||
1266 | 31 | lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_BINARY; | ||
1267 | 32 | break; | ||
1268 | 33 | case ZORBA_API_SERIALIZATION_METHOD_XML: | ||
1269 | 34 | default: | ||
1270 | 35 | lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_XML; | ||
1271 | 36 | break; | ||
1272 | 37 | } | ||
1273 | 38 | } | ||
1274 | 39 | void SerializationOptions::setByteOrderMark ( ByteOrderMark aByteOrderMark ) { | ||
1275 | 40 | if (aByteOrderMark == ZORBA_API_BYTE_ORDER_MARK_YES) { | ||
1276 | 41 | lOptions.byte_order_mark = ZORBA_BYTE_ORDER_MARK_YES; | ||
1277 | 42 | } else { | ||
1278 | 43 | lOptions.byte_order_mark = ZORBA_BYTE_ORDER_MARK_NO; | ||
1279 | 44 | } | ||
1280 | 45 | } | ||
1281 | 46 | void SerializationOptions::setEscapeUriAttributes ( EscapeUriAttributes aEscapeUriAttributes ) { | ||
1282 | 47 | if (aEscapeUriAttributes == ZORBA_API_ESCAPE_URI_ATTRIBUTES_YES) { | ||
1283 | 48 | lOptions.escape_uri_attributes = ZORBA_ESCAPE_URI_ATTRIBUTES_YES; | ||
1284 | 49 | } else { | ||
1285 | 50 | lOptions.escape_uri_attributes = ZORBA_ESCAPE_URI_ATTRIBUTES_NO; | ||
1286 | 51 | } | ||
1287 | 52 | } | ||
1288 | 53 | void SerializationOptions::setIncludeContentType ( IncludeContentType aIncludeContentType ) { | ||
1289 | 54 | if (aIncludeContentType == ZORBA_API_INCLUDE_CONTENT_TYPE_YES) { | ||
1290 | 55 | lOptions.include_content_type = ZORBA_INCLUDE_CONTENT_TYPE_YES; | ||
1291 | 56 | } else { | ||
1292 | 57 | lOptions.include_content_type = ZORBA_INCLUDE_CONTENT_TYPE_NO; | ||
1293 | 58 | } | ||
1294 | 59 | } | ||
1295 | 60 | void SerializationOptions::setIndent ( Indent aIndent ) { | ||
1296 | 61 | if (aIndent == ZORBA_API_INDENT_YES) { | ||
1297 | 62 | lOptions.indent = ZORBA_INDENT_YES; | ||
1298 | 63 | } else { | ||
1299 | 64 | lOptions.indent = ZORBA_INDENT_NO; | ||
1300 | 65 | } | ||
1301 | 66 | } | ||
1302 | 67 | void SerializationOptions::setNormalizationForm ( NormalizationForm aNormalizationForm ) { | ||
1303 | 68 | switch (aNormalizationForm) { | ||
1304 | 69 | case ZORBA_API_NORMALIZATION_FORM_NFC: | ||
1305 | 70 | lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NFC; | ||
1306 | 71 | break; | ||
1307 | 72 | case ZORBA_API_NORMALIZATION_FORM_NFD: | ||
1308 | 73 | lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NFD; | ||
1309 | 74 | break; | ||
1310 | 75 | case ZORBA_API_NORMALIZATION_FORM_NFKC: | ||
1311 | 76 | lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NFKC; | ||
1312 | 77 | break; | ||
1313 | 78 | case ZORBA_API_NORMALIZATION_FORM_NFKD: | ||
1314 | 79 | lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NFKD; | ||
1315 | 80 | break; | ||
1316 | 81 | case ZORBA_API_NORMALIZATION_FORM_FULLY_normalized: | ||
1317 | 82 | lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_FULLY_normalized; | ||
1318 | 83 | break; | ||
1319 | 84 | case ZORBA_API_NORMALIZATION_FORM_NONE: | ||
1320 | 85 | default: | ||
1321 | 86 | lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NONE; | ||
1322 | 87 | break; | ||
1323 | 88 | } | ||
1324 | 89 | } | ||
1325 | 90 | void SerializationOptions::setOmitXMLDeclaration ( OmitXMLDeclaration aOmitXMLDeclaration ) { | ||
1326 | 91 | if (aOmitXMLDeclaration == ZORBA_API_OMIT_XML_DECLARATION_YES) { | ||
1327 | 92 | lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES; | ||
1328 | 93 | } else { | ||
1329 | 94 | lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_NO; | ||
1330 | 95 | } | ||
1331 | 96 | } | ||
1332 | 97 | void SerializationOptions::setStandalone ( Standalone aStandalone ) { | ||
1333 | 98 | switch (aStandalone) { | ||
1334 | 99 | case ZORBA_API_STANDALONE_YES: | ||
1335 | 100 | lOptions.standalone = ZORBA_STANDALONE_YES; | ||
1336 | 101 | break; | ||
1337 | 102 | case ZORBA_API_STANDALONE_NO: | ||
1338 | 103 | lOptions.standalone = ZORBA_STANDALONE_NO; | ||
1339 | 104 | break; | ||
1340 | 105 | case ZORBA_API_STANDALONE_OMIT: | ||
1341 | 106 | default: | ||
1342 | 107 | lOptions.standalone = ZORBA_STANDALONE_OMIT; | ||
1343 | 108 | break; | ||
1344 | 109 | } | ||
1345 | 110 | } | ||
1346 | 111 | void SerializationOptions::setUndeclarePrefixes ( UndeclarePrefixes aUndeclarePrefixes ) { | ||
1347 | 112 | if (aUndeclarePrefixes == ZORBA_API_UNDECLARE_PREFIXES_YES) { | ||
1348 | 113 | lOptions.undeclare_prefixes = ZORBA_UNDECLARE_PREFIXES_YES; | ||
1349 | 114 | } else { | ||
1350 | 115 | lOptions.undeclare_prefixes = ZORBA_UNDECLARE_PREFIXES_NO; | ||
1351 | 116 | } | ||
1352 | 117 | } | ||
1353 | 118 | |||
1354 | 119 | void SerializationOptions::setSerializerOption(const std::string ¶meter, const std::string &value) { | ||
1355 | 120 | lOptions.SetSerializerOption(parameter.c_str(), value.c_str()); | ||
1356 | 121 | } | ||
1357 | 122 | |||
1358 | 123 | %} // end Implementation | ||
1359 | 124 | |||
1360 | 125 | %include "SerializationOptions.h" | ||
1361 | 0 | 126 | ||
1362 | === modified file 'swig/StaticContext.h' | |||
1363 | --- swig/StaticContext.h 2012-03-23 17:32:07 +0000 | |||
1364 | +++ swig/StaticContext.h 2012-03-26 20:16:18 +0000 | |||
1365 | @@ -1,5 +1,69 @@ | |||
1366 | 1 | /* | ||
1367 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
1368 | 3 | * | ||
1369 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1370 | 5 | * you may not use this file except in compliance with the License. | ||
1371 | 6 | * You may obtain a copy of the License at | ||
1372 | 7 | * | ||
1373 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1374 | 9 | * | ||
1375 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
1376 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1377 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1378 | 13 | * See the License for the specific language governing permissions and | ||
1379 | 14 | * limitations under the License. | ||
1380 | 15 | */ | ||
1381 | 16 | #ifndef API_STATIC_CONTEXT_H | ||
1382 | 17 | #define API_STATIC_CONTEXT_H | ||
1383 | 18 | |||
1384 | 1 | #include <zorba/static_context_consts.h> | 19 | #include <zorba/static_context_consts.h> |
1385 | 2 | 20 | ||
1386 | 21 | class ZorbaConstants | ||
1387 | 22 | { | ||
1388 | 23 | public: | ||
1389 | 24 | typedef enum { | ||
1390 | 25 | PRESERVE, | ||
1391 | 26 | NO_PRESERVE | ||
1392 | 27 | } PreserveMode; | ||
1393 | 28 | |||
1394 | 29 | typedef enum { | ||
1395 | 30 | INHERIT, | ||
1396 | 31 | NO_INHERIT | ||
1397 | 32 | } InheritMode; | ||
1398 | 33 | |||
1399 | 34 | typedef enum { | ||
1400 | 35 | PRESERVE_SPACE, | ||
1401 | 36 | STRIP_SPACE | ||
1402 | 37 | } BoundarySpaceMode; | ||
1403 | 38 | |||
1404 | 39 | typedef enum { | ||
1405 | 40 | PRESERVE_CONSTRUCTION, | ||
1406 | 41 | STRIP_CONSTRUCTION | ||
1407 | 42 | } ConstructionMode; | ||
1408 | 43 | |||
1409 | 44 | typedef enum { | ||
1410 | 45 | EMPTY_GREATEST, | ||
1411 | 46 | EMPTY_LEAST | ||
1412 | 47 | } OrderEmptyMode; | ||
1413 | 48 | |||
1414 | 49 | typedef enum { | ||
1415 | 50 | ORDERED, | ||
1416 | 51 | UNORDERED | ||
1417 | 52 | } OrderingMode; | ||
1418 | 53 | |||
1419 | 54 | typedef enum { | ||
1420 | 55 | VALIDATE_SKIP, | ||
1421 | 56 | VALIDATE_LAX, | ||
1422 | 57 | VALIDATE_STRICT | ||
1423 | 58 | } RevalidationMode; | ||
1424 | 59 | |||
1425 | 60 | typedef enum { | ||
1426 | 61 | XPATH2_0, | ||
1427 | 62 | XPATH1_0 | ||
1428 | 63 | } XPath1_0CompatibleMode; | ||
1429 | 64 | |||
1430 | 65 | }; // ZorbaConstants | ||
1431 | 66 | |||
1432 | 3 | class StaticContext | 67 | class StaticContext |
1433 | 4 | { | 68 | { |
1434 | 5 | friend class Zorba; | 69 | friend class Zorba; |
1435 | @@ -8,62 +72,73 @@ | |||
1436 | 8 | private: | 72 | private: |
1437 | 9 | zorba::StaticContext_t theStaticContext; | 73 | zorba::StaticContext_t theStaticContext; |
1438 | 10 | public: | 74 | public: |
1440 | 11 | StaticContext(); | 75 | |
1441 | 12 | StaticContext(const StaticContext& aStaticContext); | 76 | StaticContext(const StaticContext& aStaticContext); |
1442 | 13 | StaticContext(zorba::StaticContext_t aStaticContext); | 77 | StaticContext(zorba::StaticContext_t aStaticContext); |
1443 | 14 | 78 | ||
1446 | 15 | virtual void addColation(const std::string& aURI); | 79 | void addColation(const std::string& aURI); |
1447 | 16 | virtual bool addNamespace(const std::string& aPrefix, | 80 | bool addNamespace(const std::string& aPrefix, |
1448 | 17 | const std::string& aURI); | 81 | const std::string& aURI); |
1451 | 18 | void addReference() const; | 82 | |
1452 | 19 | virtual bool containsFunction(const std::string &aFnNameUri, | 83 | bool containsFunction(const std::string &aFnNameUri, |
1453 | 20 | const std::string &aFnNameLocal, | 84 | const std::string &aFnNameLocal, |
1454 | 21 | int arity) const; | 85 | int arity) const; |
1455 | 22 | 86 | ||
1458 | 23 | virtual StaticContext createChildContext() const; | 87 | StaticContext createChildContext() const; |
1459 | 24 | virtual void declareOption(const Item &aQName, | 88 | void declareOption(const Item &aQName, |
1460 | 25 | const std::string &aOptionVal); | 89 | const std::string &aOptionVal); |
1501 | 26 | virtual void disableFunction(const Item &aQName, int arity); | 90 | void disableFunction(const Item &aQName, int arity); |
1502 | 27 | 91 | ||
1503 | 28 | virtual void free (); | 92 | std::string getBaseURI () const; |
1504 | 29 | virtual std::string getBaseURI () const; | 93 | |
1505 | 30 | virtual zorba::boundary_space_mode_t getBoundarySpacePolicy () const; | 94 | ZorbaConstants::BoundarySpaceMode getBoundarySpacePolicy (); |
1506 | 31 | 95 | ZorbaConstants::ConstructionMode getConstructionMode(); | |
1507 | 32 | virtual zorba::construction_mode_t getConstructionMode () const; | 96 | ZorbaConstants::PreserveMode getCopyNamespacesModePreserve(); |
1508 | 33 | virtual void getCopyNamespacesMode (zorba::preserve_mode_t &aPreserve, zorba::inherit_mode_t &aInherit) const; | 97 | ZorbaConstants::InheritMode getCopyNamespacesModeInherit(); |
1509 | 34 | virtual std::string getDefaultCollation () const; | 98 | ZorbaConstants::OrderEmptyMode getDefaultOrderForEmptySequences(); |
1510 | 35 | virtual std::string getDefaultElementAndTypeNamespace () const; | 99 | ZorbaConstants::OrderingMode getOrderingMode(); |
1511 | 36 | virtual std::string getDefaultFunctionNamespace () const; | 100 | ZorbaConstants::RevalidationMode getRevalidationMode(); |
1512 | 37 | virtual zorba::order_empty_mode_t getDefaultOrderForEmptySequences () const; | 101 | ZorbaConstants::XPath1_0CompatibleMode getXPath1_0CompatibMode(); |
1513 | 38 | 102 | ||
1514 | 39 | virtual std::string getNamespaceURIByPrefix(const std::string &aPrefix) const; | 103 | std::string getDefaultCollation () const; |
1515 | 40 | virtual bool getOption(const Item &aQName, std::string &aOptionValue) const; | 104 | std::string getDefaultElementAndTypeNamespace () const; |
1516 | 41 | virtual zorba::ordering_mode_t getOrderingMode() const; | 105 | std::string getDefaultFunctionNamespace () const; |
1517 | 42 | long getRefCount() const; | 106 | |
1518 | 43 | virtual zorba::validation_mode_t getRevalidationMode(); | 107 | std::vector< std::pair< std::string, std::string > > getNamespaceBindings (); |
1519 | 44 | virtual zorba::xpath1_0compatib_mode_t getXPath1_0CompatibMode () const; | 108 | |
1520 | 45 | virtual void loadProlog (const std::string & aProlog, | 109 | std::string getNamespaceURIByPrefix(const std::string &aPrefix) const; |
1521 | 46 | const CompilerHints &hints); | 110 | bool getOption(const Item &aQName, std::string &aOptionValue) const; |
1522 | 47 | 111 | void loadProlog (const std::string & aProlog, const CompilerHints &hints); | |
1523 | 48 | void removeReference (); | 112 | |
1524 | 49 | virtual void resetTraceStream (); | 113 | void getExternalVariables(Iterator& vars) const; |
1525 | 50 | virtual bool setBaseURI (const std::string &aBaseURI); | 114 | |
1526 | 51 | virtual bool setBoundarySpacePolicy (zorba::boundary_space_mode_t aMode); | 115 | TypeIdentifier getCollectionType(const std::string &aCollectionUri); |
1527 | 52 | 116 | TypeIdentifier getDocumentType(const std::string &aDocUri); | |
1528 | 53 | virtual bool setConstructionMode (zorba::construction_mode_t aMode); | 117 | TypeIdentifier getContextItemStaticType(); |
1529 | 54 | 118 | ||
1530 | 55 | virtual bool setCopyNamespacesMode (zorba::preserve_mode_t aPreserve, | 119 | void setContextItemStaticType(const TypeIdentifier &aType); |
1531 | 56 | zorba::inherit_mode_t aInherit); | 120 | |
1532 | 57 | virtual void setDefaultCollation (const std::string &aURI); | 121 | void resetTraceStream (); |
1533 | 58 | virtual bool setDefaultElementAndTypeNamespace (const std::string &aURI); | 122 | bool setBaseURI (const std::string &aBaseURI); |
1534 | 59 | virtual bool setDefaultFunctionNamespace (const std::string &aURI); | 123 | |
1535 | 60 | virtual bool setDefaultOrderForEmptySequences (zorba::order_empty_mode_t aMode); | 124 | bool setBoundarySpacePolicy (ZorbaConstants::BoundarySpaceMode aMode); |
1536 | 61 | 125 | bool setConstructionMode (ZorbaConstants::ConstructionMode aMode); | |
1537 | 62 | virtual bool setOrderingMode (zorba::ordering_mode_t aMode); | 126 | bool setCopyNamespacesMode (ZorbaConstants::PreserveMode aPreserve, ZorbaConstants::InheritMode aInherit); |
1538 | 63 | virtual void setRevalidationMode (zorba::validation_mode_t aMode); | 127 | bool setDefaultOrderForEmptySequences (ZorbaConstants::OrderEmptyMode aMode); |
1539 | 64 | 128 | bool setOrderingMode (ZorbaConstants::OrderingMode aMode); | |
1540 | 65 | virtual bool setXPath1_0CompatibMode (zorba::xpath1_0compatib_mode_t aMode); | 129 | void setRevalidationMode (ZorbaConstants::RevalidationMode aMode); |
1541 | 130 | |||
1542 | 131 | void setURIPath(std::vector< std::string > &aURIPath ); | ||
1543 | 132 | void setLIBPath(std::vector< std::string > &aLIBPath ); | ||
1544 | 133 | void setModulePath(std::vector< std::string > &aModulePath ); | ||
1545 | 134 | |||
1546 | 135 | bool setXPath1_0CompatibMode (ZorbaConstants::XPath1_0CompatibleMode aMode); | ||
1547 | 136 | |||
1548 | 137 | void setDefaultCollation (const std::string &aURI); | ||
1549 | 138 | bool setDefaultElementAndTypeNamespace (const std::string &aURI); | ||
1550 | 139 | bool setDefaultFunctionNamespace (const std::string &aURI); | ||
1551 | 66 | 140 | ||
1552 | 67 | void destroy(); | 141 | void destroy(); |
1553 | 68 | }; // class StaticContext | 142 | }; // class StaticContext |
1554 | 69 | 143 | ||
1555 | 144 | #endif | ||
1556 | 70 | \ No newline at end of file | 145 | \ No newline at end of file |
1557 | 71 | 146 | ||
1558 | === modified file 'swig/StaticContext.i' | |||
1559 | --- swig/StaticContext.i 2012-03-23 17:32:07 +0000 | |||
1560 | +++ swig/StaticContext.i 2012-03-26 20:16:18 +0000 | |||
1561 | @@ -20,8 +20,6 @@ | |||
1562 | 20 | #include <zorba/static_context_consts.h> | 20 | #include <zorba/static_context_consts.h> |
1563 | 21 | 21 | ||
1564 | 22 | 22 | ||
1565 | 23 | StaticContext::StaticContext() {} | ||
1566 | 24 | |||
1567 | 25 | StaticContext::StaticContext(const StaticContext& aStaticContext) : | 23 | StaticContext::StaticContext(const StaticContext& aStaticContext) : |
1568 | 26 | theStaticContext(aStaticContext.theStaticContext) {} | 24 | theStaticContext(aStaticContext.theStaticContext) {} |
1569 | 27 | 25 | ||
1570 | @@ -31,65 +29,94 @@ | |||
1571 | 31 | void StaticContext::addColation(const std::string& aURI) | 29 | void StaticContext::addColation(const std::string& aURI) |
1572 | 32 | { theStaticContext->addCollation(aURI); } | 30 | { theStaticContext->addCollation(aURI); } |
1573 | 33 | 31 | ||
1576 | 34 | bool StaticContext::addNamespace(const std::string& aPrefix, | 32 | bool StaticContext::addNamespace(const std::string& aPrefix, const std::string& aURI) |
1575 | 35 | const std::string& aURI) | ||
1577 | 36 | { return theStaticContext->addNamespace(aPrefix, aURI); } | 33 | { return theStaticContext->addNamespace(aPrefix, aURI); } |
1578 | 37 | 34 | ||
1587 | 38 | void StaticContext::addReference() const | 35 | bool StaticContext::containsFunction(const std::string &aFnNameUri, const std::string &aFnNameLocal, int arity) const |
1588 | 39 | { theStaticContext->addReference(); } | 36 | { return theStaticContext->containsFunction(aFnNameUri, aFnNameLocal, arity); } |
1581 | 40 | |||
1582 | 41 | bool StaticContext::containsFunction(const std::string &aFnNameUri, | ||
1583 | 42 | const std::string &aFnNameLocal, | ||
1584 | 43 | int arity) const | ||
1585 | 44 | { return theStaticContext->containsFunction(aFnNameUri, aFnNameLocal, | ||
1586 | 45 | arity); } | ||
1589 | 46 | 37 | ||
1590 | 47 | StaticContext StaticContext::createChildContext() const | 38 | StaticContext StaticContext::createChildContext() const |
1591 | 48 | { return StaticContext(theStaticContext->createChildContext()); } | 39 | { return StaticContext(theStaticContext->createChildContext()); } |
1592 | 49 | 40 | ||
1595 | 50 | void StaticContext::declareOption (const Item &aQName, | 41 | void StaticContext::declareOption (const Item &aQName, const std::string &aOptionVal) |
1594 | 51 | const std::string &aOptionVal) | ||
1596 | 52 | { return theStaticContext->declareOption(aQName.theItem, aOptionVal); } | 42 | { return theStaticContext->declareOption(aQName.theItem, aOptionVal); } |
1597 | 53 | 43 | ||
1598 | 54 | void StaticContext::disableFunction (const Item &aQName, int arity) | 44 | void StaticContext::disableFunction (const Item &aQName, int arity) |
1599 | 55 | { theStaticContext->disableFunction( aQName.theItem, arity); } | 45 | { theStaticContext->disableFunction( aQName.theItem, arity); } |
1600 | 56 | 46 | ||
1601 | 57 | void StaticContext::free () | ||
1602 | 58 | { theStaticContext->free(); } | ||
1603 | 59 | |||
1604 | 60 | std::string StaticContext::getBaseURI () const | 47 | std::string StaticContext::getBaseURI () const |
1605 | 61 | { return std::string(theStaticContext->getBaseURI().c_str()); } | 48 | { return std::string(theStaticContext->getBaseURI().c_str()); } |
1606 | 62 | 49 | ||
1615 | 63 | zorba::boundary_space_mode_t StaticContext::getBoundarySpacePolicy() const | 50 | ZorbaConstants::BoundarySpaceMode StaticContext::getBoundarySpacePolicy() |
1616 | 64 | { return theStaticContext->getBoundarySpacePolicy(); } | 51 | { |
1617 | 65 | 52 | ZorbaConstants::BoundarySpaceMode result = ZorbaConstants::PRESERVE_SPACE; | |
1618 | 66 | zorba::construction_mode_t StaticContext::getConstructionMode () const | 53 | zorba::boundary_space_mode_t boundary = theStaticContext->getBoundarySpacePolicy(); |
1619 | 67 | { return theStaticContext->getConstructionMode(); } | 54 | if (boundary == zorba::strip_space) { |
1620 | 68 | 55 | result = ZorbaConstants::STRIP_SPACE; | |
1621 | 69 | void StaticContext::getCopyNamespacesMode (zorba::preserve_mode_t &aPreserve, zorba::inherit_mode_t &aInherit) const | 56 | } |
1622 | 70 | { return theStaticContext->getCopyNamespacesMode(aPreserve, aInherit); } | 57 | return result; |
1623 | 58 | } | ||
1624 | 59 | |||
1625 | 60 | ZorbaConstants::ConstructionMode StaticContext::getConstructionMode() | ||
1626 | 61 | { | ||
1627 | 62 | ZorbaConstants::ConstructionMode result = ZorbaConstants::STRIP_CONSTRUCTION; | ||
1628 | 63 | zorba::construction_mode_t construction = theStaticContext->getConstructionMode(); | ||
1629 | 64 | if (construction == zorba::preserve_cons) { | ||
1630 | 65 | result = ZorbaConstants::PRESERVE_CONSTRUCTION; | ||
1631 | 66 | } | ||
1632 | 67 | return result; | ||
1633 | 68 | } | ||
1634 | 69 | |||
1635 | 70 | ZorbaConstants::PreserveMode StaticContext::getCopyNamespacesModePreserve() | ||
1636 | 71 | { | ||
1637 | 72 | zorba::preserve_mode_t lPreserve; | ||
1638 | 73 | zorba::inherit_mode_t lInherit; | ||
1639 | 74 | ZorbaConstants::PreserveMode aPreserve = ZorbaConstants::NO_PRESERVE; | ||
1640 | 75 | theStaticContext->getCopyNamespacesMode(lPreserve, lInherit); | ||
1641 | 76 | if (lPreserve==zorba::preserve_ns) { | ||
1642 | 77 | aPreserve = ZorbaConstants::PRESERVE; | ||
1643 | 78 | } | ||
1644 | 79 | return aPreserve; | ||
1645 | 80 | } | ||
1646 | 81 | |||
1647 | 82 | ZorbaConstants::InheritMode StaticContext::getCopyNamespacesModeInherit() | ||
1648 | 83 | { | ||
1649 | 84 | zorba::preserve_mode_t lPreserve; | ||
1650 | 85 | zorba::inherit_mode_t lInherit; | ||
1651 | 86 | ZorbaConstants::InheritMode aInherit = ZorbaConstants::NO_INHERIT; | ||
1652 | 87 | theStaticContext->getCopyNamespacesMode(lPreserve, lInherit); | ||
1653 | 88 | if (lInherit==zorba::inherit_ns) { | ||
1654 | 89 | aInherit = ZorbaConstants::INHERIT; | ||
1655 | 90 | } | ||
1656 | 91 | return aInherit; | ||
1657 | 92 | } | ||
1658 | 71 | 93 | ||
1659 | 72 | std::string StaticContext::getDefaultCollation () const | 94 | std::string StaticContext::getDefaultCollation () const |
1660 | 73 | { return std::string(theStaticContext->getDefaultCollation().c_str()); } | 95 | { return std::string(theStaticContext->getDefaultCollation().c_str()); } |
1661 | 74 | 96 | ||
1662 | 75 | std::string StaticContext::getDefaultElementAndTypeNamespace () const | 97 | std::string StaticContext::getDefaultElementAndTypeNamespace () const |
1663 | 76 | { | 98 | { |
1666 | 77 | return std::string(theStaticContext->getDefaultElementAndTypeNamespace(). | 99 | return std::string( theStaticContext->getDefaultElementAndTypeNamespace().c_str() ); |
1665 | 78 | c_str()); | ||
1667 | 79 | } | 100 | } |
1668 | 80 | 101 | ||
1669 | 81 | std::string StaticContext::getDefaultFunctionNamespace () const | 102 | std::string StaticContext::getDefaultFunctionNamespace () const |
1670 | 82 | { | 103 | { |
1672 | 83 | return std::string(theStaticContext->getDefaultFunctionNamespace().c_str()); | 104 | return std::string( theStaticContext->getDefaultFunctionNamespace().c_str() ); |
1673 | 84 | } | 105 | } |
1674 | 85 | 106 | ||
1677 | 86 | zorba::order_empty_mode_t StaticContext::getDefaultOrderForEmptySequences() const | 107 | ZorbaConstants::OrderEmptyMode StaticContext::getDefaultOrderForEmptySequences() |
1678 | 87 | { return theStaticContext->getDefaultOrderForEmptySequences(); } | 108 | { |
1679 | 109 | ZorbaConstants::OrderEmptyMode result = ZorbaConstants::EMPTY_GREATEST; | ||
1680 | 110 | zorba::order_empty_mode_t order = theStaticContext->getDefaultOrderForEmptySequences(); | ||
1681 | 111 | if (order == zorba::empty_least) { | ||
1682 | 112 | result = ZorbaConstants::EMPTY_LEAST; | ||
1683 | 113 | } | ||
1684 | 114 | return result; | ||
1685 | 115 | } | ||
1686 | 88 | 116 | ||
1687 | 89 | std::string StaticContext::getNamespaceURIByPrefix(const std::string &aPrefix) const | 117 | std::string StaticContext::getNamespaceURIByPrefix(const std::string &aPrefix) const |
1688 | 90 | { | 118 | { |
1691 | 91 | return std::string(theStaticContext->getNamespaceURIByPrefix(aPrefix). | 119 | return std::string( theStaticContext->getNamespaceURIByPrefix(aPrefix).c_str() ); |
1690 | 92 | c_str()); | ||
1692 | 93 | } | 120 | } |
1693 | 94 | 121 | ||
1694 | 95 | bool StaticContext::getOption(const Item &aQName, std::string &aOptionValue) const | 122 | bool StaticContext::getOption(const Item &aQName, std::string &aOptionValue) const |
1695 | @@ -98,40 +125,108 @@ | |||
1696 | 98 | return theStaticContext->getOption(aQName.theItem, optVal); | 125 | return theStaticContext->getOption(aQName.theItem, optVal); |
1697 | 99 | } | 126 | } |
1698 | 100 | 127 | ||
1713 | 101 | zorba::ordering_mode_t StaticContext::getOrderingMode () const | 128 | ZorbaConstants::OrderingMode StaticContext::getOrderingMode () |
1714 | 102 | { return theStaticContext->getOrderingMode(); } | 129 | { |
1715 | 103 | 130 | ZorbaConstants::OrderingMode result = ZorbaConstants::ORDERED; | |
1716 | 104 | long StaticContext::getRefCount () const | 131 | zorba::ordering_mode_t order = theStaticContext->getOrderingMode(); |
1717 | 105 | { return theStaticContext->getRefCount(); } | 132 | if (order == zorba::unordered) { |
1718 | 106 | 133 | result = ZorbaConstants::UNORDERED; | |
1719 | 107 | zorba::validation_mode_t StaticContext::getRevalidationMode () | 134 | } |
1720 | 108 | { return theStaticContext->getRevalidationMode(); } | 135 | return result; |
1721 | 109 | 136 | } | |
1722 | 110 | zorba::xpath1_0compatib_mode_t StaticContext::getXPath1_0CompatibMode () const | 137 | |
1723 | 111 | { return theStaticContext->getXPath1_0CompatibMode(); } | 138 | ZorbaConstants::RevalidationMode StaticContext::getRevalidationMode () |
1724 | 112 | 139 | { | |
1725 | 113 | void StaticContext::loadProlog (const std::string & aProlog, | 140 | ZorbaConstants::RevalidationMode result = ZorbaConstants::VALIDATE_SKIP; |
1726 | 114 | const CompilerHints &hints) | 141 | zorba::validation_mode_t revalidation = theStaticContext->getRevalidationMode(); |
1727 | 142 | if (revalidation == zorba::validate_lax) { | ||
1728 | 143 | result = ZorbaConstants::VALIDATE_LAX; | ||
1729 | 144 | } else if (revalidation == zorba::validate_strict) { | ||
1730 | 145 | result = ZorbaConstants::VALIDATE_STRICT; | ||
1731 | 146 | } | ||
1732 | 147 | return result; | ||
1733 | 148 | } | ||
1734 | 149 | |||
1735 | 150 | ZorbaConstants::XPath1_0CompatibleMode StaticContext::getXPath1_0CompatibMode () | ||
1736 | 151 | { | ||
1737 | 152 | ZorbaConstants::XPath1_0CompatibleMode result = ZorbaConstants::XPATH2_0; | ||
1738 | 153 | zorba::xpath1_0compatib_mode_t comp = theStaticContext->getXPath1_0CompatibMode(); | ||
1739 | 154 | if (comp == zorba::xpath1_0) { | ||
1740 | 155 | result = ZorbaConstants::XPATH1_0; | ||
1741 | 156 | } | ||
1742 | 157 | return result; | ||
1743 | 158 | } | ||
1744 | 159 | |||
1745 | 160 | void StaticContext::loadProlog (const std::string & aProlog, const CompilerHints &hints) | ||
1746 | 115 | { theStaticContext->loadProlog( aProlog, hints.theCompilerHints); } | 161 | { theStaticContext->loadProlog( aProlog, hints.theCompilerHints); } |
1747 | 116 | 162 | ||
1751 | 117 | void StaticContext::removeReference () | 163 | void StaticContext::getExternalVariables(Iterator& vars) const |
1752 | 118 | { theStaticContext->removeReference(); } | 164 | { theStaticContext->getExternalVariables( vars.theIterator ); } |
1753 | 119 | 165 | ||
1754 | 166 | TypeIdentifier StaticContext::getCollectionType(const std::string & aCollectionUri) | ||
1755 | 167 | { return TypeIdentifier(theStaticContext->getCollectionType(aCollectionUri)); } | ||
1756 | 168 | |||
1757 | 169 | TypeIdentifier StaticContext::getDocumentType(const std::string &aDocUri) | ||
1758 | 170 | { return TypeIdentifier(theStaticContext->getDocumentType(aDocUri)); } | ||
1759 | 171 | |||
1760 | 172 | TypeIdentifier StaticContext::getContextItemStaticType() | ||
1761 | 173 | { return TypeIdentifier(theStaticContext->getContextItemStaticType()); } | ||
1762 | 174 | |||
1763 | 175 | std::vector< std::pair< std::string, std::string > > StaticContext::getNamespaceBindings () { | ||
1764 | 176 | std::vector< std::pair< zorba::String, zorba::String > > items; | ||
1765 | 177 | std::vector< std::pair< std::string, std::string > > result; | ||
1766 | 178 | theStaticContext->getNamespaceBindings(items); | ||
1767 | 179 | std::vector< std::pair< zorba::String, zorba::String > >::iterator iter; | ||
1768 | 180 | for(iter = items.begin(); iter != items.end(); iter++) { | ||
1769 | 181 | std::pair< std::string, std::string > pair; | ||
1770 | 182 | pair.first = (*iter).first.c_str(); | ||
1771 | 183 | pair.second = (*iter).second.c_str(); | ||
1772 | 184 | result.push_back(pair); | ||
1773 | 185 | } | ||
1774 | 186 | return result; | ||
1775 | 187 | } | ||
1776 | 188 | |||
1777 | 189 | |||
1778 | 190 | |||
1779 | 191 | void StaticContext::setContextItemStaticType(const TypeIdentifier &aType) | ||
1780 | 192 | { theStaticContext->setContextItemStaticType(aType.theTypeIdentifier); } | ||
1781 | 193 | |||
1782 | 120 | void StaticContext::resetTraceStream () | 194 | void StaticContext::resetTraceStream () |
1783 | 121 | { theStaticContext->resetTraceStream(); } | 195 | { theStaticContext->resetTraceStream(); } |
1784 | 122 | 196 | ||
1785 | 123 | bool StaticContext::setBaseURI (const std::string &aBaseURI) | 197 | bool StaticContext::setBaseURI (const std::string &aBaseURI) |
1786 | 124 | { return theStaticContext->setBaseURI(aBaseURI); } | 198 | { return theStaticContext->setBaseURI(aBaseURI); } |
1787 | 125 | 199 | ||
1797 | 126 | bool StaticContext::setBoundarySpacePolicy (zorba::boundary_space_mode_t aMode) | 200 | bool StaticContext::setBoundarySpacePolicy (ZorbaConstants::BoundarySpaceMode aMode) |
1798 | 127 | { return theStaticContext->setBoundarySpacePolicy(aMode); } | 201 | { |
1799 | 128 | 202 | zorba::boundary_space_mode_t lMode = zorba::strip_space; | |
1800 | 129 | bool StaticContext::setConstructionMode (zorba::construction_mode_t aMode) | 203 | if (aMode == ZorbaConstants::PRESERVE_SPACE) { |
1801 | 130 | { return theStaticContext->setConstructionMode(aMode); } | 204 | lMode = zorba::preserve_space; |
1802 | 131 | 205 | } | |
1803 | 132 | bool StaticContext::setCopyNamespacesMode (zorba::preserve_mode_t aPreserve, | 206 | return theStaticContext->setBoundarySpacePolicy(lMode); |
1804 | 133 | zorba::inherit_mode_t aInherit) | 207 | } |
1805 | 134 | { return theStaticContext->setCopyNamespacesMode(aPreserve, aInherit); } | 208 | |
1806 | 209 | bool StaticContext::setConstructionMode (ZorbaConstants::ConstructionMode aMode) | ||
1807 | 210 | { | ||
1808 | 211 | zorba::construction_mode_t lMode = zorba::preserve_cons; | ||
1809 | 212 | if (aMode == ZorbaConstants::STRIP_CONSTRUCTION) { | ||
1810 | 213 | lMode = zorba::strip_cons; | ||
1811 | 214 | } | ||
1812 | 215 | return theStaticContext->setConstructionMode(lMode); | ||
1813 | 216 | } | ||
1814 | 217 | |||
1815 | 218 | bool StaticContext::setCopyNamespacesMode (ZorbaConstants::PreserveMode aPreserve, ZorbaConstants::InheritMode aInherit) | ||
1816 | 219 | { | ||
1817 | 220 | zorba::preserve_mode_t lPreserve = zorba::no_preserve_ns; | ||
1818 | 221 | zorba::inherit_mode_t lInherit = zorba::no_inherit_ns; | ||
1819 | 222 | if (aPreserve == ZorbaConstants::PRESERVE) { | ||
1820 | 223 | lPreserve = zorba::preserve_ns; | ||
1821 | 224 | } | ||
1822 | 225 | if (aInherit == ZorbaConstants::INHERIT) { | ||
1823 | 226 | lInherit = zorba::inherit_ns; | ||
1824 | 227 | } | ||
1825 | 228 | return theStaticContext->setCopyNamespacesMode(lPreserve, lInherit); | ||
1826 | 229 | } | ||
1827 | 135 | 230 | ||
1828 | 136 | void StaticContext::setDefaultCollation (const std::string &aURI) | 231 | void StaticContext::setDefaultCollation (const std::string &aURI) |
1829 | 137 | { theStaticContext->setDefaultCollation(aURI); } | 232 | { theStaticContext->setDefaultCollation(aURI); } |
1830 | @@ -142,17 +237,76 @@ | |||
1831 | 142 | bool StaticContext::setDefaultFunctionNamespace (const std::string &aURI) | 237 | bool StaticContext::setDefaultFunctionNamespace (const std::string &aURI) |
1832 | 143 | { return theStaticContext->setDefaultFunctionNamespace(aURI); } | 238 | { return theStaticContext->setDefaultFunctionNamespace(aURI); } |
1833 | 144 | 239 | ||
1845 | 145 | bool StaticContext::setDefaultOrderForEmptySequences (zorba::order_empty_mode_t aMode) | 240 | bool StaticContext::setDefaultOrderForEmptySequences (ZorbaConstants::OrderEmptyMode aMode) |
1846 | 146 | { return theStaticContext->setDefaultOrderForEmptySequences(aMode); } | 241 | { |
1847 | 147 | 242 | zorba::order_empty_mode_t lMode = zorba::empty_greatest; | |
1848 | 148 | bool StaticContext::setOrderingMode (zorba::ordering_mode_t aMode) | 243 | if (aMode == ZorbaConstants::EMPTY_LEAST) { |
1849 | 149 | { return theStaticContext->setOrderingMode(aMode); } | 244 | lMode = zorba::empty_least; |
1850 | 150 | 245 | } | |
1851 | 151 | void StaticContext::setRevalidationMode (zorba::validation_mode_t aMode) | 246 | return theStaticContext->setDefaultOrderForEmptySequences(lMode); |
1852 | 152 | { return theStaticContext->setRevalidationMode(aMode); } | 247 | } |
1853 | 153 | 248 | ||
1854 | 154 | bool StaticContext::setXPath1_0CompatibMode (zorba::xpath1_0compatib_mode_t aMode) | 249 | bool StaticContext::setOrderingMode (ZorbaConstants::OrderingMode aMode) |
1855 | 155 | { return theStaticContext->setXPath1_0CompatibMode(aMode); } | 250 | { |
1856 | 251 | zorba::ordering_mode_t lMode = zorba::ordered; | ||
1857 | 252 | if (aMode == ZorbaConstants::UNORDERED) { | ||
1858 | 253 | lMode = zorba::unordered; | ||
1859 | 254 | } | ||
1860 | 255 | return theStaticContext->setOrderingMode(lMode); | ||
1861 | 256 | } | ||
1862 | 257 | |||
1863 | 258 | void StaticContext::setRevalidationMode (ZorbaConstants::RevalidationMode aMode) | ||
1864 | 259 | { | ||
1865 | 260 | zorba::validation_mode_t lMode = zorba::validate_skip; | ||
1866 | 261 | if (aMode == ZorbaConstants::VALIDATE_LAX) { | ||
1867 | 262 | lMode = zorba::validate_lax; | ||
1868 | 263 | } else if (aMode == ZorbaConstants::VALIDATE_STRICT) { | ||
1869 | 264 | lMode = zorba::validate_strict; | ||
1870 | 265 | } | ||
1871 | 266 | return theStaticContext->setRevalidationMode(lMode); | ||
1872 | 267 | } | ||
1873 | 268 | |||
1874 | 269 | void StaticContext::setURIPath(std::vector< std::string > &aURIPath ) | ||
1875 | 270 | { | ||
1876 | 271 | std::vector< zorba::String > lURIPath; | ||
1877 | 272 | lURIPath.reserve(aURIPath.size()); | ||
1878 | 273 | std::vector< std::string >::iterator iter; | ||
1879 | 274 | for(iter = aURIPath.begin(); iter != aURIPath.end(); iter++) { | ||
1880 | 275 | lURIPath.push_back((*iter)); | ||
1881 | 276 | } | ||
1882 | 277 | theStaticContext->setURIPath(lURIPath); | ||
1883 | 278 | } | ||
1884 | 279 | |||
1885 | 280 | void StaticContext::setLIBPath(std::vector< std::string > &aLIBPath ) | ||
1886 | 281 | { | ||
1887 | 282 | std::vector< zorba::String > lLIBPath; | ||
1888 | 283 | lLIBPath.reserve(aLIBPath.size()); | ||
1889 | 284 | std::vector< std::string >::iterator iter; | ||
1890 | 285 | for(iter = aLIBPath.begin(); iter != aLIBPath.end(); iter++) { | ||
1891 | 286 | lLIBPath.push_back((*iter)); | ||
1892 | 287 | } | ||
1893 | 288 | theStaticContext->setLibPath(lLIBPath); | ||
1894 | 289 | } | ||
1895 | 290 | |||
1896 | 291 | void StaticContext::setModulePath(std::vector< std::string > &aModulePath ) | ||
1897 | 292 | { | ||
1898 | 293 | std::vector< zorba::String > lModulePath; | ||
1899 | 294 | lModulePath.reserve(aModulePath.size()); | ||
1900 | 295 | std::vector< std::string >::iterator iter; | ||
1901 | 296 | for(iter = aModulePath.begin(); iter != aModulePath.end(); iter++) { | ||
1902 | 297 | lModulePath.push_back((*iter)); | ||
1903 | 298 | } | ||
1904 | 299 | theStaticContext->setModulePaths(lModulePath); | ||
1905 | 300 | } | ||
1906 | 301 | |||
1907 | 302 | bool StaticContext::setXPath1_0CompatibMode (ZorbaConstants::XPath1_0CompatibleMode aMode) | ||
1908 | 303 | { | ||
1909 | 304 | zorba::xpath1_0compatib_mode_t lMode = zorba::xpath2_0; | ||
1910 | 305 | if (aMode == ZorbaConstants::XPATH1_0) { | ||
1911 | 306 | lMode = zorba::xpath1_0; | ||
1912 | 307 | } | ||
1913 | 308 | return theStaticContext->setXPath1_0CompatibMode(lMode); | ||
1914 | 309 | } | ||
1915 | 156 | 310 | ||
1916 | 157 | void StaticContext::destroy() | 311 | void StaticContext::destroy() |
1917 | 158 | { theStaticContext = 0; } | 312 | { theStaticContext = 0; } |
1918 | @@ -165,7 +319,7 @@ | |||
1919 | 165 | %} // end Implementation | 319 | %} // end Implementation |
1920 | 166 | 320 | ||
1921 | 167 | 321 | ||
1923 | 168 | // Interface | 322 | // Interface |
1924 | 169 | 323 | ||
1925 | 170 | %rename(XPath1_0CompatibModeEnum) zorba::xpath1_0compatib_mode_t; | 324 | %rename(XPath1_0CompatibModeEnum) zorba::xpath1_0compatib_mode_t; |
1926 | 171 | %rename(XPATH2_0) xpath2_0; | 325 | %rename(XPATH2_0) xpath2_0; |
1927 | 172 | 326 | ||
1928 | === modified file 'swig/Store.i' | |||
1929 | --- swig/Store.i 2012-03-23 17:32:07 +0000 | |||
1930 | +++ swig/Store.i 2012-03-26 20:16:18 +0000 | |||
1931 | @@ -15,6 +15,8 @@ | |||
1932 | 15 | */ | 15 | */ |
1933 | 16 | 16 | ||
1934 | 17 | %{ // start Implementation | 17 | %{ // start Implementation |
1935 | 18 | |||
1936 | 19 | #include <zorba/store_consts.h> | ||
1937 | 18 | 20 | ||
1938 | 19 | class Store | 21 | class Store |
1939 | 20 | { | 22 | { |
1940 | 21 | 23 | ||
1941 | === added file 'swig/TypeIdentifier.h' | |||
1942 | --- swig/TypeIdentifier.h 1970-01-01 00:00:00 +0000 | |||
1943 | +++ swig/TypeIdentifier.h 2012-03-26 20:16:18 +0000 | |||
1944 | @@ -0,0 +1,97 @@ | |||
1945 | 1 | /* | ||
1946 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
1947 | 3 | * | ||
1948 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1949 | 5 | * you may not use this file except in compliance with the License. | ||
1950 | 6 | * You may obtain a copy of the License at | ||
1951 | 7 | * | ||
1952 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1953 | 9 | * | ||
1954 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
1955 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1956 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1957 | 13 | * See the License for the specific language governing permissions and | ||
1958 | 14 | * limitations under the License. | ||
1959 | 15 | */ | ||
1960 | 16 | |||
1961 | 17 | #ifndef API_TYPE_IDENTIFIER_H | ||
1962 | 18 | #define API_TYPE_IDENTIFIER_H | ||
1963 | 19 | |||
1964 | 20 | class IdentTypes { | ||
1965 | 21 | public: | ||
1966 | 22 | typedef enum { | ||
1967 | 23 | NAMED_TYPE, | ||
1968 | 24 | ELEMENT_TYPE, | ||
1969 | 25 | ATTRIBUTE_TYPE, | ||
1970 | 26 | DOCUMENT_TYPE, | ||
1971 | 27 | PI_TYPE, | ||
1972 | 28 | TEXT_TYPE, | ||
1973 | 29 | COMMENT_TYPE, | ||
1974 | 30 | ANY_NODE_TYPE, | ||
1975 | 31 | ITEM_TYPE, | ||
1976 | 32 | EMPTY_TYPE, | ||
1977 | 33 | INVALID_TYPE, | ||
1978 | 34 | } Kind; | ||
1979 | 35 | |||
1980 | 36 | typedef enum { | ||
1981 | 37 | QUANT_ONE, | ||
1982 | 38 | QUANT_QUESTION, | ||
1983 | 39 | QUANT_PLUS, | ||
1984 | 40 | QUANT_STAR, | ||
1985 | 41 | } Quantifier; | ||
1986 | 42 | }; | ||
1987 | 43 | |||
1988 | 44 | class TypeIdentifier | ||
1989 | 45 | { | ||
1990 | 46 | friend class StaticContext; | ||
1991 | 47 | private: | ||
1992 | 48 | zorba::TypeIdentifier_t theTypeIdentifier; | ||
1993 | 49 | static zorba::IdentTypes::quantifier_t convertQuantifier(IdentTypes::Quantifier quantifier); | ||
1994 | 50 | |||
1995 | 51 | public: | ||
1996 | 52 | TypeIdentifier (const TypeIdentifier& aTypeIdentifier) : theTypeIdentifier(aTypeIdentifier.theTypeIdentifier) {} | ||
1997 | 53 | TypeIdentifier (const zorba::TypeIdentifier_t& aZTypeIdentifier) : theTypeIdentifier(aZTypeIdentifier) {} | ||
1998 | 54 | |||
1999 | 55 | TypeIdentifier getContentType(); | ||
2000 | 56 | IdentTypes::Kind getKind(); | ||
2001 | 57 | const std::string getLocalName(); | ||
2002 | 58 | IdentTypes::Quantifier getQuantifier(); | ||
2003 | 59 | long getRefCount(); | ||
2004 | 60 | const std::string getUri(); | ||
2005 | 61 | bool isLocalNameWildcard(); | ||
2006 | 62 | bool isUriWildcard(); | ||
2007 | 63 | |||
2008 | 64 | static TypeIdentifier | ||
2009 | 65 | createAnyNodeType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE); | ||
2010 | 66 | |||
2011 | 67 | static TypeIdentifier | ||
2012 | 68 | createAttributeType (const std::string &uri, bool uriWildcard, const std::string &localNameName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE); | ||
2013 | 69 | |||
2014 | 70 | static TypeIdentifier | ||
2015 | 71 | createCommentType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE); | ||
2016 | 72 | |||
2017 | 73 | static TypeIdentifier | ||
2018 | 74 | createDocumentType (TypeIdentifier contentType, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE); | ||
2019 | 75 | |||
2020 | 76 | static TypeIdentifier | ||
2021 | 77 | createElementType (const std::string &uri, bool uriWildcard, const std::string &localName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE); | ||
2022 | 78 | |||
2023 | 79 | static TypeIdentifier | ||
2024 | 80 | createEmptyType(); | ||
2025 | 81 | |||
2026 | 82 | static TypeIdentifier | ||
2027 | 83 | createItemType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE); | ||
2028 | 84 | |||
2029 | 85 | static TypeIdentifier | ||
2030 | 86 | createNamedType (const std::string &uri, const std::string &localName, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE); | ||
2031 | 87 | |||
2032 | 88 | static TypeIdentifier | ||
2033 | 89 | createPIType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE); | ||
2034 | 90 | |||
2035 | 91 | static TypeIdentifier | ||
2036 | 92 | createTextType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE); | ||
2037 | 93 | |||
2038 | 94 | }; // class TypeIdentifier | ||
2039 | 95 | |||
2040 | 96 | |||
2041 | 97 | #endif | ||
2042 | 0 | \ No newline at end of file | 98 | \ No newline at end of file |
2043 | 1 | 99 | ||
2044 | === added file 'swig/TypeIdentifier.i' | |||
2045 | --- swig/TypeIdentifier.i 1970-01-01 00:00:00 +0000 | |||
2046 | +++ swig/TypeIdentifier.i 2012-03-26 20:16:18 +0000 | |||
2047 | @@ -0,0 +1,197 @@ | |||
2048 | 1 | /* | ||
2049 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
2050 | 3 | * | ||
2051 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
2052 | 5 | * you may not use this file except in compliance with the License. | ||
2053 | 6 | * You may obtain a copy of the License at | ||
2054 | 7 | * | ||
2055 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
2056 | 9 | * | ||
2057 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
2058 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
2059 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
2060 | 13 | * See the License for the specific language governing permissions and | ||
2061 | 14 | * limitations under the License. | ||
2062 | 15 | */ | ||
2063 | 16 | |||
2064 | 17 | %{ // start Implementation | ||
2065 | 18 | |||
2066 | 19 | zorba::IdentTypes::quantifier_t | ||
2067 | 20 | TypeIdentifier::convertQuantifier(IdentTypes::Quantifier quantifier) | ||
2068 | 21 | { | ||
2069 | 22 | zorba::IdentTypes::quantifier_t result; | ||
2070 | 23 | switch (quantifier) { | ||
2071 | 24 | case IdentTypes::QUANT_ONE: | ||
2072 | 25 | result = zorba::IdentTypes::QUANT_ONE; | ||
2073 | 26 | break; | ||
2074 | 27 | case IdentTypes::QUANT_QUESTION: | ||
2075 | 28 | result = zorba::IdentTypes::QUANT_QUESTION; | ||
2076 | 29 | break; | ||
2077 | 30 | case IdentTypes::QUANT_PLUS: | ||
2078 | 31 | result = zorba::IdentTypes::QUANT_PLUS; | ||
2079 | 32 | break; | ||
2080 | 33 | case IdentTypes::QUANT_STAR: | ||
2081 | 34 | result = zorba::IdentTypes::QUANT_STAR; | ||
2082 | 35 | break; | ||
2083 | 36 | } | ||
2084 | 37 | return result; | ||
2085 | 38 | } | ||
2086 | 39 | |||
2087 | 40 | TypeIdentifier TypeIdentifier::getContentType() | ||
2088 | 41 | { | ||
2089 | 42 | return TypeIdentifier(theTypeIdentifier->getContentType()); | ||
2090 | 43 | } | ||
2091 | 44 | IdentTypes::Kind TypeIdentifier::getKind() | ||
2092 | 45 | { | ||
2093 | 46 | zorba::IdentTypes::kind_t lKind = theTypeIdentifier->getKind(); | ||
2094 | 47 | IdentTypes::Kind result; | ||
2095 | 48 | switch (lKind) { | ||
2096 | 49 | case zorba::IdentTypes::NAMED_TYPE: | ||
2097 | 50 | result = IdentTypes::NAMED_TYPE; | ||
2098 | 51 | break; | ||
2099 | 52 | case zorba::IdentTypes::ELEMENT_TYPE: | ||
2100 | 53 | result = IdentTypes::ELEMENT_TYPE; | ||
2101 | 54 | break; | ||
2102 | 55 | case zorba::IdentTypes::ATTRIBUTE_TYPE: | ||
2103 | 56 | result = IdentTypes::ATTRIBUTE_TYPE; | ||
2104 | 57 | break; | ||
2105 | 58 | case zorba::IdentTypes::DOCUMENT_TYPE: | ||
2106 | 59 | result = IdentTypes::DOCUMENT_TYPE; | ||
2107 | 60 | break; | ||
2108 | 61 | case zorba::IdentTypes::PI_TYPE: | ||
2109 | 62 | result = IdentTypes::PI_TYPE; | ||
2110 | 63 | break; | ||
2111 | 64 | case zorba::IdentTypes::TEXT_TYPE: | ||
2112 | 65 | result = IdentTypes::TEXT_TYPE; | ||
2113 | 66 | break; | ||
2114 | 67 | case zorba::IdentTypes::COMMENT_TYPE: | ||
2115 | 68 | result = IdentTypes::COMMENT_TYPE; | ||
2116 | 69 | break; | ||
2117 | 70 | case zorba::IdentTypes::ANY_NODE_TYPE: | ||
2118 | 71 | result = IdentTypes::ANY_NODE_TYPE; | ||
2119 | 72 | break; | ||
2120 | 73 | case zorba::IdentTypes::ITEM_TYPE: | ||
2121 | 74 | result = IdentTypes::ITEM_TYPE; | ||
2122 | 75 | break; | ||
2123 | 76 | case zorba::IdentTypes::EMPTY_TYPE: | ||
2124 | 77 | result = IdentTypes::EMPTY_TYPE; | ||
2125 | 78 | break; | ||
2126 | 79 | case zorba::IdentTypes::INVALID_TYPE: | ||
2127 | 80 | result = IdentTypes::INVALID_TYPE; | ||
2128 | 81 | break; | ||
2129 | 82 | default: | ||
2130 | 83 | result = IdentTypes::ANY_NODE_TYPE; | ||
2131 | 84 | break; | ||
2132 | 85 | } | ||
2133 | 86 | return result; | ||
2134 | 87 | } | ||
2135 | 88 | const std::string TypeIdentifier::getLocalName() | ||
2136 | 89 | { | ||
2137 | 90 | return std::string(theTypeIdentifier->getLocalName().c_str()); | ||
2138 | 91 | } | ||
2139 | 92 | IdentTypes::Quantifier TypeIdentifier::getQuantifier() | ||
2140 | 93 | { | ||
2141 | 94 | zorba::IdentTypes::quantifier_t lQuantifier = theTypeIdentifier->getQuantifier(); | ||
2142 | 95 | IdentTypes::Quantifier result; | ||
2143 | 96 | switch (lQuantifier) { | ||
2144 | 97 | case zorba::IdentTypes::QUANT_ONE: | ||
2145 | 98 | result = IdentTypes::QUANT_ONE; | ||
2146 | 99 | break; | ||
2147 | 100 | case zorba::IdentTypes::QUANT_QUESTION: | ||
2148 | 101 | result = IdentTypes::QUANT_QUESTION; | ||
2149 | 102 | break; | ||
2150 | 103 | case zorba::IdentTypes::QUANT_PLUS: | ||
2151 | 104 | result = IdentTypes::QUANT_PLUS; | ||
2152 | 105 | break; | ||
2153 | 106 | case zorba::IdentTypes::QUANT_STAR: | ||
2154 | 107 | result = IdentTypes::QUANT_STAR; | ||
2155 | 108 | break; | ||
2156 | 109 | } | ||
2157 | 110 | return result; | ||
2158 | 111 | } | ||
2159 | 112 | long TypeIdentifier::getRefCount() | ||
2160 | 113 | { | ||
2161 | 114 | return theTypeIdentifier->getRefCount(); | ||
2162 | 115 | } | ||
2163 | 116 | const std::string TypeIdentifier::getUri() | ||
2164 | 117 | { | ||
2165 | 118 | return std::string(theTypeIdentifier->getUri().c_str()); | ||
2166 | 119 | } | ||
2167 | 120 | bool TypeIdentifier::isLocalNameWildcard() | ||
2168 | 121 | { | ||
2169 | 122 | return theTypeIdentifier->isLocalNameWildcard(); | ||
2170 | 123 | } | ||
2171 | 124 | bool TypeIdentifier::isUriWildcard() | ||
2172 | 125 | { | ||
2173 | 126 | return theTypeIdentifier->isUriWildcard(); | ||
2174 | 127 | } | ||
2175 | 128 | |||
2176 | 129 | |||
2177 | 130 | // STATIC METHODS | ||
2178 | 131 | TypeIdentifier | ||
2179 | 132 | TypeIdentifier::createAnyNodeType (IdentTypes::Quantifier quantifier) | ||
2180 | 133 | { | ||
2181 | 134 | return TypeIdentifier( zorba::TypeIdentifier::createAnyNodeType ( convertQuantifier(quantifier) ) ); | ||
2182 | 135 | } | ||
2183 | 136 | |||
2184 | 137 | TypeIdentifier | ||
2185 | 138 | TypeIdentifier::createAttributeType (const std::string &uri, bool uriWildcard, const std::string &localNameName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier) | ||
2186 | 139 | { | ||
2187 | 140 | return TypeIdentifier( zorba::TypeIdentifier::createAttributeType( uri, uriWildcard, localNameName, localNameWildcard, contentType.theTypeIdentifier, convertQuantifier(quantifier) ) ); | ||
2188 | 141 | } | ||
2189 | 142 | |||
2190 | 143 | TypeIdentifier | ||
2191 | 144 | TypeIdentifier::createCommentType (IdentTypes::Quantifier quantifier) | ||
2192 | 145 | { | ||
2193 | 146 | return TypeIdentifier( zorba::TypeIdentifier::createCommentType ( convertQuantifier(quantifier) ) ); | ||
2194 | 147 | } | ||
2195 | 148 | |||
2196 | 149 | TypeIdentifier | ||
2197 | 150 | TypeIdentifier::createDocumentType (TypeIdentifier contentType, IdentTypes::Quantifier quantifier) | ||
2198 | 151 | { | ||
2199 | 152 | return TypeIdentifier( zorba::TypeIdentifier::createDocumentType(contentType.theTypeIdentifier, convertQuantifier(quantifier) ) ); | ||
2200 | 153 | } | ||
2201 | 154 | |||
2202 | 155 | TypeIdentifier | ||
2203 | 156 | TypeIdentifier::createElementType (const std::string &uri, bool uriWildcard, const std::string &localName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier) | ||
2204 | 157 | { | ||
2205 | 158 | return TypeIdentifier( zorba::TypeIdentifier::createElementType(uri, uriWildcard, localName, localNameWildcard, contentType.theTypeIdentifier, convertQuantifier(quantifier) ) ); | ||
2206 | 159 | } | ||
2207 | 160 | |||
2208 | 161 | TypeIdentifier | ||
2209 | 162 | TypeIdentifier::createEmptyType() | ||
2210 | 163 | { | ||
2211 | 164 | return TypeIdentifier( zorba::TypeIdentifier::createEmptyType() ); | ||
2212 | 165 | } | ||
2213 | 166 | |||
2214 | 167 | TypeIdentifier | ||
2215 | 168 | TypeIdentifier::createItemType (IdentTypes::Quantifier quantifier) | ||
2216 | 169 | { | ||
2217 | 170 | return TypeIdentifier( zorba::TypeIdentifier::createItemType( convertQuantifier(quantifier) ) ); | ||
2218 | 171 | } | ||
2219 | 172 | |||
2220 | 173 | TypeIdentifier | ||
2221 | 174 | TypeIdentifier::createNamedType (const std::string &uri, const std::string &localName, IdentTypes::Quantifier quantifier) | ||
2222 | 175 | { | ||
2223 | 176 | return TypeIdentifier( zorba::TypeIdentifier::createNamedType( uri, localName, convertQuantifier(quantifier) ) ); | ||
2224 | 177 | } | ||
2225 | 178 | |||
2226 | 179 | TypeIdentifier | ||
2227 | 180 | TypeIdentifier::createPIType (IdentTypes::Quantifier quantifier) | ||
2228 | 181 | { | ||
2229 | 182 | return TypeIdentifier( zorba::TypeIdentifier::createPIType( convertQuantifier(quantifier) ) ); | ||
2230 | 183 | } | ||
2231 | 184 | |||
2232 | 185 | TypeIdentifier | ||
2233 | 186 | TypeIdentifier::createTextType (IdentTypes::Quantifier quantifier) | ||
2234 | 187 | { | ||
2235 | 188 | return TypeIdentifier( zorba::TypeIdentifier::createTextType( convertQuantifier(quantifier) ) ); | ||
2236 | 189 | } | ||
2237 | 190 | |||
2238 | 191 | // END OF STATIC METHODS | ||
2239 | 192 | |||
2240 | 193 | |||
2241 | 194 | %} // end Implementation | ||
2242 | 195 | |||
2243 | 196 | |||
2244 | 197 | %include "TypeIdentifier.h" | ||
2245 | 0 | 198 | ||
2246 | === added file 'swig/XQuery.h' | |||
2247 | --- swig/XQuery.h 1970-01-01 00:00:00 +0000 | |||
2248 | +++ swig/XQuery.h 2012-03-26 20:16:18 +0000 | |||
2249 | @@ -0,0 +1,47 @@ | |||
2250 | 1 | /* | ||
2251 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
2252 | 3 | * | ||
2253 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
2254 | 5 | * you may not use this file except in compliance with the License. | ||
2255 | 6 | * You may obtain a copy of the License at | ||
2256 | 7 | * | ||
2257 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
2258 | 9 | * | ||
2259 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
2260 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
2261 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
2262 | 13 | * See the License for the specific language governing permissions and | ||
2263 | 14 | * limitations under the License. | ||
2264 | 15 | */ | ||
2265 | 16 | #ifndef API_XQUERY_H | ||
2266 | 17 | #define API_XQUERY_H | ||
2267 | 18 | |||
2268 | 19 | class XQuery | ||
2269 | 20 | { | ||
2270 | 21 | private: | ||
2271 | 22 | zorba::XQuery_t theQuery; | ||
2272 | 23 | bool closed; | ||
2273 | 24 | |||
2274 | 25 | public: | ||
2275 | 26 | XQuery():closed(false) {} | ||
2276 | 27 | XQuery(const XQuery& aXQuery) : theQuery(aXQuery.theQuery), closed(aXQuery.closed) {} | ||
2277 | 28 | XQuery(zorba::XQuery_t aQuery) : theQuery(aQuery), closed(false) {} | ||
2278 | 29 | |||
2279 | 30 | std::string execute(); | ||
2280 | 31 | std::string printPlanAsXML(); | ||
2281 | 32 | std::string printPlanAsDOT(); | ||
2282 | 33 | void compile (const std::string &aQuery); | ||
2283 | 34 | void compile (const std::string &aQuery, StaticContext &aStaticContext); | ||
2284 | 35 | |||
2285 | 36 | #ifdef SWIGPYTHON | ||
2286 | 37 | void executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy); | ||
2287 | 38 | #endif | ||
2288 | 39 | |||
2289 | 40 | void destroy(); | ||
2290 | 41 | Iterator iterator(); | ||
2291 | 42 | DynamicContext getDynamicContext(); | ||
2292 | 43 | StaticContext getStaticContext(); | ||
2293 | 44 | void getExternalVariables(Iterator& vars) const; | ||
2294 | 45 | }; // class XQuery | ||
2295 | 46 | |||
2296 | 47 | #endif | ||
2297 | 0 | \ No newline at end of file | 48 | \ No newline at end of file |
2298 | 1 | 49 | ||
2299 | === modified file 'swig/XQuery.i' | |||
2300 | --- swig/XQuery.i 2012-03-23 17:32:07 +0000 | |||
2301 | +++ swig/XQuery.i 2012-03-26 20:16:18 +0000 | |||
2302 | @@ -16,332 +16,60 @@ | |||
2303 | 16 | 16 | ||
2304 | 17 | %{ // start Implementation | 17 | %{ // start Implementation |
2305 | 18 | 18 | ||
2494 | 19 | class Iterator | 19 | std::string XQuery::execute() |
2307 | 20 | { | ||
2308 | 21 | protected: | ||
2309 | 22 | friend class DynamicContext; | ||
2310 | 23 | zorba::Iterator_t theIterator; | ||
2311 | 24 | zorba::Item theItem; | ||
2312 | 25 | bool theConsumed; | ||
2313 | 26 | |||
2314 | 27 | public: | ||
2315 | 28 | Iterator() {} | ||
2316 | 29 | Iterator(const Iterator& anIterator) | ||
2317 | 30 | : theIterator(anIterator.theIterator), | ||
2318 | 31 | theItem(anIterator.theItem), | ||
2319 | 32 | theConsumed(false) | ||
2320 | 33 | {} | ||
2321 | 34 | |||
2322 | 35 | Iterator(zorba::Iterator_t anIterator) | ||
2323 | 36 | : theIterator(anIterator), | ||
2324 | 37 | theConsumed(false) | ||
2325 | 38 | {} | ||
2326 | 39 | |||
2327 | 40 | Iterator(zorba::Item& aItem) | ||
2328 | 41 | : theIterator(0), | ||
2329 | 42 | theItem(aItem), | ||
2330 | 43 | theConsumed(false) | ||
2331 | 44 | {} | ||
2332 | 45 | |||
2333 | 46 | void open() | ||
2334 | 47 | { | ||
2335 | 48 | if (theIterator) | ||
2336 | 49 | theIterator->open(); | ||
2337 | 50 | theConsumed = false; | ||
2338 | 51 | } | ||
2339 | 52 | |||
2340 | 53 | bool next(Item& aItem); | ||
2341 | 54 | |||
2342 | 55 | void close() | ||
2343 | 56 | { | ||
2344 | 57 | if (theIterator) | ||
2345 | 58 | theIterator->close(); | ||
2346 | 59 | theConsumed = true; | ||
2347 | 60 | } | ||
2348 | 61 | |||
2349 | 62 | void destroy() | ||
2350 | 63 | { | ||
2351 | 64 | theIterator = 0; | ||
2352 | 65 | } | ||
2353 | 66 | |||
2354 | 67 | }; // class Iterator | ||
2355 | 68 | |||
2356 | 69 | |||
2357 | 70 | class Item | ||
2358 | 71 | { | ||
2359 | 72 | friend class Iterator; | ||
2360 | 73 | friend class StaticContext; | ||
2361 | 74 | friend class DocumentManager; | ||
2362 | 75 | friend class SingletonIterator; | ||
2363 | 76 | friend class DynamicContext; | ||
2364 | 77 | friend class ItemFactory; | ||
2365 | 78 | |||
2366 | 79 | private: | ||
2367 | 80 | zorba::Item theItem; | ||
2368 | 81 | |||
2369 | 82 | public: | ||
2370 | 83 | Item() {} | ||
2371 | 84 | Item(const Item& aItem) : theItem(aItem.theItem) {} | ||
2372 | 85 | Item(const zorba::Item& aZItem) : theItem(aZItem) {} | ||
2373 | 86 | |||
2374 | 87 | static Item createEmptyItem() | ||
2375 | 88 | { return Item(); } | ||
2376 | 89 | |||
2377 | 90 | std::string getStringValue() const | ||
2378 | 91 | { return std::string(theItem.getStringValue().c_str()); } | ||
2379 | 92 | |||
2380 | 93 | std::string serialize() const | ||
2381 | 94 | { | ||
2382 | 95 | std::stringstream lStream; | ||
2383 | 96 | Zorba_SerializerOptions_t lOptions; | ||
2384 | 97 | zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(lOptions); | ||
2385 | 98 | zorba::SingletonItemSequence lSequence(theItem); | ||
2386 | 99 | lSerializer->serialize(&lSequence, lStream); | ||
2387 | 100 | return lStream.str(); | ||
2388 | 101 | } | ||
2389 | 102 | |||
2390 | 103 | Iterator getAtomizationValue () const | ||
2391 | 104 | { return Iterator(theItem.getAtomizationValue()); } | ||
2392 | 105 | |||
2393 | 106 | Iterator getAttributes () const | ||
2394 | 107 | { return Iterator(theItem.getAttributes()); } | ||
2395 | 108 | |||
2396 | 109 | bool getBooleanValue () const | ||
2397 | 110 | { return theItem.getBooleanValue(); } | ||
2398 | 111 | |||
2399 | 112 | Iterator getChildren () const | ||
2400 | 113 | { return Iterator(theItem.getChildren()); } | ||
2401 | 114 | |||
2402 | 115 | Item getEBV () const | ||
2403 | 116 | { return Item(theItem.getEBV()); } | ||
2404 | 117 | |||
2405 | 118 | int getIntValue () const | ||
2406 | 119 | { return theItem.getIntValue(); } | ||
2407 | 120 | |||
2408 | 121 | std::string getLocalName () const | ||
2409 | 122 | { return std::string(theItem.getLocalName().c_str()); } | ||
2410 | 123 | |||
2411 | 124 | std::string getNamespace () const | ||
2412 | 125 | { return std::string(theItem.getNamespace().c_str()); } | ||
2413 | 126 | |||
2414 | 127 | bool getNodeName (Item &aNodeName) const | ||
2415 | 128 | { return theItem.getNodeName( aNodeName.theItem ); } | ||
2416 | 129 | |||
2417 | 130 | std::string getPrefix () const | ||
2418 | 131 | { return std::string(theItem.getPrefix().c_str()); } | ||
2419 | 132 | |||
2420 | 133 | Item getType () const | ||
2421 | 134 | { return Item( theItem.getType() ); } | ||
2422 | 135 | |||
2423 | 136 | unsigned int getUnsignedIntValue () const | ||
2424 | 137 | { return theItem.getUnsignedIntValue(); } | ||
2425 | 138 | |||
2426 | 139 | bool isAtomic () const | ||
2427 | 140 | { return theItem.isAtomic(); } | ||
2428 | 141 | |||
2429 | 142 | bool isNaN () const | ||
2430 | 143 | { return theItem.isNaN(); } | ||
2431 | 144 | |||
2432 | 145 | bool isNode () const | ||
2433 | 146 | { return theItem.isNode(); } | ||
2434 | 147 | |||
2435 | 148 | bool isNull () const | ||
2436 | 149 | { return theItem.isNull(); } | ||
2437 | 150 | |||
2438 | 151 | bool isPosOrNegInf () const | ||
2439 | 152 | { return theItem.isPosOrNegInf(); } | ||
2440 | 153 | |||
2441 | 154 | int getNodeKind () const | ||
2442 | 155 | { return theItem.getNodeKind(); } | ||
2443 | 156 | |||
2444 | 157 | }; // class Item | ||
2445 | 158 | |||
2446 | 159 | class DynamicContext | ||
2447 | 160 | { | ||
2448 | 161 | private: | ||
2449 | 162 | zorba::DynamicContext* theContext; | ||
2450 | 163 | |||
2451 | 164 | public: | ||
2452 | 165 | DynamicContext() | ||
2453 | 166 | : theContext(0) | ||
2454 | 167 | { | ||
2455 | 168 | } | ||
2456 | 169 | |||
2457 | 170 | DynamicContext(const DynamicContext& aCtx) | ||
2458 | 171 | : theContext(aCtx.theContext) | ||
2459 | 172 | { | ||
2460 | 173 | } | ||
2461 | 174 | |||
2462 | 175 | DynamicContext(zorba::DynamicContext* aCtx) | ||
2463 | 176 | : theContext(aCtx) | ||
2464 | 177 | { | ||
2465 | 178 | } | ||
2466 | 179 | |||
2467 | 180 | void | ||
2468 | 181 | setVariable( | ||
2469 | 182 | const std::string& aNamespace, | ||
2470 | 183 | const std::string& aLocalname, | ||
2471 | 184 | Iterator aIter) | ||
2472 | 185 | { | ||
2473 | 186 | theContext->setVariable(aNamespace, aLocalname, aIter.theIterator); | ||
2474 | 187 | } | ||
2475 | 188 | |||
2476 | 189 | void | ||
2477 | 190 | setContextItem(Item aItem) | ||
2478 | 191 | { | ||
2479 | 192 | theContext->setContextItem(aItem.theItem); | ||
2480 | 193 | } | ||
2481 | 194 | }; | ||
2482 | 195 | |||
2483 | 196 | class XQuery | ||
2484 | 197 | { | ||
2485 | 198 | private: | ||
2486 | 199 | zorba::XQuery_t theQuery; | ||
2487 | 200 | |||
2488 | 201 | public: | ||
2489 | 202 | XQuery() {} | ||
2490 | 203 | XQuery(const XQuery& aXQuery) : theQuery(aXQuery.theQuery) {} | ||
2491 | 204 | XQuery(zorba::XQuery_t aQuery) : theQuery(aQuery) {} | ||
2492 | 205 | |||
2493 | 206 | std::string execute() | ||
2495 | 207 | { | 20 | { |
2496 | 208 | std::stringstream lStream; | 21 | std::stringstream lStream; |
2497 | 209 | lStream << theQuery; | 22 | lStream << theQuery; |
2499 | 210 | return lStream.str(); | 23 | std::string str = lStream.str(); |
2500 | 24 | return str; | ||
2501 | 211 | } | 25 | } |
2504 | 212 | 26 | ||
2505 | 213 | void compile (const std::string &aQuery) | 27 | void XQuery::compile (const std::string &aQuery) |
2506 | 214 | { | 28 | { |
2507 | 215 | theQuery->compile(aQuery); | 29 | theQuery->compile(aQuery); |
2508 | 216 | } | 30 | } |
2509 | 217 | 31 | ||
2511 | 218 | void compile (const std::string &aQuery, StaticContext &aStaticContext ) | 32 | void XQuery::compile (const std::string &aQuery, StaticContext &aStaticContext ) |
2512 | 219 | { | 33 | { |
2513 | 220 | Zorba_CompilerHints_t hints; | 34 | Zorba_CompilerHints_t hints; |
2514 | 221 | theQuery->compile(aQuery, aStaticContext.theStaticContext, hints); | 35 | theQuery->compile(aQuery, aStaticContext.theStaticContext, hints); |
2515 | 222 | } | 36 | } |
2518 | 223 | 37 | ||
2519 | 224 | std::string printPlanAsXML() | 38 | std::string XQuery::printPlanAsXML() |
2520 | 225 | { | 39 | { |
2521 | 226 | std::ostringstream lStream; | 40 | std::ostringstream lStream; |
2522 | 227 | theQuery->printPlan(lStream); | 41 | theQuery->printPlan(lStream); |
2523 | 228 | return lStream.str(); | 42 | return lStream.str(); |
2524 | 229 | } | 43 | } |
2525 | 230 | 44 | ||
2527 | 231 | std::string printPlanAsDOT() | 45 | std::string XQuery::printPlanAsDOT() |
2528 | 232 | { | 46 | { |
2529 | 233 | std::ostringstream lStream; | 47 | std::ostringstream lStream; |
2530 | 234 | theQuery->printPlan(lStream, true); | 48 | theQuery->printPlan(lStream, true); |
2531 | 235 | return lStream.str(); | 49 | return lStream.str(); |
2532 | 236 | } | 50 | } |
2536 | 237 | 51 | ||
2537 | 238 | DynamicContext | 52 | DynamicContext XQuery::getDynamicContext() |
2535 | 239 | getDynamicContext() | ||
2538 | 240 | { | 53 | { |
2539 | 241 | return DynamicContext(theQuery->getDynamicContext()); | 54 | return DynamicContext(theQuery->getDynamicContext()); |
2540 | 242 | } | 55 | } |
2541 | 243 | 56 | ||
2542 | 57 | StaticContext XQuery::getStaticContext() | ||
2543 | 58 | { | ||
2544 | 59 | return StaticContext( zorba::StaticContext_t( const_cast<zorba::StaticContext *>(theQuery->getStaticContext()) ) ); | ||
2545 | 60 | } | ||
2546 | 61 | |||
2547 | 62 | void XQuery::getExternalVariables(Iterator& vars) const | ||
2548 | 63 | { theQuery->getExternalVariables( vars.theIterator ); } | ||
2549 | 64 | |||
2550 | 244 | #ifdef SWIGPYTHON | 65 | #ifdef SWIGPYTHON |
2552 | 245 | void executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy) | 66 | void XQuery::executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy) |
2553 | 246 | { theQuery->executeSAX(contentHandlerProxy); } | 67 | { theQuery->executeSAX(contentHandlerProxy); } |
2554 | 247 | #endif | 68 | #endif |
2555 | 248 | 69 | ||
2583 | 249 | void destroy() { theQuery = 0; } | 70 | void XQuery::destroy() { theQuery = 0; } |
2584 | 250 | Iterator iterator() { return Iterator(theQuery->iterator()); } | 71 | Iterator XQuery::iterator() { return Iterator(theQuery->iterator()); } |
2558 | 251 | }; // class XQuery | ||
2559 | 252 | |||
2560 | 253 | |||
2561 | 254 | // remaining method definitions from Iterator | ||
2562 | 255 | bool | ||
2563 | 256 | Iterator::next(Item& aItem) | ||
2564 | 257 | { | ||
2565 | 258 | if (theIterator) | ||
2566 | 259 | { | ||
2567 | 260 | return theIterator->next(aItem.theItem); | ||
2568 | 261 | } | ||
2569 | 262 | else | ||
2570 | 263 | { | ||
2571 | 264 | if (!theConsumed) | ||
2572 | 265 | { | ||
2573 | 266 | aItem = theItem; | ||
2574 | 267 | return true; | ||
2575 | 268 | } | ||
2576 | 269 | else | ||
2577 | 270 | { | ||
2578 | 271 | return false; | ||
2579 | 272 | } | ||
2580 | 273 | } | ||
2581 | 274 | } | ||
2582 | 275 | |||
2585 | 276 | 72 | ||
2586 | 277 | %} // end Implementation | 73 | %} // end Implementation |
2587 | 278 | 74 | ||
2657 | 279 | 75 | %include "XQuery.h" | |
2589 | 280 | // Interfaces | ||
2590 | 281 | |||
2591 | 282 | class DynamicContext | ||
2592 | 283 | { | ||
2593 | 284 | public: | ||
2594 | 285 | void | ||
2595 | 286 | setVariable( | ||
2596 | 287 | const std::string& aNamespace, | ||
2597 | 288 | const std::string& aLocalname, | ||
2598 | 289 | Iterator); | ||
2599 | 290 | |||
2600 | 291 | void | ||
2601 | 292 | setContextItem(Item); | ||
2602 | 293 | }; | ||
2603 | 294 | |||
2604 | 295 | class Item | ||
2605 | 296 | { | ||
2606 | 297 | public: | ||
2607 | 298 | static Item createEmptyItem(); | ||
2608 | 299 | std::string getStringValue() const; | ||
2609 | 300 | std::string serialize() const; | ||
2610 | 301 | Iterator getAtomizationValue () const; | ||
2611 | 302 | Iterator getAttributes () const; | ||
2612 | 303 | bool getBooleanValue () const; | ||
2613 | 304 | Iterator getChildren () const; | ||
2614 | 305 | Item getEBV () const; | ||
2615 | 306 | int getIntValue () const; | ||
2616 | 307 | std::string getLocalName () const; | ||
2617 | 308 | std::string getNamespace () const; | ||
2618 | 309 | bool getNodeName (Item &aNodeName) const; | ||
2619 | 310 | std::string getPrefix () const; | ||
2620 | 311 | Item getType () const; | ||
2621 | 312 | unsigned int getUnsignedIntValue () const; | ||
2622 | 313 | |||
2623 | 314 | int getNodeKind() const; | ||
2624 | 315 | bool isAtomic () const; | ||
2625 | 316 | bool isNaN () const; | ||
2626 | 317 | bool isNode () const; | ||
2627 | 318 | bool isNull () const; | ||
2628 | 319 | bool isPosOrNegInf () const; | ||
2629 | 320 | }; // class Item | ||
2630 | 321 | |||
2631 | 322 | class Iterator | ||
2632 | 323 | { | ||
2633 | 324 | public: | ||
2634 | 325 | void open(); | ||
2635 | 326 | bool next(Item&); | ||
2636 | 327 | void close(); | ||
2637 | 328 | void destroy(); | ||
2638 | 329 | }; // class Iterator | ||
2639 | 330 | |||
2640 | 331 | class XQuery | ||
2641 | 332 | { | ||
2642 | 333 | public: | ||
2643 | 334 | std::string execute(); | ||
2644 | 335 | std::string printPlanAsXML(); | ||
2645 | 336 | std::string printPlanAsDOT(); | ||
2646 | 337 | void compile (const std::string &aQuery); | ||
2647 | 338 | void compile (const std::string &aQuery, StaticContext &aStaticContext); | ||
2648 | 339 | |||
2649 | 340 | #ifdef SWIGPYTHON | ||
2650 | 341 | void executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy); | ||
2651 | 342 | #endif | ||
2652 | 343 | |||
2653 | 344 | void destroy(); | ||
2654 | 345 | Iterator iterator(); | ||
2655 | 346 | DynamicContext getDynamicContext(); | ||
2656 | 347 | }; // class XQuery | ||
2658 | 348 | \ No newline at end of file | 76 | \ No newline at end of file |
2659 | 349 | 77 | ||
2660 | === added file 'swig/XmlDataManager.h' | |||
2661 | --- swig/XmlDataManager.h 1970-01-01 00:00:00 +0000 | |||
2662 | +++ swig/XmlDataManager.h 2012-03-26 20:16:18 +0000 | |||
2663 | @@ -0,0 +1,35 @@ | |||
2664 | 1 | /* | ||
2665 | 2 | * Copyright 2006-2012 The FLWOR Foundation. | ||
2666 | 3 | * | ||
2667 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
2668 | 5 | * you may not use this file except in compliance with the License. | ||
2669 | 6 | * You may obtain a copy of the License at | ||
2670 | 7 | * | ||
2671 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
2672 | 9 | * | ||
2673 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
2674 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
2675 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
2676 | 13 | * See the License for the specific language governing permissions and | ||
2677 | 14 | * limitations under the License. | ||
2678 | 15 | */ | ||
2679 | 16 | #ifndef API_XML_DATA_MANAGER_H | ||
2680 | 17 | #define API_XML_DATA_MANAGER_H | ||
2681 | 18 | |||
2682 | 19 | class XmlDataManager | ||
2683 | 20 | { | ||
2684 | 21 | private: | ||
2685 | 22 | zorba::XmlDataManager* theManager; | ||
2686 | 23 | |||
2687 | 24 | public: | ||
2688 | 25 | XmlDataManager() : theManager(0) {} | ||
2689 | 26 | XmlDataManager(const XmlDataManager& aMgr) : theManager(aMgr.theManager) {} | ||
2690 | 27 | XmlDataManager(zorba::XmlDataManager* aMgr) : theManager(aMgr) {} | ||
2691 | 28 | |||
2692 | 29 | DocumentManager getDocumentManager(); | ||
2693 | 30 | CollectionManager getCollectionManager(); | ||
2694 | 31 | CollectionManager getW3CCollectionManager(); | ||
2695 | 32 | Iterator parseXML(const std::string& aDoc); | ||
2696 | 33 | |||
2697 | 34 | }; | ||
2698 | 35 | #endif | ||
2699 | 0 | \ No newline at end of file | 36 | \ No newline at end of file |
2700 | 1 | 37 | ||
2701 | === modified file 'swig/XmlDataManager.i' | |||
2702 | --- swig/XmlDataManager.i 2012-03-23 17:32:07 +0000 | |||
2703 | +++ swig/XmlDataManager.i 2012-03-26 20:16:18 +0000 | |||
2704 | @@ -1,5 +1,5 @@ | |||
2705 | 1 | /* | 1 | /* |
2707 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | 2 | * Copyright 2006-2012 The FLWOR Foundation. |
2708 | 3 | * | 3 | * |
2709 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
2710 | 5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
2711 | @@ -16,54 +16,20 @@ | |||
2712 | 16 | 16 | ||
2713 | 17 | %{ // start Implementation | 17 | %{ // start Implementation |
2714 | 18 | 18 | ||
2758 | 19 | 19 | DocumentManager XmlDataManager::getDocumentManager() | |
2716 | 20 | class DocumentManager | ||
2717 | 21 | { | ||
2718 | 22 | private: | ||
2719 | 23 | zorba::DocumentManager* theManager; | ||
2720 | 24 | |||
2721 | 25 | public: | ||
2722 | 26 | DocumentManager() : theManager(0) {} | ||
2723 | 27 | DocumentManager(const DocumentManager& aMgr) : theManager(aMgr.theManager) {} | ||
2724 | 28 | DocumentManager(zorba::DocumentManager* aMgr) : theManager(aMgr) {} | ||
2725 | 29 | |||
2726 | 30 | void put(const std::string& aName, Item aDoc) | ||
2727 | 31 | { | ||
2728 | 32 | theManager->put(aName, aDoc.theItem); | ||
2729 | 33 | } | ||
2730 | 34 | |||
2731 | 35 | void remove(const std::string& aName) | ||
2732 | 36 | { | ||
2733 | 37 | theManager->remove(aName); | ||
2734 | 38 | } | ||
2735 | 39 | |||
2736 | 40 | Item document(const std::string& aName) | ||
2737 | 41 | { | ||
2738 | 42 | return theManager->document(aName); | ||
2739 | 43 | } | ||
2740 | 44 | |||
2741 | 45 | bool isAvailableDocument(const std::string& aName) | ||
2742 | 46 | { | ||
2743 | 47 | return theManager->isAvailableDocument(aName); | ||
2744 | 48 | } | ||
2745 | 49 | }; | ||
2746 | 50 | |||
2747 | 51 | class XmlDataManager | ||
2748 | 52 | { | ||
2749 | 53 | private: | ||
2750 | 54 | zorba::XmlDataManager* theManager; | ||
2751 | 55 | |||
2752 | 56 | public: | ||
2753 | 57 | XmlDataManager() : theManager(0) {} | ||
2754 | 58 | XmlDataManager(const XmlDataManager& aMgr) : theManager(aMgr.theManager) {} | ||
2755 | 59 | XmlDataManager(zorba::XmlDataManager* aMgr) : theManager(aMgr) {} | ||
2756 | 60 | |||
2757 | 61 | DocumentManager getDocumentManager() | ||
2759 | 62 | { | 20 | { |
2760 | 63 | return DocumentManager(theManager->getDocumentManager()); | 21 | return DocumentManager(theManager->getDocumentManager()); |
2761 | 64 | } | 22 | } |
2762 | 23 | CollectionManager XmlDataManager::getCollectionManager() | ||
2763 | 24 | { | ||
2764 | 25 | return CollectionManager(theManager->getCollectionManager()); | ||
2765 | 26 | } | ||
2766 | 27 | CollectionManager XmlDataManager::getW3CCollectionManager() | ||
2767 | 28 | { | ||
2768 | 29 | return CollectionManager(theManager->getW3CCollectionManager()); | ||
2769 | 30 | } | ||
2770 | 65 | 31 | ||
2772 | 66 | Iterator parseXML(const std::string& aDoc) | 32 | Iterator XmlDataManager::parseXML(const std::string& aDoc) |
2773 | 67 | { | 33 | { |
2774 | 68 | std::stringstream lDoc; | 34 | std::stringstream lDoc; |
2775 | 69 | lDoc << aDoc; | 35 | lDoc << aDoc; |
2776 | @@ -71,28 +37,7 @@ | |||
2777 | 71 | return Iterator(lItem); | 37 | return Iterator(lItem); |
2778 | 72 | } | 38 | } |
2779 | 73 | 39 | ||
2780 | 74 | }; | ||
2781 | 75 | 40 | ||
2782 | 76 | %} // end Implementation | 41 | %} // end Implementation |
2783 | 77 | 42 | ||
2805 | 78 | class DocumentManager | 43 | %include "XmlDataManager.h" |
2785 | 79 | { | ||
2786 | 80 | public: | ||
2787 | 81 | void put(const std::string& aName, Item aDoc); | ||
2788 | 82 | |||
2789 | 83 | void remove(const std::string& aName); | ||
2790 | 84 | |||
2791 | 85 | Item document(const std::string& aName); | ||
2792 | 86 | |||
2793 | 87 | bool isAvailableDocument(const std::string& aName); | ||
2794 | 88 | }; | ||
2795 | 89 | |||
2796 | 90 | |||
2797 | 91 | class XmlDataManager | ||
2798 | 92 | { | ||
2799 | 93 | public: | ||
2800 | 94 | DocumentManager getDocumentManager(); | ||
2801 | 95 | |||
2802 | 96 | Iterator parseXML(const std::string& aDoc); | ||
2803 | 97 | |||
2804 | 98 | }; // class XmlDataManager | ||
2806 | 99 | 44 | ||
2807 | === modified file 'swig/Zorba.i' | |||
2808 | --- swig/Zorba.i 2012-03-23 17:32:07 +0000 | |||
2809 | +++ swig/Zorba.i 2012-03-26 20:16:18 +0000 | |||
2810 | @@ -15,27 +15,26 @@ | |||
2811 | 15 | { | 15 | { |
2812 | 16 | return Zorba(zorba::Zorba::getInstance(aStore.getStore())); | 16 | return Zorba(zorba::Zorba::getInstance(aStore.getStore())); |
2813 | 17 | } | 17 | } |
2814 | 18 | |||
2815 | 19 | ItemFactory getItemFactory() | 18 | ItemFactory getItemFactory() |
2816 | 20 | { | 19 | { |
2817 | 21 | return ItemFactory(theZorba->getItemFactory()); | 20 | return ItemFactory(theZorba->getItemFactory()); |
2818 | 22 | } | 21 | } |
2820 | 23 | 22 | ||
2821 | 24 | StaticContext createStaticContext() | 23 | StaticContext createStaticContext() |
2822 | 25 | { | 24 | { |
2823 | 26 | return StaticContext(theZorba->createStaticContext()); | 25 | return StaticContext(theZorba->createStaticContext()); |
2824 | 27 | } | 26 | } |
2825 | 28 | 27 | ||
2826 | 28 | XQuery createQuery() | ||
2827 | 29 | { | ||
2828 | 30 | return XQuery(theZorba->createQuery()); | ||
2829 | 31 | } | ||
2830 | 32 | |||
2831 | 29 | XQuery compileQuery(const std::string& aStr) | 33 | XQuery compileQuery(const std::string& aStr) |
2832 | 30 | { | 34 | { |
2833 | 31 | return XQuery(theZorba->compileQuery(aStr)); | 35 | return XQuery(theZorba->compileQuery(aStr)); |
2834 | 32 | } | 36 | } |
2835 | 33 | 37 | ||
2836 | 34 | XQuery createQuery() | ||
2837 | 35 | { | ||
2838 | 36 | return XQuery(theZorba->createQuery()); | ||
2839 | 37 | } | ||
2840 | 38 | |||
2841 | 39 | XQuery compileQuery( | 38 | XQuery compileQuery( |
2842 | 40 | const std::string& aStr, | 39 | const std::string& aStr, |
2843 | 41 | StaticContext &aStaticContext ) | 40 | StaticContext &aStaticContext ) |
2844 | @@ -47,6 +46,22 @@ | |||
2845 | 47 | ) | 46 | ) |
2846 | 48 | ); | 47 | ); |
2847 | 49 | } | 48 | } |
2848 | 49 | /* | ||
2849 | 50 | XQuery compileQuery(const ZIStreamHelper& aZorbaStream) | ||
2850 | 51 | { | ||
2851 | 52 | zorbabuffer *buffer = new zorbabuffer(&const_cast<ZIStreamHelper &> (aZorbaStream)); | ||
2852 | 53 | std::istream stream = std::istream(buffer); | ||
2853 | 54 | //zistream stream = zistream(buffer); | ||
2854 | 55 | return XQuery(theZorba->compileQuery(stream)); | ||
2855 | 56 | } | ||
2856 | 57 | |||
2857 | 58 | XQuery compileQuery(const ZIStreamHelper& aZorbaStream, StaticContext &aStaticContext ) | ||
2858 | 59 | { | ||
2859 | 60 | zorbabuffer *buffer = new zorbabuffer(&const_cast<ZIStreamHelper &> (aZorbaStream)); | ||
2860 | 61 | std::istream stream = std::istream(buffer); | ||
2861 | 62 | return XQuery(theZorba->compileQuery(stream, aStaticContext.theStaticContext)); | ||
2862 | 63 | } | ||
2863 | 64 | */ | ||
2864 | 50 | 65 | ||
2865 | 51 | /* | 66 | /* |
2866 | 52 | //--->> DiagnosticHandler implementations are postponed | 67 | //--->> DiagnosticHandler implementations are postponed |
2867 | @@ -95,6 +110,18 @@ | |||
2868 | 95 | { | 110 | { |
2869 | 96 | theZorba->shutdown(); | 111 | theZorba->shutdown(); |
2870 | 97 | } | 112 | } |
2871 | 113 | std::string getVersion() { | ||
2872 | 114 | return zorba::Zorba::version().getVersion(); | ||
2873 | 115 | } | ||
2874 | 116 | int getMajorVersion() { | ||
2875 | 117 | return zorba::Zorba::version().getMajorVersion(); | ||
2876 | 118 | } | ||
2877 | 119 | int getMinorVersion() { | ||
2878 | 120 | return zorba::Zorba::version().getMinorVersion(); | ||
2879 | 121 | } | ||
2880 | 122 | int getPatchVersion() { | ||
2881 | 123 | return zorba::Zorba::version().getPatchVersion(); | ||
2882 | 124 | } | ||
2883 | 98 | 125 | ||
2884 | 99 | }; // class Zorba | 126 | }; // class Zorba |
2885 | 100 | 127 | ||
2886 | @@ -111,8 +138,9 @@ | |||
2887 | 111 | XQuery createQuery(); | 138 | XQuery createQuery(); |
2888 | 112 | XQuery compileQuery(const std::string& aStr); | 139 | XQuery compileQuery(const std::string& aStr); |
2889 | 113 | XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext ); | 140 | XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext ); |
2890 | 141 | //XQuery compileQuery(const ZIStreamHelper& aZorbaStream); | ||
2891 | 142 | //XQuery compileQuery(const ZIStreamHelper& aZorbaStream, StaticContext &aStaticContext ); | ||
2892 | 114 | ItemFactory getItemFactory(); | 143 | ItemFactory getItemFactory(); |
2893 | 115 | |||
2894 | 116 | /* | 144 | /* |
2895 | 117 | XQuery compileQuery(const std::string& aStr, DiagnosticHandler* aDiagnosticHandler); | 145 | XQuery compileQuery(const std::string& aStr, DiagnosticHandler* aDiagnosticHandler); |
2896 | 118 | XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext, | 146 | XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext, |
2897 | @@ -122,5 +150,9 @@ | |||
2898 | 122 | */ | 150 | */ |
2899 | 123 | XmlDataManager getXmlDataManager(); | 151 | XmlDataManager getXmlDataManager(); |
2900 | 124 | void shutdown(); | 152 | void shutdown(); |
2901 | 153 | std::string getVersion(); | ||
2902 | 154 | int getMajorVersion(); | ||
2903 | 155 | int getMinorVersion(); | ||
2904 | 156 | int getPatchVersion(); | ||
2905 | 125 | 157 | ||
2906 | 126 | }; // class Zorba | 158 | }; // class Zorba |
2907 | 127 | 159 | ||
2908 | === modified file 'swig/java/CMakeLists.txt' | |||
2909 | --- swig/java/CMakeLists.txt 2012-03-23 17:32:07 +0000 | |||
2910 | +++ swig/java/CMakeLists.txt 2012-03-26 20:16:18 +0000 | |||
2911 | @@ -60,8 +60,21 @@ | |||
2912 | 60 | MESSAGE(STATUS "Java module install path: " ${JAVA_SITEARCH_DIR}) | 60 | MESSAGE(STATUS "Java module install path: " ${JAVA_SITEARCH_DIR}) |
2913 | 61 | 61 | ||
2914 | 62 | FILE(GLOB JAVA_SWIG_FILES "${CMAKE_CURRENT_BINARY_DIR}/*.java") | 62 | FILE(GLOB JAVA_SWIG_FILES "${CMAKE_CURRENT_BINARY_DIR}/*.java") |
2917 | 63 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h") | 63 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h" COPYONLY) |
2918 | 64 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h") | 64 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h" COPYONLY) |
2919 | 65 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h" COPYONLY) | ||
2920 | 66 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h" COPYONLY) | ||
2921 | 67 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h" COPYONLY) | ||
2922 | 68 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h" COPYONLY) | ||
2923 | 69 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h" COPYONLY) | ||
2924 | 70 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h" COPYONLY) | ||
2925 | 71 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../SerializationOptions.h" "${CMAKE_CURRENT_BINARY_DIR}/SerializationOptions.h" COPYONLY) | ||
2926 | 72 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Collection.h" "${CMAKE_CURRENT_BINARY_DIR}/Collection.h" COPYONLY) | ||
2927 | 73 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY) | ||
2928 | 74 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY) | ||
2929 | 75 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY) | ||
2930 | 76 | # CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZInputStream.java" "${CMAKE_CURRENT_BINARY_DIR}/ZInputStream.java" COPYONLY) | ||
2931 | 77 | # CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/zistream.java" "${CMAKE_CURRENT_BINARY_DIR}/zistream.java" COPYONLY) | ||
2932 | 65 | 78 | ||
2933 | 66 | IF ( APPLE ) | 79 | IF ( APPLE ) |
2934 | 67 | INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_SWIG_LIB_PREFIX}libzorba_api.jnilib DESTINATION ${JAVA_SITEARCH_DIR}) | 80 | INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_SWIG_LIB_PREFIX}libzorba_api.jnilib DESTINATION ${JAVA_SITEARCH_DIR}) |
2935 | 68 | 81 | ||
2936 | === modified file 'swig/java/zorba_api.i' | |||
2937 | --- swig/java/zorba_api.i 2012-03-23 17:32:07 +0000 | |||
2938 | +++ swig/java/zorba_api.i 2012-03-26 20:16:18 +0000 | |||
2939 | @@ -20,5 +20,6 @@ | |||
2940 | 20 | // don't do a JNI call for constants and enums. | 20 | // don't do a JNI call for constants and enums. |
2941 | 21 | %javaconst(1); | 21 | %javaconst(1); |
2942 | 22 | 22 | ||
2943 | 23 | |||
2944 | 24 | |||
2945 | 23 | %include ../zorba_api.i | 25 | %include ../zorba_api.i |
2946 | 24 | |||
2947 | 25 | 26 | ||
2948 | === modified file 'swig/php/CMakeLists.txt' | |||
2949 | --- swig/php/CMakeLists.txt 2012-03-23 17:32:07 +0000 | |||
2950 | +++ swig/php/CMakeLists.txt 2012-03-26 20:16:18 +0000 | |||
2951 | @@ -35,6 +35,8 @@ | |||
2952 | 35 | ENDIF (APPLE) | 35 | ENDIF (APPLE) |
2953 | 36 | 36 | ||
2954 | 37 | IF (WIN32) | 37 | IF (WIN32) |
2955 | 38 | STRING(REGEX REPLACE "\\\\" "/" PHP5_LIBRARY "${PHP5_LIBRARY}") | ||
2956 | 39 | MESSAGE (STATUS "SWIG PHP: Link library: " ${PHP5_LIBRARY}) | ||
2957 | 38 | SWIG_LINK_LIBRARIES (zorba_api ${PHP5_LIBRARY}) | 40 | SWIG_LINK_LIBRARIES (zorba_api ${PHP5_LIBRARY}) |
2958 | 39 | ENDIF (WIN32) | 41 | ENDIF (WIN32) |
2959 | 40 | 42 | ||
2960 | @@ -47,6 +49,17 @@ | |||
2961 | 47 | 49 | ||
2962 | 48 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h") | 50 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h") |
2963 | 49 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h") | 51 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h") |
2964 | 52 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h") | ||
2965 | 53 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h") | ||
2966 | 54 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h") | ||
2967 | 55 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h") | ||
2968 | 56 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h") | ||
2969 | 57 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h") | ||
2970 | 58 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../SerializationOptions.h" "${CMAKE_CURRENT_BINARY_DIR}/SerializationOptions.h" COPYONLY) | ||
2971 | 59 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Collection.h" "${CMAKE_CURRENT_BINARY_DIR}/Collection.h" COPYONLY) | ||
2972 | 60 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY) | ||
2973 | 61 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY) | ||
2974 | 62 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY) | ||
2975 | 50 | 63 | ||
2976 | 51 | # The following fix was added because of the changes in CMake 2.8, which have the | 64 | # The following fix was added because of the changes in CMake 2.8, which have the |
2977 | 52 | # result of naming the java binding library "liblibzorba_api.so" instead of "libzorba_api.so" | 65 | # result of naming the java binding library "liblibzorba_api.so" instead of "libzorba_api.so" |
2978 | @@ -84,4 +97,5 @@ | |||
2979 | 84 | DESTINATION share/php ) | 97 | DESTINATION share/php ) |
2980 | 85 | ENDIF (MSVC_IDE) | 98 | ENDIF (MSVC_IDE) |
2981 | 86 | ENDIF (NOT WIN32 OR CYGWIN) | 99 | ENDIF (NOT WIN32 OR CYGWIN) |
2982 | 100 | ADD_SUBDIRECTORY (tests) | ||
2983 | 87 | ENDIF (NOT PHP5_FOUND) | 101 | ENDIF (NOT PHP5_FOUND) |
2984 | 88 | 102 | ||
2985 | === added directory 'swig/php/tests' | |||
2986 | === added file 'swig/php/tests/CMakeLists.txt' | |||
2987 | --- swig/php/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
2988 | +++ swig/php/tests/CMakeLists.txt 2012-03-26 20:16:18 +0000 | |||
2989 | @@ -0,0 +1,90 @@ | |||
2990 | 1 | # Copyright 2006-2011 The FLWOR Foundation. | ||
2991 | 2 | # | ||
2992 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
2993 | 4 | # you may not use this file except in compliance with the License. | ||
2994 | 5 | # You may obtain a copy of the License at | ||
2995 | 6 | # | ||
2996 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
2997 | 8 | # | ||
2998 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
2999 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
3000 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3001 | 12 | # See the License for the specific language governing permissions and | ||
3002 | 13 | # limitations under the License. | ||
3003 | 14 | MESSAGE(STATUS "Adding tests for PHP Binding") | ||
3004 | 15 | |||
3005 | 16 | SET(phpPath ${CMAKE_BINARY_DIR}/swig/php) | ||
3006 | 17 | IF (MSVC_IDE) | ||
3007 | 18 | SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php/@CMAKE_BUILD_TYPE@) | ||
3008 | 19 | ELSE (MSVC_IDE) | ||
3009 | 20 | SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php) | ||
3010 | 21 | ENDIF (MSVC_IDE) | ||
3011 | 22 | SET(phpIncludePath ${CMAKE_BINARY_DIR}/swig/php) | ||
3012 | 23 | MESSAGE(STATUS "PHP Path:" ${phpPath}) | ||
3013 | 24 | MESSAGE(STATUS "PHP Extension Path: " ${phpExtensionPath}) | ||
3014 | 25 | MESSAGE(STATUS "PHP Include Path: " ${phpExtensionPath}) | ||
3015 | 26 | |||
3016 | 27 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/php.ini.in ${CMAKE_CURRENT_BINARY_DIR}/php.ini) | ||
3017 | 28 | |||
3018 | 29 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/books.xml ${CMAKE_CURRENT_BINARY_DIR}/books.xml COPYONLY) | ||
3019 | 30 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/compilerHints.xq ${CMAKE_CURRENT_BINARY_DIR}/compilerHints.xq COPYONLY) | ||
3020 | 31 | |||
3021 | 32 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test01.php ${CMAKE_CURRENT_BINARY_DIR}/test01.php) | ||
3022 | 33 | ADD_TEST("php_test01" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test01.php) | ||
3023 | 34 | SET_TESTS_PROPERTIES("php_test01" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
3024 | 35 | |||
3025 | 36 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test02.php ${CMAKE_CURRENT_BINARY_DIR}/test02.php) | ||
3026 | 37 | ADD_TEST("php_test02" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test02.php) | ||
3027 | 38 | SET_TESTS_PROPERTIES("php_test02" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
3028 | 39 | |||
3029 | 40 | #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test03.php ${CMAKE_CURRENT_BINARY_DIR}/test03.php) | ||
3030 | 41 | #ADD_TEST("php_test03" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test03.php) | ||
3031 | 42 | #SET_TESTS_PROPERTIES("php_test03" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
3032 | 43 | |||
3033 | 44 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test04.php ${CMAKE_CURRENT_BINARY_DIR}/test04.php) | ||
3034 | 45 | ADD_TEST("php_test04" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test04.php) | ||
3035 | 46 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test04.xq ${CMAKE_CURRENT_BINARY_DIR}/test04.xq COPYONLY) | ||
3036 | 47 | SET_TESTS_PROPERTIES("php_test04" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
3037 | 48 | |||
3038 | 49 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test05.php ${CMAKE_CURRENT_BINARY_DIR}/test05.php) | ||
3039 | 50 | ADD_TEST("php_test05" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test05.php) | ||
3040 | 51 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test05.xq ${CMAKE_CURRENT_BINARY_DIR}/test05.xq COPYONLY) | ||
3041 | 52 | SET_TESTS_PROPERTIES("php_test05" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
3042 | 53 | |||
3043 | 54 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test06.php ${CMAKE_CURRENT_BINARY_DIR}/test06.php) | ||
3044 | 55 | ADD_TEST("php_test06" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test06.php) | ||
3045 | 56 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test06.xq ${CMAKE_CURRENT_BINARY_DIR}/test06.xq COPYONLY) | ||
3046 | 57 | SET_TESTS_PROPERTIES("php_test06" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
3047 | 58 | |||
3048 | 59 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test07.php ${CMAKE_CURRENT_BINARY_DIR}/test07.php) | ||
3049 | 60 | ADD_TEST("php_test07" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test07.php) | ||
3050 | 61 | SET_TESTS_PROPERTIES("php_test07" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
3051 | 62 | |||
3052 | 63 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test08.php ${CMAKE_CURRENT_BINARY_DIR}/test08.php) | ||
3053 | 64 | ADD_TEST("php_test08" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test08.php) | ||
3054 | 65 | SET_TESTS_PROPERTIES("php_test08" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
3055 | 66 | |||
3056 | 67 | #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test09.php ${CMAKE_CURRENT_BINARY_DIR}/test09.php) | ||
3057 | 68 | #ADD_TEST("php_test09" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test09.php) | ||
3058 | 69 | #SET_TESTS_PROPERTIES("php_test09" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
3059 | 70 | |||
3060 | 71 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test10.php ${CMAKE_CURRENT_BINARY_DIR}/test10.php) | ||
3061 | 72 | ADD_TEST("php_test10" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test10.php) | ||
3062 | 73 | SET_TESTS_PROPERTIES("php_test10" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
3063 | 74 | |||
3064 | 75 | #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test11.php ${CMAKE_CURRENT_BINARY_DIR}/test11.php) | ||
3065 | 76 | #ADD_TEST("php_test11" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test11.php) | ||
3066 | 77 | #SET_TESTS_PROPERTIES("php_test11" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
3067 | 78 | |||
3068 | 79 | #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test12.php ${CMAKE_CURRENT_BINARY_DIR}/test12.php) | ||
3069 | 80 | #ADD_TEST("php_test12" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test12.php) | ||
3070 | 81 | #SET_TESTS_PROPERTIES("php_test12" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
3071 | 82 | |||
3072 | 83 | #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test13.php ${CMAKE_CURRENT_BINARY_DIR}/test13.php) | ||
3073 | 84 | #ADD_TEST("php_test13" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test13.php) | ||
3074 | 85 | #SET_TESTS_PROPERTIES("php_test13" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
3075 | 86 | |||
3076 | 87 | #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test14.php ${CMAKE_CURRENT_BINARY_DIR}/test14.php) | ||
3077 | 88 | #ADD_TEST("php_test14" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test14.php) | ||
3078 | 89 | #SET_TESTS_PROPERTIES("php_test14" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
3079 | 90 | |||
3080 | 0 | 91 | ||
3081 | === added file 'swig/php/tests/books.xml' | |||
3082 | --- swig/php/tests/books.xml 1970-01-01 00:00:00 +0000 | |||
3083 | +++ swig/php/tests/books.xml 2012-03-26 20:16:18 +0000 | |||
3084 | @@ -0,0 +1,11 @@ | |||
3085 | 1 | <?xml version="1.0" encoding="UTF-8" ?> | ||
3086 | 2 | <books> | ||
3087 | 3 | <book> | ||
3088 | 4 | <title>Book 1</title> | ||
3089 | 5 | <author>Author 1</author> | ||
3090 | 6 | </book> | ||
3091 | 7 | <book featured="YES"> | ||
3092 | 8 | <title>Book 2</title> | ||
3093 | 9 | <author>Author 2</author> | ||
3094 | 10 | </book> | ||
3095 | 11 | </books> | ||
3096 | 0 | 12 | ||
3097 | === added file 'swig/php/tests/compilerHints.xq' | |||
3098 | --- swig/php/tests/compilerHints.xq 1970-01-01 00:00:00 +0000 | |||
3099 | +++ swig/php/tests/compilerHints.xq 2012-03-26 20:16:18 +0000 | |||
3100 | @@ -0,0 +1,4 @@ | |||
3101 | 1 | for tumbling window $w in (2, 4, 6, 8, 10, 12, 14) | ||
3102 | 2 | start at $s when fn:true() | ||
3103 | 3 | only end at $e when $e - $s eq 2 | ||
3104 | 4 | return avg($w) | ||
3105 | 0 | 5 | ||
3106 | === added file 'swig/php/tests/php.ini.in' | |||
3107 | --- swig/php/tests/php.ini.in 1970-01-01 00:00:00 +0000 | |||
3108 | +++ swig/php/tests/php.ini.in 2012-03-26 20:16:18 +0000 | |||
3109 | @@ -0,0 +1,3 @@ | |||
3110 | 1 | enable_dl=On | ||
3111 | 2 | extension_dir=@phpExtensionPath@ | ||
3112 | 3 | include_path=".:@phpIncludePath@" | ||
3113 | 0 | \ No newline at end of file | 4 | \ No newline at end of file |
3114 | 1 | 5 | ||
3115 | === added file 'swig/php/tests/test01.php' | |||
3116 | --- swig/php/tests/test01.php 1970-01-01 00:00:00 +0000 | |||
3117 | +++ swig/php/tests/test01.php 2012-03-26 20:16:18 +0000 | |||
3118 | @@ -0,0 +1,29 @@ | |||
3119 | 1 | <? | ||
3120 | 2 | /* | ||
3121 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
3122 | 4 | * | ||
3123 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3124 | 6 | * you may not use this file except in compliance with the License. | ||
3125 | 7 | * You may obtain a copy of the License at | ||
3126 | 8 | * | ||
3127 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3128 | 10 | * | ||
3129 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
3130 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
3131 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3132 | 14 | * See the License for the specific language governing permissions and | ||
3133 | 15 | * limitations under the License. | ||
3134 | 16 | */ | ||
3135 | 17 | |||
3136 | 18 | require '@phpPath@/Zorba/zorba_api_wrapper.php'; | ||
3137 | 19 | |||
3138 | 20 | print "Running: Get zorba instance and shutdown\n"; | ||
3139 | 21 | |||
3140 | 22 | $store = InMemoryStore::getInstance(); | ||
3141 | 23 | $zorba = Zorba::getInstance($store); | ||
3142 | 24 | |||
3143 | 25 | $zorba->shutdown(); | ||
3144 | 26 | InMemoryStore::shutdown($store); | ||
3145 | 27 | |||
3146 | 28 | print "Success"; | ||
3147 | 29 | ?> | ||
3148 | 0 | \ No newline at end of file | 30 | \ No newline at end of file |
3149 | 1 | 31 | ||
3150 | === added file 'swig/php/tests/test02.php' | |||
3151 | --- swig/php/tests/test02.php 1970-01-01 00:00:00 +0000 | |||
3152 | +++ swig/php/tests/test02.php 2012-03-26 20:16:18 +0000 | |||
3153 | @@ -0,0 +1,44 @@ | |||
3154 | 1 | <? | ||
3155 | 2 | /* | ||
3156 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
3157 | 4 | * | ||
3158 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3159 | 6 | * you may not use this file except in compliance with the License. | ||
3160 | 7 | * You may obtain a copy of the License at | ||
3161 | 8 | * | ||
3162 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3163 | 10 | * | ||
3164 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
3165 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
3166 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3167 | 14 | * See the License for the specific language governing permissions and | ||
3168 | 15 | * limitations under the License. | ||
3169 | 16 | */ | ||
3170 | 17 | |||
3171 | 18 | require '@phpPath@/Zorba/zorba_api_wrapper.php'; | ||
3172 | 19 | |||
3173 | 20 | function test(Zorba $aZorba) { | ||
3174 | 21 | $lQuery = $aZorba->compileQuery("(1,2,3,4,5)"); | ||
3175 | 22 | $iter = $lQuery->iterator(); | ||
3176 | 23 | $iter->open(); | ||
3177 | 24 | $item = Item::createEmptyItem(); | ||
3178 | 25 | while ($iter->next($item)) { | ||
3179 | 26 | print $item->getStringValue()."\n"; | ||
3180 | 27 | } | ||
3181 | 28 | $iter->close(); | ||
3182 | 29 | $iter->destroy(); | ||
3183 | 30 | return true; | ||
3184 | 31 | } | ||
3185 | 32 | |||
3186 | 33 | |||
3187 | 34 | $store = InMemoryStore::getInstance(); | ||
3188 | 35 | $zorba = Zorba::getInstance($store); | ||
3189 | 36 | |||
3190 | 37 | print "Running: Compile query string\n"; | ||
3191 | 38 | test($zorba); | ||
3192 | 39 | print "Success"; | ||
3193 | 40 | |||
3194 | 41 | $zorba->shutdown(); | ||
3195 | 42 | InMemoryStore::shutdown($store); | ||
3196 | 43 | |||
3197 | 44 | ?> | ||
3198 | 0 | \ No newline at end of file | 45 | \ No newline at end of file |
3199 | 1 | 46 | ||
3200 | === added file 'swig/php/tests/test03.php' | |||
3201 | --- swig/php/tests/test03.php 1970-01-01 00:00:00 +0000 | |||
3202 | +++ swig/php/tests/test03.php 2012-03-26 20:16:18 +0000 | |||
3203 | @@ -0,0 +1,48 @@ | |||
3204 | 1 | <? | ||
3205 | 2 | /* | ||
3206 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
3207 | 4 | * | ||
3208 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3209 | 6 | * you may not use this file except in compliance with the License. | ||
3210 | 7 | * You may obtain a copy of the License at | ||
3211 | 8 | * | ||
3212 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3213 | 10 | * | ||
3214 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
3215 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
3216 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3217 | 14 | * See the License for the specific language governing permissions and | ||
3218 | 15 | * limitations under the License. | ||
3219 | 16 | */ | ||
3220 | 17 | |||
3221 | 18 | require '@phpPath@/Zorba/zorba_api_wrapper.php'; | ||
3222 | 19 | |||
3223 | 20 | class MyDiagnosticHandler(DiagnosticHandler handler) { | ||
3224 | 21 | funtion error(self, *args) { | ||
3225 | 22 | print "Error args: ", args; | ||
3226 | 23 | } | ||
3227 | 24 | } | ||
3228 | 25 | |||
3229 | 26 | function test(Zorba $aZorba) | ||
3230 | 27 | { | ||
3231 | 28 | diagnosticHandler = MyDiagnosticHandler() | ||
3232 | 29 | try { | ||
3233 | 30 | xquery = zorba.compileQuery("1 div 0", diagnosticHandler); | ||
3234 | 31 | print xquery.execute() | ||
3235 | 32 | } catch (Exception e) { | ||
3236 | 33 | print "Caught error: "; | ||
3237 | 34 | } | ||
3238 | 35 | return | ||
3239 | 36 | } | ||
3240 | 37 | |||
3241 | 38 | $store = InMemoryStore::getInstance(); | ||
3242 | 39 | $zorba = Zorba::getInstance($store); | ||
3243 | 40 | |||
3244 | 41 | print "Running: Compile query string using Diagnostic Handler" | ||
3245 | 42 | test($zorba); | ||
3246 | 43 | print "Success"; | ||
3247 | 44 | |||
3248 | 45 | $zorba->shutdown(); | ||
3249 | 46 | InMemoryStore::shutdown($store); | ||
3250 | 47 | |||
3251 | 48 | ?> | ||
3252 | 0 | \ No newline at end of file | 49 | \ No newline at end of file |
3253 | 1 | 50 | ||
3254 | === added file 'swig/php/tests/test04.php' | |||
3255 | --- swig/php/tests/test04.php 1970-01-01 00:00:00 +0000 | |||
3256 | +++ swig/php/tests/test04.php 2012-03-26 20:16:18 +0000 | |||
3257 | @@ -0,0 +1,43 @@ | |||
3258 | 1 | <? | ||
3259 | 2 | /* | ||
3260 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
3261 | 4 | * | ||
3262 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3263 | 6 | * you may not use this file except in compliance with the License. | ||
3264 | 7 | * You may obtain a copy of the License at | ||
3265 | 8 | * | ||
3266 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3267 | 10 | * | ||
3268 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
3269 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
3270 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3271 | 14 | * See the License for the specific language governing permissions and | ||
3272 | 15 | * limitations under the License. | ||
3273 | 16 | */ | ||
3274 | 17 | |||
3275 | 18 | require '@phpPath@/Zorba/zorba_api_wrapper.php'; | ||
3276 | 19 | |||
3277 | 20 | function test(Zorba $aZorba) { | ||
3278 | 21 | #Read and write result | ||
3279 | 22 | $filename = 'test04.xq'; | ||
3280 | 23 | print "Executing: $filename\n"; | ||
3281 | 24 | $f = fopen($filename, 'r'); | ||
3282 | 25 | $contents = fread($f, filesize($filename)); | ||
3283 | 26 | fclose($f); | ||
3284 | 27 | $xquery = $aZorba->compileQuery($contents); | ||
3285 | 28 | $result = $xquery->execute(); | ||
3286 | 29 | print $result."\n"; | ||
3287 | 30 | return; | ||
3288 | 31 | } | ||
3289 | 32 | |||
3290 | 33 | $store = InMemoryStore::getInstance(); | ||
3291 | 34 | $zorba = Zorba::getInstance($store); | ||
3292 | 35 | |||
3293 | 36 | print "Running: XQuery execute\n"; | ||
3294 | 37 | test($zorba); | ||
3295 | 38 | print "Success"; | ||
3296 | 39 | |||
3297 | 40 | $zorba->shutdown(); | ||
3298 | 41 | InMemoryStore::shutdown($store); | ||
3299 | 42 | |||
3300 | 43 | ?> | ||
3301 | 0 | \ No newline at end of file | 44 | \ No newline at end of file |
3302 | 1 | 45 | ||
3303 | === added file 'swig/php/tests/test04.xq' | |||
3304 | --- swig/php/tests/test04.xq 1970-01-01 00:00:00 +0000 | |||
3305 | +++ swig/php/tests/test04.xq 2012-03-26 20:16:18 +0000 | |||
3306 | @@ -0,0 +1,4 @@ | |||
3307 | 1 | for tumbling window $w in (2, 4, 6, 8, 10, 12, 14) | ||
3308 | 2 | start at $s when fn:true() | ||
3309 | 3 | only end at $e when $e - $s eq 2 | ||
3310 | 4 | return avg($w) | ||
3311 | 0 | 5 | ||
3312 | === added file 'swig/php/tests/test05.php' | |||
3313 | --- swig/php/tests/test05.php 1970-01-01 00:00:00 +0000 | |||
3314 | +++ swig/php/tests/test05.php 2012-03-26 20:16:18 +0000 | |||
3315 | @@ -0,0 +1,43 @@ | |||
3316 | 1 | <? | ||
3317 | 2 | /* | ||
3318 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
3319 | 4 | * | ||
3320 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3321 | 6 | * you may not use this file except in compliance with the License. | ||
3322 | 7 | * You may obtain a copy of the License at | ||
3323 | 8 | * | ||
3324 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3325 | 10 | * | ||
3326 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
3327 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
3328 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3329 | 14 | * See the License for the specific language governing permissions and | ||
3330 | 15 | * limitations under the License. | ||
3331 | 16 | */ | ||
3332 | 17 | |||
3333 | 18 | require '@phpPath@/Zorba/zorba_api_wrapper.php'; | ||
3334 | 19 | |||
3335 | 20 | function test(Zorba $aZorba) { | ||
3336 | 21 | #Read and write result | ||
3337 | 22 | $filename = 'test05.xq'; | ||
3338 | 23 | print "Executing: $filename\n"; | ||
3339 | 24 | $f = fopen($filename, 'r'); | ||
3340 | 25 | $contents = fread($f, filesize($filename)); | ||
3341 | 26 | fclose($f); | ||
3342 | 27 | $xquery = $aZorba->compileQuery($contents); | ||
3343 | 28 | $result = $xquery->printPlanAsXML(); | ||
3344 | 29 | print $result."\n"; | ||
3345 | 30 | return; | ||
3346 | 31 | } | ||
3347 | 32 | |||
3348 | 33 | $store = InMemoryStore::getInstance(); | ||
3349 | 34 | $zorba = Zorba::getInstance($store); | ||
3350 | 35 | |||
3351 | 36 | print "Running: XQuery execute - printPlanAsXML\n"; | ||
3352 | 37 | test($zorba); | ||
3353 | 38 | print "Success"; | ||
3354 | 39 | |||
3355 | 40 | $zorba->shutdown(); | ||
3356 | 41 | InMemoryStore::shutdown($store); | ||
3357 | 42 | |||
3358 | 43 | ?> | ||
3359 | 0 | \ No newline at end of file | 44 | \ No newline at end of file |
3360 | 1 | 45 | ||
3361 | === added file 'swig/php/tests/test05.xq' | |||
3362 | --- swig/php/tests/test05.xq 1970-01-01 00:00:00 +0000 | |||
3363 | +++ swig/php/tests/test05.xq 2012-03-26 20:16:18 +0000 | |||
3364 | @@ -0,0 +1,7 @@ | |||
3365 | 1 | for $x in (5,6,7,1,2,3,4) | ||
3366 | 2 | where $x < 4 | ||
3367 | 3 | for $y in (4,9,6,8,2) | ||
3368 | 4 | let $z := $x * $y | ||
3369 | 5 | where $z > 20 | ||
3370 | 6 | return | ||
3371 | 7 | <value x="{$x}" y="{$y}">{$z}</value> | ||
3372 | 0 | \ No newline at end of file | 8 | \ No newline at end of file |
3373 | 1 | 9 | ||
3374 | === added file 'swig/php/tests/test06.php' | |||
3375 | --- swig/php/tests/test06.php 1970-01-01 00:00:00 +0000 | |||
3376 | +++ swig/php/tests/test06.php 2012-03-26 20:16:18 +0000 | |||
3377 | @@ -0,0 +1,43 @@ | |||
3378 | 1 | <? | ||
3379 | 2 | /* | ||
3380 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
3381 | 4 | * | ||
3382 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3383 | 6 | * you may not use this file except in compliance with the License. | ||
3384 | 7 | * You may obtain a copy of the License at | ||
3385 | 8 | * | ||
3386 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3387 | 10 | * | ||
3388 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
3389 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
3390 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3391 | 14 | * See the License for the specific language governing permissions and | ||
3392 | 15 | * limitations under the License. | ||
3393 | 16 | */ | ||
3394 | 17 | |||
3395 | 18 | require '@phpPath@/Zorba/zorba_api_wrapper.php'; | ||
3396 | 19 | |||
3397 | 20 | function test(Zorba $aZorba) { | ||
3398 | 21 | #Read and write result | ||
3399 | 22 | $filename = 'test06.xq'; | ||
3400 | 23 | print "Executing: $filename\n"; | ||
3401 | 24 | $f = fopen($filename, 'r'); | ||
3402 | 25 | $contents = fread($f, filesize($filename)); | ||
3403 | 26 | fclose($f); | ||
3404 | 27 | $xquery = $aZorba->compileQuery($contents); | ||
3405 | 28 | $result = $xquery->printPlanAsDOT(); | ||
3406 | 29 | print $result."\n"; | ||
3407 | 30 | return; | ||
3408 | 31 | } | ||
3409 | 32 | |||
3410 | 33 | $store = InMemoryStore::getInstance(); | ||
3411 | 34 | $zorba = Zorba::getInstance($store); | ||
3412 | 35 | |||
3413 | 36 | print "Running: XQuery execute - printPlanAsDOT\n"; | ||
3414 | 37 | test($zorba); | ||
3415 | 38 | print "Success"; | ||
3416 | 39 | |||
3417 | 40 | $zorba->shutdown(); | ||
3418 | 41 | InMemoryStore::shutdown($store); | ||
3419 | 42 | |||
3420 | 43 | ?> | ||
3421 | 0 | \ No newline at end of file | 44 | \ No newline at end of file |
3422 | 1 | 45 | ||
3423 | === added file 'swig/php/tests/test06.xq' | |||
3424 | --- swig/php/tests/test06.xq 1970-01-01 00:00:00 +0000 | |||
3425 | +++ swig/php/tests/test06.xq 2012-03-26 20:16:18 +0000 | |||
3426 | @@ -0,0 +1,7 @@ | |||
3427 | 1 | for $x in (5,6,7,1,2,3,4) | ||
3428 | 2 | where $x < 4 | ||
3429 | 3 | for $y in (4,9,6,8,2) | ||
3430 | 4 | let $z := $x * $y | ||
3431 | 5 | where $z > 20 | ||
3432 | 6 | return | ||
3433 | 7 | <value x="{$x}" y="{$y}">{$z}</value> | ||
3434 | 0 | \ No newline at end of file | 8 | \ No newline at end of file |
3435 | 1 | 9 | ||
3436 | === added file 'swig/php/tests/test07.php' | |||
3437 | --- swig/php/tests/test07.php 1970-01-01 00:00:00 +0000 | |||
3438 | +++ swig/php/tests/test07.php 2012-03-26 20:16:18 +0000 | |||
3439 | @@ -0,0 +1,56 @@ | |||
3440 | 1 | <? | ||
3441 | 2 | /* | ||
3442 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
3443 | 4 | * | ||
3444 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3445 | 6 | * you may not use this file except in compliance with the License. | ||
3446 | 7 | * You may obtain a copy of the License at | ||
3447 | 8 | * | ||
3448 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3449 | 10 | * | ||
3450 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
3451 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
3452 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3453 | 14 | * See the License for the specific language governing permissions and | ||
3454 | 15 | * limitations under the License. | ||
3455 | 16 | */ | ||
3456 | 17 | |||
3457 | 18 | require '@phpPath@/Zorba/zorba_api_wrapper.php'; | ||
3458 | 19 | |||
3459 | 20 | function test(Zorba $aZorba) { | ||
3460 | 21 | $filename = 'books.xml'; | ||
3461 | 22 | $f = fopen($filename, 'r'); | ||
3462 | 23 | $contents = fread($f, filesize($filename)); | ||
3463 | 24 | fclose($f); | ||
3464 | 25 | |||
3465 | 26 | $dataManager = $aZorba->getXmlDataManager(); | ||
3466 | 27 | $docIter = $dataManager->parseXML($contents); | ||
3467 | 28 | $docIter->open(); | ||
3468 | 29 | |||
3469 | 30 | $doc = Item::createEmptyItem(); | ||
3470 | 31 | $docIter->next($doc); | ||
3471 | 32 | |||
3472 | 33 | $docIter->close(); | ||
3473 | 34 | $docIter->destroy(); | ||
3474 | 35 | |||
3475 | 36 | $docManager = $dataManager->getDocumentManager(); | ||
3476 | 37 | $docManager->put("my_fake_books.xml", $doc); | ||
3477 | 38 | $xquery = $aZorba->compileQuery("doc('my_fake_books.xml')"); | ||
3478 | 39 | |||
3479 | 40 | $result = $xquery->execute(); | ||
3480 | 41 | print $result."\n"; | ||
3481 | 42 | |||
3482 | 43 | return; | ||
3483 | 44 | } | ||
3484 | 45 | |||
3485 | 46 | $store = InMemoryStore::getInstance(); | ||
3486 | 47 | $zorba = Zorba::getInstance($store); | ||
3487 | 48 | |||
3488 | 49 | print "Running: XQuery execute - parsing XML\n"; | ||
3489 | 50 | test($zorba); | ||
3490 | 51 | print "Success"; | ||
3491 | 52 | |||
3492 | 53 | $zorba->shutdown(); | ||
3493 | 54 | InMemoryStore::shutdown($store); | ||
3494 | 55 | |||
3495 | 56 | ?> | ||
3496 | 0 | \ No newline at end of file | 57 | \ No newline at end of file |
3497 | 1 | 58 | ||
3498 | === added file 'swig/php/tests/test08.php' | |||
3499 | --- swig/php/tests/test08.php 1970-01-01 00:00:00 +0000 | |||
3500 | +++ swig/php/tests/test08.php 2012-03-26 20:16:18 +0000 | |||
3501 | @@ -0,0 +1,120 @@ | |||
3502 | 1 | <? | ||
3503 | 2 | /* | ||
3504 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
3505 | 4 | * | ||
3506 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3507 | 6 | * you may not use this file except in compliance with the License. | ||
3508 | 7 | * You may obtain a copy of the License at | ||
3509 | 8 | * | ||
3510 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3511 | 10 | * | ||
3512 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
3513 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
3514 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3515 | 14 | * See the License for the specific language governing permissions and | ||
3516 | 15 | * limitations under the License. | ||
3517 | 16 | */ | ||
3518 | 17 | |||
3519 | 18 | require '@phpPath@/Zorba/zorba_api_wrapper.php'; | ||
3520 | 19 | |||
3521 | 20 | function println($string) { | ||
3522 | 21 | print $string."\n"; | ||
3523 | 22 | } | ||
3524 | 23 | |||
3525 | 24 | function test(Zorba $aZorba) { | ||
3526 | 25 | #Read and write result | ||
3527 | 26 | println ("Executing: test08.xq"); | ||
3528 | 27 | $lines = '(1, xs:int(2),"bla", <a><b att="{(3, xs:int(4),"foo", "bar")}"/>text<!--a comment--><?pi?></a>)'; | ||
3529 | 28 | $xquery = $aZorba->compileQuery($lines); | ||
3530 | 29 | $result = $xquery->execute(); | ||
3531 | 30 | println ($result); | ||
3532 | 31 | |||
3533 | 32 | println ("Iterator:"); | ||
3534 | 33 | $iterator = $xquery->iterator(); | ||
3535 | 34 | |||
3536 | 35 | printIterator($iterator, ""); | ||
3537 | 36 | |||
3538 | 37 | $handle = fopen('test8_result.xml', 'w'); | ||
3539 | 38 | fwrite($handle, $result); | ||
3540 | 39 | fclose($handle); | ||
3541 | 40 | return; | ||
3542 | 41 | } | ||
3543 | 42 | |||
3544 | 43 | function printIterator($iterator, $pre) { | ||
3545 | 44 | $item = Item::createEmptyItem(); | ||
3546 | 45 | $iterator->open(); | ||
3547 | 46 | while ($iterator->next($item)) { | ||
3548 | 47 | printItem($item, $pre); | ||
3549 | 48 | } | ||
3550 | 49 | $iterator->close(); | ||
3551 | 50 | } | ||
3552 | 51 | |||
3553 | 52 | function printItem($item, $pre) { | ||
3554 | 53 | if ($item->isAtomic()) { | ||
3555 | 54 | $typeItem = $item->getType(); | ||
3556 | 55 | println ($pre . "Leaf Atomic: '" . $item->getStringValue() . "' \ttype:" . $typeItem->getStringValue()); | ||
3557 | 56 | return; | ||
3558 | 57 | } | ||
3559 | 58 | |||
3560 | 59 | if ($item->isNode()) { | ||
3561 | 60 | $kind = $item->getNodeKind(); | ||
3562 | 61 | |||
3563 | 62 | if ($kind == 0) { # anyNode | ||
3564 | 63 | println ($pre . 'Any node'); | ||
3565 | 64 | println ($pre . " Children:"); | ||
3566 | 65 | printIterator($item->getChildren() . $pre." "); | ||
3567 | 66 | } | ||
3568 | 67 | if ($kind == 1) { # doc | ||
3569 | 68 | println ($pre . 'Doc'); | ||
3570 | 69 | println ($pre . " Children:"); | ||
3571 | 70 | printIterator($item->getChildren() . $pre." "); | ||
3572 | 71 | } | ||
3573 | 72 | if ($kind == 2) { # element | ||
3574 | 73 | $nodeName = Item::createEmptyItem(); | ||
3575 | 74 | $item->getNodeName($nodeName); | ||
3576 | 75 | $typeItem = $item->getType(); | ||
3577 | 76 | println ($pre . "Start Element: " . $nodeName->getStringValue() . " \ttype:" . $typeItem->getStringValue()); | ||
3578 | 77 | println ($pre . " Attributes:"); | ||
3579 | 78 | printIterator($item->getAttributes(), $pre." "); | ||
3580 | 79 | println ($pre . " Children:"); | ||
3581 | 80 | printIterator($item->getChildren(), $pre." "); | ||
3582 | 81 | println ($pre . "End Element: " . $nodeName->getStringValue()); | ||
3583 | 82 | } | ||
3584 | 83 | if ($kind == 3) { # attribute | ||
3585 | 84 | $nodeName = Item::createEmptyItem(); | ||
3586 | 85 | $item->getNodeName($nodeName); | ||
3587 | 86 | $typeItem = $item->getType(); | ||
3588 | 87 | println ($pre . "Attribute: " . $nodeName->getStringValue() . "= '" . $item->getStringValue() . " \ttype:" . $typeItem->getStringValue()); | ||
3589 | 88 | println ($pre." Atomization value:"); | ||
3590 | 89 | printIterator($item->getAtomizationValue(), $pre." "); | ||
3591 | 90 | } | ||
3592 | 91 | if ($kind == 4) { # text | ||
3593 | 92 | $typeItem = $item->getType(); | ||
3594 | 93 | println ($pre . "Text: " . $item->getStringValue() . " \ttype:" . $typeItem->getStringValue()); | ||
3595 | 94 | println ($pre." Atomization value:"); | ||
3596 | 95 | printIterator($item->getAtomizationValue(), $pre." "); | ||
3597 | 96 | } | ||
3598 | 97 | if ($kind == 5) { # pi | ||
3599 | 98 | $nodeName = Item::createEmptyItem(); | ||
3600 | 99 | $item->getNodeName($nodeName); | ||
3601 | 100 | println ($pre . "Pi: " . $nodeName->getStringValue()); | ||
3602 | 101 | } | ||
3603 | 102 | if ($kind == 6) { # comment | ||
3604 | 103 | println ($pre . "Comment: " . $item->getStringValue()); | ||
3605 | 104 | } | ||
3606 | 105 | } else { | ||
3607 | 106 | println ($pre."Item not Node, not Atomic"); | ||
3608 | 107 | } | ||
3609 | 108 | } | ||
3610 | 109 | |||
3611 | 110 | $store = InMemoryStore::getInstance(); | ||
3612 | 111 | $zorba = Zorba::getInstance($store); | ||
3613 | 112 | |||
3614 | 113 | println ("Running: XQuery execute - Get Iterator and println (info from its items\n"); | ||
3615 | 114 | test($zorba); | ||
3616 | 115 | println ("Success"); | ||
3617 | 116 | |||
3618 | 117 | $zorba->shutdown(); | ||
3619 | 118 | InMemoryStore::shutdown($store); | ||
3620 | 119 | |||
3621 | 120 | ?> | ||
3622 | 0 | \ No newline at end of file | 121 | \ No newline at end of file |
3623 | 1 | 122 | ||
3624 | === added file 'swig/php/tests/test09.php' | |||
3625 | --- swig/php/tests/test09.php 1970-01-01 00:00:00 +0000 | |||
3626 | +++ swig/php/tests/test09.php 2012-03-26 20:16:18 +0000 | |||
3627 | @@ -0,0 +1,92 @@ | |||
3628 | 1 | <? | ||
3629 | 2 | /* | ||
3630 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
3631 | 4 | * | ||
3632 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3633 | 6 | * you may not use this file except in compliance with the License. | ||
3634 | 7 | * You may obtain a copy of the License at | ||
3635 | 8 | * | ||
3636 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3637 | 10 | * | ||
3638 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
3639 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
3640 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3641 | 14 | * See the License for the specific language governing permissions and | ||
3642 | 15 | * limitations under the License. | ||
3643 | 16 | */ | ||
3644 | 17 | |||
3645 | 18 | require '@phpPath@/Zorba/zorba_api_wrapper.php'; | ||
3646 | 19 | |||
3647 | 20 | function test(Zorba $aZorba) { | ||
3648 | 21 | $xquery = $aZorba->compileQuery("<a>text-a1<b at1='att1' at2='{1+2}'>text-b1</b>text-a2</a>"); | ||
3649 | 22 | |||
3650 | 23 | |||
3651 | 24 | $saxHandler = new SAX2ContentHandlerProxy(); | ||
3652 | 25 | $saxHandler->setStartDocumentHandler(startDocumentHandler); | ||
3653 | 26 | $saxHandler->setEndDocumentHandler(endDocumentHandler); | ||
3654 | 27 | $saxHandler->setStartElementHandler(startElementHandler); | ||
3655 | 28 | $saxHandler->setEndElementHandler(endElementHandler); | ||
3656 | 29 | $saxHandler->setCharactersHandler(charactersHandler); | ||
3657 | 30 | $saxHandler->setProcessingInstructionHandler(processingInstructionHandler); | ||
3658 | 31 | $saxHandler->setIgnorableWhitespaceHandler(ignorableWhitespaceHandler); | ||
3659 | 32 | $saxHandler->setStartPrefixMappingHandler(startPrefixMappingHandler); | ||
3660 | 33 | $saxHandler->setEndPrefixMappingHandler(endPrefixMappingHandler); | ||
3661 | 34 | $saxHandler->setSkippedEntityHandler(skippedEntityHandler); | ||
3662 | 35 | $xquery->executeSAX($saxHandler); | ||
3663 | 36 | |||
3664 | 37 | return; | ||
3665 | 38 | } | ||
3666 | 39 | |||
3667 | 40 | function startDocumentHandler() { | ||
3668 | 41 | print "Start Document"; | ||
3669 | 42 | return; | ||
3670 | 43 | } | ||
3671 | 44 | function endDocumentHandler() { | ||
3672 | 45 | print "End Document"; | ||
3673 | 46 | return; | ||
3674 | 47 | } | ||
3675 | 48 | function startElementHandler($URI, $localName, $QName, $SAXAttributes) { | ||
3676 | 49 | print "Start Element - " . $QName; | ||
3677 | 50 | return; | ||
3678 | 51 | } | ||
3679 | 52 | function endElementHandler($URI, $localName, $QName) { | ||
3680 | 53 | print "End Element - " . $QName; | ||
3681 | 54 | return; | ||
3682 | 55 | } | ||
3683 | 56 | function charactersHandler($text) { | ||
3684 | 57 | print "Characters - " . $text; | ||
3685 | 58 | return; | ||
3686 | 59 | } | ||
3687 | 60 | function processingInstructionHandler($target, $data) { | ||
3688 | 61 | print "Processing Instruction"; | ||
3689 | 62 | return; | ||
3690 | 63 | } | ||
3691 | 64 | function ignorableWhitespaceHandler($text) { | ||
3692 | 65 | print "Ignorable Whitespace - " . $text; | ||
3693 | 66 | return; | ||
3694 | 67 | } | ||
3695 | 68 | function startPrefixMappingHandler($prefix, $URI) { | ||
3696 | 69 | print "Start Prefix Mapping - " . $prefix; | ||
3697 | 70 | return; | ||
3698 | 71 | } | ||
3699 | 72 | function endPrefixMappingHandler($prefix) { | ||
3700 | 73 | print "End Prefix Mapping - " . $prefix; | ||
3701 | 74 | return; | ||
3702 | 75 | } | ||
3703 | 76 | function skippedEntityHandler($name) { | ||
3704 | 77 | print "Skipped Entity - " . $name; | ||
3705 | 78 | return; | ||
3706 | 79 | } | ||
3707 | 80 | |||
3708 | 81 | |||
3709 | 82 | $store = InMemoryStore::getInstance(); | ||
3710 | 83 | $zorba = Zorba::getInstance($store); | ||
3711 | 84 | |||
3712 | 85 | print "Running: XQuery execute - executeSAX\n"; | ||
3713 | 86 | test($zorba); | ||
3714 | 87 | print "Success"; | ||
3715 | 88 | |||
3716 | 89 | $zorba->shutdown(); | ||
3717 | 90 | InMemoryStore::shutdown($store); | ||
3718 | 91 | |||
3719 | 92 | ?> | ||
3720 | 0 | \ No newline at end of file | 93 | \ No newline at end of file |
3721 | 1 | 94 | ||
3722 | === added file 'swig/php/tests/test10.php' | |||
3723 | --- swig/php/tests/test10.php 1970-01-01 00:00:00 +0000 | |||
3724 | +++ swig/php/tests/test10.php 2012-03-26 20:16:18 +0000 | |||
3725 | @@ -0,0 +1,55 @@ | |||
3726 | 1 | <? | ||
3727 | 2 | /* | ||
3728 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
3729 | 4 | * | ||
3730 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3731 | 6 | * you may not use this file except in compliance with the License. | ||
3732 | 7 | * You may obtain a copy of the License at | ||
3733 | 8 | * | ||
3734 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3735 | 10 | * | ||
3736 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
3737 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
3738 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3739 | 14 | * See the License for the specific language governing permissions and | ||
3740 | 15 | * limitations under the License. | ||
3741 | 16 | */ | ||
3742 | 17 | |||
3743 | 18 | require '@phpPath@/Zorba/zorba_api_wrapper.php'; | ||
3744 | 19 | |||
3745 | 20 | function test(Zorba $aZorba) { | ||
3746 | 21 | $filename = 'books.xml'; | ||
3747 | 22 | $f = fopen($filename, 'r'); | ||
3748 | 23 | $contents = fread($f, filesize($filename)); | ||
3749 | 24 | fclose($f); | ||
3750 | 25 | |||
3751 | 26 | $dataManager = $aZorba->getXmlDataManager(); | ||
3752 | 27 | $docIter = $dataManager->parseXML($contents); | ||
3753 | 28 | $docIter->open(); | ||
3754 | 29 | |||
3755 | 30 | $doc = Item::createEmptyItem(); | ||
3756 | 31 | $docIter->next($doc); | ||
3757 | 32 | |||
3758 | 33 | $docIter->close(); | ||
3759 | 34 | $docIter->destroy(); | ||
3760 | 35 | |||
3761 | 36 | $xquery = $aZorba->compileQuery("."); | ||
3762 | 37 | $dynCtx = $xquery->getDynamicContext(); | ||
3763 | 38 | $dynCtx->setContextItem($doc); | ||
3764 | 39 | print $xquery->execute()."\n"; | ||
3765 | 40 | |||
3766 | 41 | return; | ||
3767 | 42 | } | ||
3768 | 43 | |||
3769 | 44 | |||
3770 | 45 | $store = InMemoryStore::getInstance(); | ||
3771 | 46 | $zorba = Zorba::getInstance($store); | ||
3772 | 47 | |||
3773 | 48 | print "Running: XQuery execute - Get Iterator and print info from its items\n"; | ||
3774 | 49 | test($zorba); | ||
3775 | 50 | print "Success"; | ||
3776 | 51 | |||
3777 | 52 | $zorba->shutdown(); | ||
3778 | 53 | InMemoryStore::shutdown($store); | ||
3779 | 54 | |||
3780 | 55 | ?> | ||
3781 | 0 | \ No newline at end of file | 56 | \ No newline at end of file |
3782 | 1 | 57 | ||
3783 | === added file 'swig/php/tests/test11.php' | |||
3784 | --- swig/php/tests/test11.php 1970-01-01 00:00:00 +0000 | |||
3785 | +++ swig/php/tests/test11.php 2012-03-26 20:16:18 +0000 | |||
3786 | @@ -0,0 +1,52 @@ | |||
3787 | 1 | <? | ||
3788 | 2 | /* | ||
3789 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
3790 | 4 | * | ||
3791 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3792 | 6 | * you may not use this file except in compliance with the License. | ||
3793 | 7 | * You may obtain a copy of the License at | ||
3794 | 8 | * | ||
3795 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3796 | 10 | * | ||
3797 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
3798 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
3799 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3800 | 14 | * See the License for the specific language governing permissions and | ||
3801 | 15 | * limitations under the License. | ||
3802 | 16 | */ | ||
3803 | 17 | |||
3804 | 18 | //require '@phpPath@/Zorba/zorba_api_wrapper.php'; | ||
3805 | 19 | require 'C:/dev/zapi/build/swig/php/Zorba/zorba_api_wrapper.php'; | ||
3806 | 20 | |||
3807 | 21 | class MyDiagnosticHandler(zorba_api.DiagnosticHandler): | ||
3808 | 22 | def error(self, *args): | ||
3809 | 23 | print "Error args: ", args | ||
3810 | 24 | |||
3811 | 25 | def test(zorba): | ||
3812 | 26 | #Read and write result | ||
3813 | 27 | print 'Executing: compilerHints.xq' | ||
3814 | 28 | f = open('compilerHints.xq', 'r') | ||
3815 | 29 | lines = f.read() | ||
3816 | 30 | f.close() | ||
3817 | 31 | diagnosticHandler = MyDiagnosticHandler() | ||
3818 | 32 | compilerHints = zorba_api.CompilerHints() | ||
3819 | 33 | compilerHints.setOptimizationLevel(0) | ||
3820 | 34 | xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler) | ||
3821 | 35 | |||
3822 | 36 | result = xquery.execute() | ||
3823 | 37 | print result | ||
3824 | 38 | return | ||
3825 | 39 | |||
3826 | 40 | |||
3827 | 41 | store = zorba_api.InMemoryStore_getInstance() | ||
3828 | 42 | zorba = zorba_api.Zorba_getInstance(store) | ||
3829 | 43 | |||
3830 | 44 | print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 0" | ||
3831 | 45 | test(zorba) | ||
3832 | 46 | print "Success" | ||
3833 | 47 | |||
3834 | 48 | |||
3835 | 49 | zorba.shutdown() | ||
3836 | 50 | zorba_api.InMemoryStore_shutdown(store) | ||
3837 | 51 | |||
3838 | 52 | ?> | ||
3839 | 0 | \ No newline at end of file | 53 | \ No newline at end of file |
3840 | 1 | 54 | ||
3841 | === added file 'swig/php/tests/test12.php' | |||
3842 | --- swig/php/tests/test12.php 1970-01-01 00:00:00 +0000 | |||
3843 | +++ swig/php/tests/test12.php 2012-03-26 20:16:18 +0000 | |||
3844 | @@ -0,0 +1,52 @@ | |||
3845 | 1 | <? | ||
3846 | 2 | /* | ||
3847 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
3848 | 4 | * | ||
3849 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3850 | 6 | * you may not use this file except in compliance with the License. | ||
3851 | 7 | * You may obtain a copy of the License at | ||
3852 | 8 | * | ||
3853 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3854 | 10 | * | ||
3855 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
3856 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
3857 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3858 | 14 | * See the License for the specific language governing permissions and | ||
3859 | 15 | * limitations under the License. | ||
3860 | 16 | */ | ||
3861 | 17 | |||
3862 | 18 | //require '@phpPath@/Zorba/zorba_api_wrapper.php'; | ||
3863 | 19 | require 'C:/dev/zapi/build/swig/php/Zorba/zorba_api_wrapper.php'; | ||
3864 | 20 | |||
3865 | 21 | class MyDiagnosticHandler(zorba_api.DiagnosticHandler): | ||
3866 | 22 | def error(self, *args): | ||
3867 | 23 | print "Error args: ", args | ||
3868 | 24 | |||
3869 | 25 | def test(zorba): | ||
3870 | 26 | #Read and write result | ||
3871 | 27 | print 'Executing: compilerHints.xq' | ||
3872 | 28 | f = open('compilerHints.xq', 'r') | ||
3873 | 29 | lines = f.read() | ||
3874 | 30 | f.close() | ||
3875 | 31 | diagnosticHandler = MyDiagnosticHandler() | ||
3876 | 32 | compilerHints = zorba_api.CompilerHints() | ||
3877 | 33 | compilerHints.setOptimizationLevel(1) | ||
3878 | 34 | xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler) | ||
3879 | 35 | |||
3880 | 36 | result = xquery.execute() | ||
3881 | 37 | print result | ||
3882 | 38 | return | ||
3883 | 39 | |||
3884 | 40 | |||
3885 | 41 | store = zorba_api.InMemoryStore_getInstance() | ||
3886 | 42 | zorba = zorba_api.Zorba_getInstance(store) | ||
3887 | 43 | |||
3888 | 44 | print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 1" | ||
3889 | 45 | test(zorba) | ||
3890 | 46 | print "Success" | ||
3891 | 47 | |||
3892 | 48 | |||
3893 | 49 | zorba.shutdown() | ||
3894 | 50 | zorba_api.InMemoryStore_shutdown(store) | ||
3895 | 51 | |||
3896 | 52 | ?> | ||
3897 | 0 | \ No newline at end of file | 53 | \ No newline at end of file |
3898 | 1 | 54 | ||
3899 | === added file 'swig/php/tests/test13.php' | |||
3900 | --- swig/php/tests/test13.php 1970-01-01 00:00:00 +0000 | |||
3901 | +++ swig/php/tests/test13.php 2012-03-26 20:16:18 +0000 | |||
3902 | @@ -0,0 +1,53 @@ | |||
3903 | 1 | <? | ||
3904 | 2 | /* | ||
3905 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
3906 | 4 | * | ||
3907 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3908 | 6 | * you may not use this file except in compliance with the License. | ||
3909 | 7 | * You may obtain a copy of the License at | ||
3910 | 8 | * | ||
3911 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3912 | 10 | * | ||
3913 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
3914 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
3915 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3916 | 14 | * See the License for the specific language governing permissions and | ||
3917 | 15 | * limitations under the License. | ||
3918 | 16 | */ | ||
3919 | 17 | |||
3920 | 18 | //require '@phpPath@/Zorba/zorba_api_wrapper.php'; | ||
3921 | 19 | require 'C:/dev/zapi/build/swig/php/Zorba/zorba_api_wrapper.php'; | ||
3922 | 20 | |||
3923 | 21 | class MyDiagnosticHandler(zorba_api.DiagnosticHandler): | ||
3924 | 22 | def error(self, *args): | ||
3925 | 23 | print "Error args: ", args | ||
3926 | 24 | |||
3927 | 25 | def test(zorba): | ||
3928 | 26 | #Read and write result | ||
3929 | 27 | print 'Executing: compilerHints.xq' | ||
3930 | 28 | f = open('compilerHints.xq', 'r') | ||
3931 | 29 | lines = f.read() | ||
3932 | 30 | f.close() | ||
3933 | 31 | diagnosticHandler = MyDiagnosticHandler() | ||
3934 | 32 | compilerHints = zorba_api.CompilerHints() | ||
3935 | 33 | compilerHints.setLibModule(True) | ||
3936 | 34 | compilerHints.setOptimizationLevel(0) | ||
3937 | 35 | xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler) | ||
3938 | 36 | |||
3939 | 37 | result = xquery.execute() | ||
3940 | 38 | print result | ||
3941 | 39 | return | ||
3942 | 40 | |||
3943 | 41 | |||
3944 | 42 | store = zorba_api.InMemoryStore_getInstance() | ||
3945 | 43 | zorba = zorba_api.Zorba_getInstance(store) | ||
3946 | 44 | |||
3947 | 45 | print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 0 - setLibModule(True)" | ||
3948 | 46 | test(zorba) | ||
3949 | 47 | print "Success" | ||
3950 | 48 | |||
3951 | 49 | |||
3952 | 50 | zorba.shutdown() | ||
3953 | 51 | zorba_api.InMemoryStore_shutdown(store) | ||
3954 | 52 | |||
3955 | 53 | ?> | ||
3956 | 0 | \ No newline at end of file | 54 | \ No newline at end of file |
3957 | 1 | 55 | ||
3958 | === added file 'swig/php/tests/test14.php' | |||
3959 | --- swig/php/tests/test14.php 1970-01-01 00:00:00 +0000 | |||
3960 | +++ swig/php/tests/test14.php 2012-03-26 20:16:18 +0000 | |||
3961 | @@ -0,0 +1,53 @@ | |||
3962 | 1 | <? | ||
3963 | 2 | /* | ||
3964 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
3965 | 4 | * | ||
3966 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
3967 | 6 | * you may not use this file except in compliance with the License. | ||
3968 | 7 | * You may obtain a copy of the License at | ||
3969 | 8 | * | ||
3970 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
3971 | 10 | * | ||
3972 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
3973 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
3974 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
3975 | 14 | * See the License for the specific language governing permissions and | ||
3976 | 15 | * limitations under the License. | ||
3977 | 16 | */ | ||
3978 | 17 | |||
3979 | 18 | //require '@phpPath@/Zorba/zorba_api_wrapper.php'; | ||
3980 | 19 | require 'C:/dev/zapi/build/swig/php/Zorba/zorba_api_wrapper.php'; | ||
3981 | 20 | |||
3982 | 21 | class MyDiagnosticHandler(zorba_api.DiagnosticHandler): | ||
3983 | 22 | def error(self, *args): | ||
3984 | 23 | print "Error args: ", args | ||
3985 | 24 | |||
3986 | 25 | def test(zorba): | ||
3987 | 26 | #Read and write result | ||
3988 | 27 | print 'Executing: compilerHints.xq' | ||
3989 | 28 | f = open('compilerHints.xq', 'r') | ||
3990 | 29 | lines = f.read() | ||
3991 | 30 | f.close() | ||
3992 | 31 | diagnosticHandler = MyDiagnosticHandler() | ||
3993 | 32 | compilerHints = zorba_api.CompilerHints() | ||
3994 | 33 | compilerHints.setLibModule(True) | ||
3995 | 34 | compilerHints.setOptimizationLevel(1) | ||
3996 | 35 | xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler) | ||
3997 | 36 | |||
3998 | 37 | result = xquery.execute() | ||
3999 | 38 | print result | ||
4000 | 39 | return | ||
4001 | 40 | |||
4002 | 41 | |||
4003 | 42 | store = zorba_api.InMemoryStore_getInstance() | ||
4004 | 43 | zorba = zorba_api.Zorba_getInstance(store) | ||
4005 | 44 | |||
4006 | 45 | print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 1 - setLibModule(True)" | ||
4007 | 46 | test(zorba) | ||
4008 | 47 | print "Success" | ||
4009 | 48 | |||
4010 | 49 | |||
4011 | 50 | zorba.shutdown() | ||
4012 | 51 | zorba_api.InMemoryStore_shutdown(store) | ||
4013 | 52 | |||
4014 | 53 | ?> | ||
4015 | 0 | \ No newline at end of file | 54 | \ No newline at end of file |
4016 | 1 | 55 | ||
4017 | === added file 'swig/php/tests/zorba_api.php' | |||
4018 | --- swig/php/tests/zorba_api.php 1970-01-01 00:00:00 +0000 | |||
4019 | +++ swig/php/tests/zorba_api.php 2012-03-26 20:16:18 +0000 | |||
4020 | @@ -0,0 +1,178 @@ | |||
4021 | 1 | <?php | ||
4022 | 2 | /* | ||
4023 | 3 | * Copyright 2006-2012 The FLWOR Foundation. | ||
4024 | 4 | * | ||
4025 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
4026 | 6 | * you may not use this file except in compliance with the License. | ||
4027 | 7 | * You may obtain a copy of the License at | ||
4028 | 8 | * | ||
4029 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
4030 | 10 | * | ||
4031 | 11 | * Unless required by applicable law or agreed to in writing, software | ||
4032 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
4033 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
4034 | 14 | * See the License for the specific language governing permissions and | ||
4035 | 15 | * limitations under the License. | ||
4036 | 16 | */ | ||
4037 | 17 | |||
4038 | 18 | // Try to load our extension if it's not already loaded. | ||
4039 | 19 | if (!extension_loaded("zorba_api")) { | ||
4040 | 20 | if (strtolower(substr(PHP_OS, 0, 3)) === 'win') { | ||
4041 | 21 | if (!dl('zorba_api.dll')) return; | ||
4042 | 22 | } else { | ||
4043 | 23 | // PHP_SHLIB_SUFFIX is available as of PHP 4.3.0, for older PHP assume 'so'. | ||
4044 | 24 | // It gives 'dylib' on MacOS X which is for libraries, modules are 'so'. | ||
4045 | 25 | if (PHP_SHLIB_SUFFIX === 'PHP_SHLIB_SUFFIX' || PHP_SHLIB_SUFFIX === 'dylib') { | ||
4046 | 26 | if (!dl('zorba_api.so')) return; | ||
4047 | 27 | } else { | ||
4048 | 28 | if (!dl('zorba_api.'.PHP_SHLIB_SUFFIX)) return; | ||
4049 | 29 | } | ||
4050 | 30 | } | ||
4051 | 31 | } | ||
4052 | 32 | |||
4053 | 33 | class Item { | ||
4054 | 34 | public $_cPtr=null; | ||
4055 | 35 | |||
4056 | 36 | static function createEmptyItem() { | ||
4057 | 37 | $r=Item_createEmptyItem(); | ||
4058 | 38 | return is_resource($r) ? new Item($r) : $r; | ||
4059 | 39 | } | ||
4060 | 40 | |||
4061 | 41 | function getStringValue() { | ||
4062 | 42 | return Item_getStringValue($this->_cPtr); | ||
4063 | 43 | } | ||
4064 | 44 | |||
4065 | 45 | function __construct() { | ||
4066 | 46 | $this->_cPtr=new_Item(); | ||
4067 | 47 | } | ||
4068 | 48 | } | ||
4069 | 49 | |||
4070 | 50 | class Iterator { | ||
4071 | 51 | public $_cPtr=null; | ||
4072 | 52 | |||
4073 | 53 | function open() { | ||
4074 | 54 | Iterator_open($this->_cPtr); | ||
4075 | 55 | } | ||
4076 | 56 | |||
4077 | 57 | function next($arg1) { | ||
4078 | 58 | return Iterator_next($this->_cPtr,$arg1); | ||
4079 | 59 | } | ||
4080 | 60 | |||
4081 | 61 | function close() { | ||
4082 | 62 | Iterator_close($this->_cPtr); | ||
4083 | 63 | } | ||
4084 | 64 | |||
4085 | 65 | function destroy() { | ||
4086 | 66 | Iterator_destroy($this->_cPtr); | ||
4087 | 67 | } | ||
4088 | 68 | |||
4089 | 69 | function __construct($cPtr) { | ||
4090 | 70 | $this->_cPtr=$cPtr; | ||
4091 | 71 | } | ||
4092 | 72 | |||
4093 | 73 | public function __destruct() { | ||
4094 | 74 | $this->destroy(); | ||
4095 | 75 | } | ||
4096 | 76 | } | ||
4097 | 77 | |||
4098 | 78 | class XQuery { | ||
4099 | 79 | public $_cPtr=null; | ||
4100 | 80 | |||
4101 | 81 | function execute() { | ||
4102 | 82 | return XQuery_execute($this->_cPtr); | ||
4103 | 83 | } | ||
4104 | 84 | |||
4105 | 85 | function isUpdateQuery() { | ||
4106 | 86 | return XQuery_isUpdateQuery($this->_cPtr); | ||
4107 | 87 | } | ||
4108 | 88 | |||
4109 | 89 | function applyUpdates() { | ||
4110 | 90 | XQuery_applyUpdates($this->_cPtr); | ||
4111 | 91 | } | ||
4112 | 92 | |||
4113 | 93 | function destroy() { | ||
4114 | 94 | XQuery_destroy($this->_cPtr); | ||
4115 | 95 | } | ||
4116 | 96 | |||
4117 | 97 | function iterator() { | ||
4118 | 98 | $r=XQuery_iterator($this->_cPtr); | ||
4119 | 99 | return is_resource($r) ? new Iterator($r) : $r; | ||
4120 | 100 | } | ||
4121 | 101 | |||
4122 | 102 | function __construct($cPtr) { | ||
4123 | 103 | $this->_cPtr=$cPtr; | ||
4124 | 104 | } | ||
4125 | 105 | |||
4126 | 106 | function __destruct() { | ||
4127 | 107 | $this->destroy(); | ||
4128 | 108 | } | ||
4129 | 109 | } | ||
4130 | 110 | |||
4131 | 111 | class Store { | ||
4132 | 112 | //public $_cPtr=null; | ||
4133 | 113 | |||
4134 | 114 | //function __construct() { | ||
4135 | 115 | // $this->_cPtr=new_Store(); | ||
4136 | 116 | //} | ||
4137 | 117 | } | ||
4138 | 118 | |||
4139 | 119 | class InMemoryStore extends Store { | ||
4140 | 120 | public $_cPtr=null; | ||
4141 | 121 | |||
4142 | 122 | static function getInstance() { | ||
4143 | 123 | $r=InMemoryStore_getInstance(); | ||
4144 | 124 | return is_resource($r) ? new InMemoryStore($r) : $r; | ||
4145 | 125 | } | ||
4146 | 126 | |||
4147 | 127 | static function shutdown($arg1) { | ||
4148 | 128 | InMemoryStore_shutdown($arg1); | ||
4149 | 129 | } | ||
4150 | 130 | |||
4151 | 131 | private function __construct($cPtr) { | ||
4152 | 132 | $this->_cPtr=$cPtr; | ||
4153 | 133 | } | ||
4154 | 134 | } | ||
4155 | 135 | |||
4156 | 136 | class XmlDataManager { | ||
4157 | 137 | public $_cPtr=null; | ||
4158 | 138 | |||
4159 | 139 | function loadDocument($aName,$aContent) { | ||
4160 | 140 | XmlDataManager_loadDocument($this->_cPtr,$aName,$aContent); | ||
4161 | 141 | } | ||
4162 | 142 | |||
4163 | 143 | function deleteDocument($aName) { | ||
4164 | 144 | return XmlDataManager_deleteDocument($this->_cPtr,$aName); | ||
4165 | 145 | } | ||
4166 | 146 | |||
4167 | 147 | function __construct($cPtr) { | ||
4168 | 148 | $this->_cPtr=$cPtr; | ||
4169 | 149 | } | ||
4170 | 150 | } | ||
4171 | 151 | |||
4172 | 152 | class Zorba { | ||
4173 | 153 | public $_cPtr=null; | ||
4174 | 154 | |||
4175 | 155 | static function getInstance($arg1) { | ||
4176 | 156 | $r=Zorba_getInstance($arg1->_cPtr); | ||
4177 | 157 | return is_resource($r) ? new Zorba($r) : $r; | ||
4178 | 158 | } | ||
4179 | 159 | |||
4180 | 160 | function compileQuery($aStr) { | ||
4181 | 161 | $r=Zorba_compileQuery($this->_cPtr,$aStr); | ||
4182 | 162 | return is_resource($r) ? new XQuery($r) : $r; | ||
4183 | 163 | } | ||
4184 | 164 | |||
4185 | 165 | function getXmlDataManager() { | ||
4186 | 166 | $r=Zorba_getXmlDataManager($this->_cPtr); | ||
4187 | 167 | return is_resource($r) ? new XmlDataManager($r) : $r; | ||
4188 | 168 | } | ||
4189 | 169 | |||
4190 | 170 | function shutdown() { | ||
4191 | 171 | Zorba_shutdown($this->_cPtr); | ||
4192 | 172 | } | ||
4193 | 173 | |||
4194 | 174 | private function __construct($cPtr) { | ||
4195 | 175 | $this->_cPtr=$cPtr; | ||
4196 | 176 | } | ||
4197 | 177 | } | ||
4198 | 178 | ?> | ||
4199 | 0 | 179 | ||
4200 | === modified file 'swig/python/CMakeLists.txt' | |||
4201 | --- swig/python/CMakeLists.txt 2012-03-23 17:32:07 +0000 | |||
4202 | +++ swig/python/CMakeLists.txt 2012-03-26 20:16:18 +0000 | |||
4203 | @@ -20,8 +20,13 @@ | |||
4204 | 20 | SWIG_ADD_MODULE (zorba_api_python python zorba_api.i) | 20 | SWIG_ADD_MODULE (zorba_api_python python zorba_api.i) |
4205 | 21 | SWIG_LINK_LIBRARIES (zorba_api_python zorba_simplestore ${PYTHON_LIBRARIES}) | 21 | SWIG_LINK_LIBRARIES (zorba_api_python zorba_simplestore ${PYTHON_LIBRARIES}) |
4206 | 22 | SET_TARGET_PROPERTIES (_zorba_api_python PROPERTIES OUTPUT_NAME "_zorba_api") | 22 | SET_TARGET_PROPERTIES (_zorba_api_python PROPERTIES OUTPUT_NAME "_zorba_api") |
4209 | 23 | SET_PROPERTY( TARGET _zorba_api_python PROPERTY PROJECT_LABEL "Api_Python" ) | 23 | |
4210 | 24 | 24 | IF (MSVC_IDE) | |
4211 | 25 | SET_PROPERTY( TARGET _zorba_api_python PROPERTY PROJECT_LABEL "Api_Python" ) | ||
4212 | 26 | SET_PROPERTY( TARGET _zorba_api_python PROPERTY LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/swig/python ) | ||
4213 | 27 | SET_PROPERTY( TARGET _zorba_api_python PROPERTY LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/swig/python ) | ||
4214 | 28 | ENDIF (MSVC_IDE) | ||
4215 | 29 | |||
4216 | 25 | EXECUTE_PROCESS ( | 30 | EXECUTE_PROCESS ( |
4217 | 26 | COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig;print sysconfig.get_python_lib(0)" | 31 | COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig;print sysconfig.get_python_lib(0)" |
4218 | 27 | OUTPUT_VARIABLE PYTHON_INSTALL_PATH | 32 | OUTPUT_VARIABLE PYTHON_INSTALL_PATH |
4219 | @@ -31,6 +36,18 @@ | |||
4220 | 31 | SET (PYTHON_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/share/python") | 36 | SET (PYTHON_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/share/python") |
4221 | 32 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h") | 37 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h") |
4222 | 33 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h") | 38 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h") |
4223 | 39 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h") | ||
4224 | 40 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h") | ||
4225 | 41 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h") | ||
4226 | 42 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h") | ||
4227 | 43 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h") | ||
4228 | 44 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h") | ||
4229 | 45 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../SerializationOptions.h" "${CMAKE_CURRENT_BINARY_DIR}/SerializationOptions.h" COPYONLY) | ||
4230 | 46 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Collection.h" "${CMAKE_CURRENT_BINARY_DIR}/Collection.h" COPYONLY) | ||
4231 | 47 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY) | ||
4232 | 48 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY) | ||
4233 | 49 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY) | ||
4234 | 50 | |||
4235 | 34 | MESSAGE (STATUS "SWIG Python: Python module install path: " ${PYTHON_INSTALL_PATH}) | 51 | MESSAGE (STATUS "SWIG Python: Python module install path: " ${PYTHON_INSTALL_PATH}) |
4236 | 35 | 52 | ||
4237 | 36 | IF (NOT WIN32) | 53 | IF (NOT WIN32) |
4238 | @@ -41,17 +58,10 @@ | |||
4239 | 41 | DESTINATION ${PYTHON_INSTALL_PATH} | 58 | DESTINATION ${PYTHON_INSTALL_PATH} |
4240 | 42 | ) | 59 | ) |
4241 | 43 | ELSE(NOT WIN32) | 60 | ELSE(NOT WIN32) |
4242 | 44 | IF (MSVC_IDE) | ||
4243 | 45 | INSTALL ( FILES | ||
4244 | 46 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/_zorba_api.pyd | ||
4245 | 47 | DESTINATION share/python | ||
4246 | 48 | COMPONENT "python_swig" ) | ||
4247 | 49 | ELSE (MSVC_IDE) | ||
4248 | 50 | INSTALL ( FILES | 61 | INSTALL ( FILES |
4249 | 51 | ${CMAKE_CURRENT_BINARY_DIR}/_zorba_api.pyd | 62 | ${CMAKE_CURRENT_BINARY_DIR}/_zorba_api.pyd |
4250 | 52 | DESTINATION share/python | 63 | DESTINATION share/python |
4251 | 53 | COMPONENT "python_swig" ) | 64 | COMPONENT "python_swig" ) |
4252 | 54 | ENDIF (MSVC_IDE) | ||
4253 | 55 | ENDIF(NOT WIN32) | 65 | ENDIF(NOT WIN32) |
4254 | 56 | 66 | ||
4255 | 57 | ADD_SUBDIRECTORY (tests) | 67 | ADD_SUBDIRECTORY (tests) |
4256 | 58 | 68 | ||
4257 | === modified file 'swig/ruby/CMakeLists.txt' | |||
4258 | --- swig/ruby/CMakeLists.txt 2012-03-23 17:32:07 +0000 | |||
4259 | +++ swig/ruby/CMakeLists.txt 2012-03-26 20:16:18 +0000 | |||
4260 | @@ -23,8 +23,9 @@ | |||
4261 | 23 | IF (WIN32) | 23 | IF (WIN32) |
4262 | 24 | SWIG_ADD_MODULE(zorba_api_ruby ruby zorba_api.i) | 24 | SWIG_ADD_MODULE(zorba_api_ruby ruby zorba_api.i) |
4263 | 25 | SWIG_LINK_LIBRARIES(zorba_api_ruby zorba_simplestore ${RUBY_LIBRARY}) | 25 | SWIG_LINK_LIBRARIES(zorba_api_ruby zorba_simplestore ${RUBY_LIBRARY}) |
4265 | 26 | SET_TARGET_PROPERTIES (zorba_api_ruby PROPERTIES OUTPUT_NAME "zorba_api") | 26 | SET_TARGET_PROPERTIES( zorba_api_ruby PROPERTIES OUTPUT_NAME "zorba_api") |
4266 | 27 | SET_TARGET_PROPERTIES( zorba_api_ruby PROPERTIES PROJECT_LABEL "Api_Ruby" ) | 27 | SET_TARGET_PROPERTIES( zorba_api_ruby PROPERTIES PROJECT_LABEL "Api_Ruby" ) |
4267 | 28 | SET_TARGET_PROPERTIES( zorba_api_ruby PROPERTIES SUFFIX ".so" ) | ||
4268 | 28 | ELSE (WIN32) | 29 | ELSE (WIN32) |
4269 | 29 | SWIG_ADD_MODULE(zorba_api ruby zorba_api.i) | 30 | SWIG_ADD_MODULE(zorba_api ruby zorba_api.i) |
4270 | 30 | SWIG_LINK_LIBRARIES(zorba_api zorba_simplestore ${RUBY_LIBRARY}) | 31 | SWIG_LINK_LIBRARIES(zorba_api zorba_simplestore ${RUBY_LIBRARY}) |
4271 | @@ -52,7 +53,18 @@ | |||
4272 | 52 | #STRING(REPLACE "/usr/" "" RUBY_SITEARCH_DIR "${RUBY_SITEARCH_DIR}" ) | 53 | #STRING(REPLACE "/usr/" "" RUBY_SITEARCH_DIR "${RUBY_SITEARCH_DIR}" ) |
4273 | 53 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h") | 54 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h") |
4274 | 54 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h") | 55 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h") |
4276 | 55 | 56 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h") | |
4277 | 57 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h") | ||
4278 | 58 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h") | ||
4279 | 59 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h") | ||
4280 | 60 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h") | ||
4281 | 61 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h") | ||
4282 | 62 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../SerializationOptions.h" "${CMAKE_CURRENT_BINARY_DIR}/SerializationOptions.h" COPYONLY) | ||
4283 | 63 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Collection.h" "${CMAKE_CURRENT_BINARY_DIR}/Collection.h" COPYONLY) | ||
4284 | 64 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY) | ||
4285 | 65 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY) | ||
4286 | 66 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY) | ||
4287 | 67 | |||
4288 | 56 | SET (RUBY_SITEARCH_DIR "${CMAKE_INSTALL_PREFIX}/share/ruby") | 68 | SET (RUBY_SITEARCH_DIR "${CMAKE_INSTALL_PREFIX}/share/ruby") |
4289 | 57 | 69 | ||
4290 | 58 | IF ( APPLE ) | 70 | IF ( APPLE ) |
4291 | @@ -77,6 +89,8 @@ | |||
4292 | 77 | ENDIF ( LINUX ) | 89 | ENDIF ( LINUX ) |
4293 | 78 | ENDIF ( APPLE ) | 90 | ENDIF ( APPLE ) |
4294 | 79 | 91 | ||
4295 | 92 | ADD_SUBDIRECTORY (tests) | ||
4296 | 93 | |||
4297 | 80 | ELSE (RUBY_LIBRARY AND RUBY_INCLUDE_PATH) | 94 | ELSE (RUBY_LIBRARY AND RUBY_INCLUDE_PATH) |
4298 | 81 | MESSAGE(STATUS "SWIG Ruby: binding not generated because library and include files are not installed.") | 95 | MESSAGE(STATUS "SWIG Ruby: binding not generated because library and include files are not installed.") |
4299 | 82 | ENDIF (RUBY_LIBRARY AND RUBY_INCLUDE_PATH) | 96 | ENDIF (RUBY_LIBRARY AND RUBY_INCLUDE_PATH) |
4300 | 83 | 97 | ||
4301 | === added directory 'swig/ruby/tests' | |||
4302 | === added file 'swig/ruby/tests/CMakeLists.txt' | |||
4303 | --- swig/ruby/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
4304 | +++ swig/ruby/tests/CMakeLists.txt 2012-03-26 20:16:18 +0000 | |||
4305 | @@ -0,0 +1,83 @@ | |||
4306 | 1 | # Copyright 2006-2011 The FLWOR Foundation. | ||
4307 | 2 | # | ||
4308 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
4309 | 4 | # you may not use this file except in compliance with the License. | ||
4310 | 5 | # You may obtain a copy of the License at | ||
4311 | 6 | # | ||
4312 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
4313 | 8 | # | ||
4314 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
4315 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
4316 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
4317 | 12 | # See the License for the specific language governing permissions and | ||
4318 | 13 | # limitations under the License. | ||
4319 | 14 | MESSAGE(STATUS "Adding tests for Ruby Binding") | ||
4320 | 15 | |||
4321 | 16 | IF (MSVC_IDE) | ||
4322 | 17 | SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby/@CMAKE_BUILD_TYPE@) | ||
4323 | 18 | ELSE (MSVC_IDE) | ||
4324 | 19 | SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby) | ||
4325 | 20 | ENDIF (MSVC_IDE) | ||
4326 | 21 | |||
4327 | 22 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/books.xml ${CMAKE_CURRENT_BINARY_DIR}/books.xml COPYONLY) | ||
4328 | 23 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/compilerHints.xq ${CMAKE_CURRENT_BINARY_DIR}/compilerHints.xq COPYONLY) | ||
4329 | 24 | |||
4330 | 25 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test01.rb ${CMAKE_CURRENT_BINARY_DIR}/test01.rb) | ||
4331 | 26 | ADD_TEST("ruby_test01" ${RUBY_EXECUTABLE} test01.rb) | ||
4332 | 27 | SET_TESTS_PROPERTIES("ruby_test01" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
4333 | 28 | |||
4334 | 29 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test02.rb ${CMAKE_CURRENT_BINARY_DIR}/test02.rb) | ||
4335 | 30 | ADD_TEST("ruby_test02" ${RUBY_EXECUTABLE} test02.rb) | ||
4336 | 31 | SET_TESTS_PROPERTIES("ruby_test02" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
4337 | 32 | |||
4338 | 33 | #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test03.rb ${CMAKE_CURRENT_BINARY_DIR}/test03.rb) | ||
4339 | 34 | #ADD_TEST("ruby_test03" ${RUBY_EXECUTABLE} test03.rb) | ||
4340 | 35 | #SET_TESTS_PROPERTIES("ruby_test03" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
4341 | 36 | |||
4342 | 37 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test04.rb ${CMAKE_CURRENT_BINARY_DIR}/test04.rb) | ||
4343 | 38 | ADD_TEST("ruby_test04" ${RUBY_EXECUTABLE} test04.rb) | ||
4344 | 39 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test04.xq ${CMAKE_CURRENT_BINARY_DIR}/test04.xq COPYONLY) | ||
4345 | 40 | SET_TESTS_PROPERTIES("ruby_test04" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
4346 | 41 | |||
4347 | 42 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test05.rb ${CMAKE_CURRENT_BINARY_DIR}/test05.rb) | ||
4348 | 43 | ADD_TEST("ruby_test05" ${RUBY_EXECUTABLE} test05.rb) | ||
4349 | 44 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test05.xq ${CMAKE_CURRENT_BINARY_DIR}/test05.xq COPYONLY) | ||
4350 | 45 | SET_TESTS_PROPERTIES("ruby_test05" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
4351 | 46 | |||
4352 | 47 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test06.rb ${CMAKE_CURRENT_BINARY_DIR}/test06.rb) | ||
4353 | 48 | ADD_TEST("ruby_test06" ${RUBY_EXECUTABLE} test06.rb) | ||
4354 | 49 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test06.xq ${CMAKE_CURRENT_BINARY_DIR}/test06.xq COPYONLY) | ||
4355 | 50 | SET_TESTS_PROPERTIES("ruby_test06" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
4356 | 51 | |||
4357 | 52 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test07.rb ${CMAKE_CURRENT_BINARY_DIR}/test07.rb) | ||
4358 | 53 | ADD_TEST("ruby_test07" ${RUBY_EXECUTABLE} test07.rb) | ||
4359 | 54 | SET_TESTS_PROPERTIES("ruby_test07" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
4360 | 55 | |||
4361 | 56 | # CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test08.rb ${CMAKE_CURRENT_BINARY_DIR}/test08.rb) | ||
4362 | 57 | # ADD_TEST("ruby_test08" ${RUBY_EXECUTABLE} test08.rb) | ||
4363 | 58 | # SET_TESTS_PROPERTIES("ruby_test08" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
4364 | 59 | |||
4365 | 60 | # CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test09.rb ${CMAKE_CURRENT_BINARY_DIR}/test09.rb) | ||
4366 | 61 | # ADD_TEST("ruby_test09" ${RUBY_EXECUTABLE} test09.rb) | ||
4367 | 62 | # SET_TESTS_PROPERTIES("ruby_test09" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
4368 | 63 | |||
4369 | 64 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test10.rb ${CMAKE_CURRENT_BINARY_DIR}/test10.rb) | ||
4370 | 65 | ADD_TEST("ruby_test10" ${RUBY_EXECUTABLE} test10.rb) | ||
4371 | 66 | SET_TESTS_PROPERTIES("ruby_test10" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
4372 | 67 | |||
4373 | 68 | #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test11.rb ${CMAKE_CURRENT_BINARY_DIR}/test11.rb) | ||
4374 | 69 | #ADD_TEST("ruby_test11" ${RUBY_EXECUTABLE} test11.rb) | ||
4375 | 70 | #SET_TESTS_PROPERTIES("ruby_test11" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
4376 | 71 | |||
4377 | 72 | #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test12.rb ${CMAKE_CURRENT_BINARY_DIR}/test12.rb) | ||
4378 | 73 | #ADD_TEST("ruby_test12" ${RUBY_EXECUTABLE} test12.rb) | ||
4379 | 74 | #SET_TESTS_PROPERTIES("ruby_test12" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
4380 | 75 | |||
4381 | 76 | #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test13.rb ${CMAKE_CURRENT_BINARY_DIR}/test13.rb) | ||
4382 | 77 | #ADD_TEST("ruby_test13" ${RUBY_EXECUTABLE} test13.rb) | ||
4383 | 78 | #SET_TESTS_PROPERTIES("ruby_test13" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
4384 | 79 | |||
4385 | 80 | #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test14.rb ${CMAKE_CURRENT_BINARY_DIR}/test14.rb) | ||
4386 | 81 | #ADD_TEST("ruby_test14" ${RUBY_EXECUTABLE} test14.rb) | ||
4387 | 82 | #SET_TESTS_PROPERTIES("ruby_test14" PROPERTIES PASS_REGULAR_EXPRESSION "Success") | ||
4388 | 83 | |||
4389 | 0 | 84 | ||
4390 | === added file 'swig/ruby/tests/books.xml' | |||
4391 | --- swig/ruby/tests/books.xml 1970-01-01 00:00:00 +0000 | |||
4392 | +++ swig/ruby/tests/books.xml 2012-03-26 20:16:18 +0000 | |||
4393 | @@ -0,0 +1,11 @@ | |||
4394 | 1 | <?xml version="1.0" encoding="UTF-8" ?> | ||
4395 | 2 | <books> | ||
4396 | 3 | <book> | ||
4397 | 4 | <title>Book 1</title> | ||
4398 | 5 | <author>Author 1</author> | ||
4399 | 6 | </book> | ||
4400 | 7 | <book featured="YES"> | ||
4401 | 8 | <title>Book 2</title> | ||
4402 | 9 | <author>Author 2</author> | ||
4403 | 10 | </book> | ||
4404 | 11 | </books> | ||
4405 | 0 | 12 | ||
4406 | === added file 'swig/ruby/tests/compilerHints.xq' | |||
4407 | --- swig/ruby/tests/compilerHints.xq 1970-01-01 00:00:00 +0000 | |||
4408 | +++ swig/ruby/tests/compilerHints.xq 2012-03-26 20:16:18 +0000 | |||
4409 | @@ -0,0 +1,4 @@ | |||
4410 | 1 | for tumbling window $w in (2, 4, 6, 8, 10, 12, 14) | ||
4411 | 2 | start at $s when fn:true() | ||
4412 | 3 | only end at $e when $e - $s eq 2 | ||
4413 | 4 | return avg($w) | ||
4414 | 0 | 5 | ||
4415 | === added file 'swig/ruby/tests/test01.rb' | |||
4416 | --- swig/ruby/tests/test01.rb 1970-01-01 00:00:00 +0000 | |||
4417 | +++ swig/ruby/tests/test01.rb 2012-03-26 20:16:18 +0000 | |||
4418 | @@ -0,0 +1,24 @@ | |||
4419 | 1 | # Copyright 2006-2012 The FLWOR Foundation. | ||
4420 | 2 | # | ||
4421 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
4422 | 4 | # you may not use this file except in compliance with the License. | ||
4423 | 5 | # You may obtain a copy of the License at | ||
4424 | 6 | # | ||
4425 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
4426 | 8 | # | ||
4427 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
4428 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
4429 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
4430 | 12 | # See the License for the specific language governing permissions and | ||
4431 | 13 | # limitations under the License. | ||
4432 | 14 | |||
4433 | 15 | require '@rubyPath@/zorba_api' | ||
4434 | 16 | |||
4435 | 17 | print "Running: Get zorba instance and shutdown" | ||
4436 | 18 | |||
4437 | 19 | store = Zorba_api::InMemoryStore.getInstance() | ||
4438 | 20 | zorba = Zorba_api::Zorba.getInstance(store) | ||
4439 | 21 | zorba.shutdown() | ||
4440 | 22 | Zorba_api::InMemoryStore.shutdown(store) | ||
4441 | 23 | |||
4442 | 24 | print "Success" | ||
4443 | 0 | 25 | ||
4444 | === added file 'swig/ruby/tests/test02.rb' | |||
4445 | --- swig/ruby/tests/test02.rb 1970-01-01 00:00:00 +0000 | |||
4446 | +++ swig/ruby/tests/test02.rb 2012-03-26 20:16:18 +0000 | |||
4447 | @@ -0,0 +1,39 @@ | |||
4448 | 1 | # Copyright 2006-2012 The FLWOR Foundation. | ||
4449 | 2 | # | ||
4450 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
4451 | 4 | # you may not use this file except in compliance with the License. | ||
4452 | 5 | # You may obtain a copy of the License at | ||
4453 | 6 | # | ||
4454 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
4455 | 8 | # | ||
4456 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
4457 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
4458 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
4459 | 12 | # See the License for the specific language governing permissions and | ||
4460 | 13 | # limitations under the License. | ||
4461 | 14 | |||
4462 | 15 | require '@rubyPath@/zorba_api' | ||
4463 | 16 | |||
4464 | 17 | def test(zorba) | ||
4465 | 18 | xquery = zorba.compileQuery("(1,2,3,4,5)") | ||
4466 | 19 | iter = xquery.iterator() | ||
4467 | 20 | iter.open() | ||
4468 | 21 | item = Zorba_api::Item.createEmptyItem() | ||
4469 | 22 | while iter.next(item) do | ||
4470 | 23 | print item.getStringValue() | ||
4471 | 24 | print "\n" | ||
4472 | 25 | end | ||
4473 | 26 | iter.close() | ||
4474 | 27 | iter.destroy() | ||
4475 | 28 | xquery.destroy() | ||
4476 | 29 | end | ||
4477 | 30 | |||
4478 | 31 | store = Zorba_api::InMemoryStore.getInstance() | ||
4479 | 32 | zorba = Zorba_api::Zorba.getInstance(store) | ||
4480 | 33 | |||
4481 | 34 | print "Running: Compile query string" | ||
4482 | 35 | test(zorba) | ||
4483 | 36 | print "Success" | ||
4484 | 37 | |||
4485 | 38 | zorba.shutdown() | ||
4486 | 39 | Zorba_api::InMemoryStore.shutdown(store) | ||
4487 | 0 | 40 | ||
4488 | === added file 'swig/ruby/tests/test03.rb' | |||
4489 | --- swig/ruby/tests/test03.rb 1970-01-01 00:00:00 +0000 | |||
4490 | +++ swig/ruby/tests/test03.rb 2012-03-26 20:16:18 +0000 | |||
4491 | @@ -0,0 +1,43 @@ | |||
4492 | 1 | # Copyright 2006-2012 The FLWOR Foundation. | ||
4493 | 2 | # | ||
4494 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
4495 | 4 | # you may not use this file except in compliance with the License. | ||
4496 | 5 | # You may obtain a copy of the License at | ||
4497 | 6 | # | ||
4498 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
4499 | 8 | # | ||
4500 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
4501 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
4502 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
4503 | 12 | # See the License for the specific language governing permissions and | ||
4504 | 13 | # limitations under the License. | ||
4505 | 14 | |||
4506 | 15 | require '@rubyPath@/zorba_api' | ||
4507 | 16 | |||
4508 | 17 | class MyDiagnosticHandler < Zorba_api.DiagnosticHandler | ||
4509 | 18 | def error(self, *args) | ||
4510 | 19 | print "Error args: " + args | ||
4511 | 20 | end | ||
4512 | 21 | end | ||
4513 | 22 | |||
4514 | 23 | def test(zorba): | ||
4515 | 24 | diagnosticHandler = MyDiagnosticHandler.new | ||
4516 | 25 | begin | ||
4517 | 26 | xquery = zorba.compileQuery("1 div 0", diagnosticHandler) | ||
4518 | 27 | print xquery.execute() | ||
4519 | 28 | rescue => e | ||
4520 | 29 | print "Caught error: " + e.message | ||
4521 | 30 | ensure | ||
4522 | 31 | xquery.destroy() | ||
4523 | 32 | end | ||
4524 | 33 | end | ||
4525 | 34 | |||
4526 | 35 | store = Zorba_api::InMemoryStore.getInstance() | ||
4527 | 36 | zorba = Zorba_api::Zorba.getInstance(store) | ||
4528 | 37 | |||
4529 | 38 | print "Running: Capturing error with DiagnosticHandler" | ||
4530 | 39 | test(zorba) | ||
4531 | 40 | print "Success" | ||
4532 | 41 | |||
4533 | 42 | zorba.shutdown() | ||
4534 | 43 | Zorba_api::InMemoryStore.shutdown(store) | ||
4535 | 0 | 44 | ||
4536 | === added file 'swig/ruby/tests/test04.rb' | |||
4537 | --- swig/ruby/tests/test04.rb 1970-01-01 00:00:00 +0000 | |||
4538 | +++ swig/ruby/tests/test04.rb 2012-03-26 20:16:18 +0000 | |||
4539 | @@ -0,0 +1,35 @@ | |||
4540 | 1 | # Copyright 2006-2012 The FLWOR Foundation. | ||
4541 | 2 | # | ||
4542 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
4543 | 4 | # you may not use this file except in compliance with the License. | ||
4544 | 5 | # You may obtain a copy of the License at | ||
4545 | 6 | # | ||
4546 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
4547 | 8 | # | ||
4548 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
4549 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
4550 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
4551 | 12 | # See the License for the specific language governing permissions and | ||
4552 | 13 | # limitations under the License. | ||
4553 | 14 | |||
4554 | 15 | require '@rubyPath@/zorba_api' | ||
4555 | 16 | |||
4556 | 17 | def test(zorba) | ||
4557 | 18 | print 'Executing: test04.xq' | ||
4558 | 19 | file = File.open("test04.xq", "rb") | ||
4559 | 20 | contents = file.read | ||
4560 | 21 | xquery = zorba.compileQuery(contents) | ||
4561 | 22 | result = xquery.execute() | ||
4562 | 23 | print result | ||
4563 | 24 | xquery.destroy() | ||
4564 | 25 | end | ||
4565 | 26 | |||
4566 | 27 | store = Zorba_api::InMemoryStore.getInstance() | ||
4567 | 28 | zorba = Zorba_api::Zorba.getInstance(store) | ||
4568 | 29 | |||
4569 | 30 | print "Running: XQuery execute" | ||
4570 | 31 | test(zorba) | ||
4571 | 32 | print "Success" | ||
4572 | 33 | |||
4573 | 34 | zorba.shutdown() | ||
4574 | 35 | Zorba_api::InMemoryStore.shutdown(store) | ||
4575 | 0 | 36 | ||
4576 | === added file 'swig/ruby/tests/test04.xq' | |||
4577 | --- swig/ruby/tests/test04.xq 1970-01-01 00:00:00 +0000 | |||
4578 | +++ swig/ruby/tests/test04.xq 2012-03-26 20:16:18 +0000 | |||
4579 | @@ -0,0 +1,4 @@ | |||
4580 | 1 | for tumbling window $w in (2, 4, 6, 8, 10, 12, 14) | ||
4581 | 2 | start at $s when fn:true() | ||
4582 | 3 | only end at $e when $e - $s eq 2 | ||
4583 | 4 | return avg($w) | ||
4584 | 0 | 5 | ||
4585 | === added file 'swig/ruby/tests/test05.rb' | |||
4586 | --- swig/ruby/tests/test05.rb 1970-01-01 00:00:00 +0000 | |||
4587 | +++ swig/ruby/tests/test05.rb 2012-03-26 20:16:18 +0000 | |||
4588 | @@ -0,0 +1,35 @@ | |||
4589 | 1 | # Copyright 2006-2011 The FLWOR Foundation. | ||
4590 | 2 | # | ||
4591 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
4592 | 4 | # you may not use this file except in compliance with the License. | ||
4593 | 5 | # You may obtain a copy of the License at | ||
4594 | 6 | # | ||
4595 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
4596 | 8 | # | ||
4597 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
4598 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
4599 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
4600 | 12 | # See the License for the specific language governing permissions and | ||
4601 | 13 | # limitations under the License. | ||
4602 | 14 | |||
4603 | 15 | require '@rubyPath@/zorba_api' | ||
4604 | 16 | |||
4605 | 17 | def test(zorba) | ||
4606 | 18 | print 'Executing: test05.xq' | ||
4607 | 19 | file = File.open("test05.xq", "rb") | ||
4608 | 20 | contents = file.read | ||
4609 | 21 | xquery = zorba.compileQuery(contents) | ||
4610 | 22 | result = xquery.printPlanAsXML() | ||
4611 | 23 | print result | ||
4612 | 24 | xquery.destroy() | ||
4613 | 25 | end | ||
4614 | 26 | |||
4615 | 27 | store = Zorba_api::InMemoryStore.getInstance() | ||
4616 | 28 | zorba = Zorba_api::Zorba.getInstance(store) | ||
4617 | 29 | |||
4618 | 30 | print "Running: XQuery execute - printPlanAsXML" | ||
4619 | 31 | test(zorba) | ||
4620 | 32 | print "Success" | ||
4621 | 33 | |||
4622 | 34 | zorba.shutdown() | ||
4623 | 35 | Zorba_api::InMemoryStore.shutdown(store) | ||
4624 | 0 | 36 | ||
4625 | === added file 'swig/ruby/tests/test05.xq' | |||
4626 | --- swig/ruby/tests/test05.xq 1970-01-01 00:00:00 +0000 | |||
4627 | +++ swig/ruby/tests/test05.xq 2012-03-26 20:16:18 +0000 | |||
4628 | @@ -0,0 +1,7 @@ | |||
4629 | 1 | for $x in (5,6,7,1,2,3,4) | ||
4630 | 2 | where $x < 4 | ||
4631 | 3 | for $y in (4,9,6,8,2) | ||
4632 | 4 | let $z := $x * $y | ||
4633 | 5 | where $z > 20 | ||
4634 | 6 | return | ||
4635 | 7 | <value x="{$x}" y="{$y}">{$z}</value> | ||
4636 | 0 | \ No newline at end of file | 8 | \ No newline at end of file |
4637 | 1 | 9 | ||
4638 | === added file 'swig/ruby/tests/test06.rb' | |||
4639 | --- swig/ruby/tests/test06.rb 1970-01-01 00:00:00 +0000 | |||
4640 | +++ swig/ruby/tests/test06.rb 2012-03-26 20:16:18 +0000 | |||
4641 | @@ -0,0 +1,35 @@ | |||
4642 | 1 | # Copyright 2006-2011 The FLWOR Foundation. | ||
4643 | 2 | # | ||
4644 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
4645 | 4 | # you may not use this file except in compliance with the License. | ||
4646 | 5 | # You may obtain a copy of the License at | ||
4647 | 6 | # | ||
4648 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
4649 | 8 | # | ||
4650 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
4651 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
4652 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
4653 | 12 | # See the License for the specific language governing permissions and | ||
4654 | 13 | # limitations under the License. | ||
4655 | 14 | |||
4656 | 15 | require '@rubyPath@/zorba_api' | ||
4657 | 16 | |||
4658 | 17 | def test(zorba) | ||
4659 | 18 | print 'Executing: test06.xq' | ||
4660 | 19 | file = File.open("test06.xq", "rb") | ||
4661 | 20 | contents = file.read | ||
4662 | 21 | xquery = zorba.compileQuery(contents) | ||
4663 | 22 | result = xquery.printPlanAsDOT() | ||
4664 | 23 | print result | ||
4665 | 24 | xquery.destroy() | ||
4666 | 25 | end | ||
4667 | 26 | |||
4668 | 27 | store = Zorba_api::InMemoryStore.getInstance() | ||
4669 | 28 | zorba = Zorba_api::Zorba.getInstance(store) | ||
4670 | 29 | |||
4671 | 30 | print "Running: XQuery execute - printPlanAsDOT" | ||
4672 | 31 | test(zorba) | ||
4673 | 32 | print "Success" | ||
4674 | 33 | |||
4675 | 34 | zorba.shutdown() | ||
4676 | 35 | Zorba_api::InMemoryStore.shutdown(store) | ||
4677 | 0 | 36 | ||
4678 | === added file 'swig/ruby/tests/test06.xq' | |||
4679 | --- swig/ruby/tests/test06.xq 1970-01-01 00:00:00 +0000 | |||
4680 | +++ swig/ruby/tests/test06.xq 2012-03-26 20:16:18 +0000 | |||
4681 | @@ -0,0 +1,7 @@ | |||
4682 | 1 | for $x in (5,6,7,1,2,3,4) | ||
4683 | 2 | where $x < 4 | ||
4684 | 3 | for $y in (4,9,6,8,2) | ||
4685 | 4 | let $z := $x * $y | ||
4686 | 5 | where $z > 20 | ||
4687 | 6 | return | ||
4688 | 7 | <value x="{$x}" y="{$y}">{$z}</value> | ||
4689 | 0 | \ No newline at end of file | 8 | \ No newline at end of file |
4690 | 1 | 9 | ||
4691 | === added file 'swig/ruby/tests/test07.rb' | |||
4692 | --- swig/ruby/tests/test07.rb 1970-01-01 00:00:00 +0000 | |||
4693 | +++ swig/ruby/tests/test07.rb 2012-03-26 20:16:18 +0000 | |||
4694 | @@ -0,0 +1,48 @@ | |||
4695 | 1 | # Copyright 2006-2011 The FLWOR Foundation. | ||
4696 | 2 | # | ||
4697 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
4698 | 4 | # you may not use this file except in compliance with the License. | ||
4699 | 5 | # You may obtain a copy of the License at | ||
4700 | 6 | # | ||
4701 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
4702 | 8 | # | ||
4703 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
4704 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
4705 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
4706 | 12 | # See the License for the specific language governing permissions and | ||
4707 | 13 | # limitations under the License. | ||
4708 | 14 | |||
4709 | 15 | require '@rubyPath@/zorba_api' | ||
4710 | 16 | |||
4711 | 17 | def test(zorba) | ||
4712 | 18 | file = File.open("books.xml", "rb") | ||
4713 | 19 | contents = file.read | ||
4714 | 20 | |||
4715 | 21 | dataManager = zorba.getXmlDataManager() | ||
4716 | 22 | docIter = dataManager.parseXML(contents) | ||
4717 | 23 | docIter.open() | ||
4718 | 24 | |||
4719 | 25 | doc = Zorba_api::Item.createEmptyItem() | ||
4720 | 26 | docIter.next(doc) | ||
4721 | 27 | |||
4722 | 28 | docIter.close() | ||
4723 | 29 | docIter.destroy() | ||
4724 | 30 | |||
4725 | 31 | docManager = dataManager.getDocumentManager() | ||
4726 | 32 | docManager.put("my_fake_books.xml", doc) | ||
4727 | 33 | xquery = zorba.compileQuery("doc('my_fake_books.xml')") | ||
4728 | 34 | |||
4729 | 35 | result = xquery.execute() | ||
4730 | 36 | print result | ||
4731 | 37 | xquery.destroy() | ||
4732 | 38 | end | ||
4733 | 39 | |||
4734 | 40 | store = Zorba_api::InMemoryStore.getInstance() | ||
4735 | 41 | zorba = Zorba_api::Zorba.getInstance(store) | ||
4736 | 42 | |||
4737 | 43 | print "Running: XQuery execute - parsing XML" | ||
4738 | 44 | test(zorba) | ||
4739 | 45 | print "Success" | ||
4740 | 46 | |||
4741 | 47 | zorba.shutdown() | ||
4742 | 48 | Zorba_api::InMemoryStore.shutdown(store) | ||
4743 | 0 | 49 | ||
4744 | === added file 'swig/ruby/tests/test08.rb' | |||
4745 | --- swig/ruby/tests/test08.rb 1970-01-01 00:00:00 +0000 | |||
4746 | +++ swig/ruby/tests/test08.rb 2012-03-26 20:16:18 +0000 | |||
4747 | @@ -0,0 +1,108 @@ | |||
4748 | 1 | # Copyright 2006-2011 The FLWOR Foundation. | ||
4749 | 2 | # | ||
4750 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
4751 | 4 | # you may not use this file except in compliance with the License. | ||
4752 | 5 | # You may obtain a copy of the License at | ||
4753 | 6 | # | ||
4754 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
4755 | 8 | # | ||
4756 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
4757 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
4758 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
4759 | 12 | # See the License for the specific language governing permissions and | ||
4760 | 13 | # limitations under the License. | ||
4761 | 14 | |||
4762 | 15 | require '@rubyPath@/zorba_api' | ||
4763 | 16 | |||
4764 | 17 | def test(zorba) | ||
4765 | 18 | print 'Executing: test08.xq' + "\n" | ||
4766 | 19 | lines = '(1, xs:int(2),"bla", <a><b att="{(3, xs:int(4),"foo", "bar")}"/>text<!--a comment--><?pi?></a>)' | ||
4767 | 20 | xquery = zorba.compileQuery(lines) | ||
4768 | 21 | result = xquery.execute() | ||
4769 | 22 | print result + "\n" | ||
4770 | 23 | |||
4771 | 24 | print "Iterator:" + "\n" | ||
4772 | 25 | iterator = xquery.iterator() | ||
4773 | 26 | printIterator(iterator, "") | ||
4774 | 27 | xquery.destroy() | ||
4775 | 28 | |||
4776 | 29 | end | ||
4777 | 30 | |||
4778 | 31 | |||
4779 | 32 | def printIterator(iterator, pre) | ||
4780 | 33 | item = Zorba_api::Item.createEmptyItem() | ||
4781 | 34 | iterator.open() | ||
4782 | 35 | while iterator.next(item) | ||
4783 | 36 | printItem(item, pre) | ||
4784 | 37 | end | ||
4785 | 38 | iterator.close() | ||
4786 | 39 | iterator.destroy() | ||
4787 | 40 | end | ||
4788 | 41 | |||
4789 | 42 | def printItem(item, pre) | ||
4790 | 43 | if item.isAtomic(): | ||
4791 | 44 | typeItem = item.getType() | ||
4792 | 45 | print pre + "Leaf Atomic: '" + item.getStringValue() + "' \ttype:", typeItem.getStringValue() + "\n" | ||
4793 | 46 | return | ||
4794 | 47 | end | ||
4795 | 48 | |||
4796 | 49 | if item.isNode(): | ||
4797 | 50 | kind = item.getNodeKind() | ||
4798 | 51 | |||
4799 | 52 | if kind == 0 # anyNode | ||
4800 | 53 | print pre + 'Any node' + "\n" | ||
4801 | 54 | print pre + " Children:" + "\n" | ||
4802 | 55 | printIterator(item.getChildren(), pre+" ") | ||
4803 | 56 | end | ||
4804 | 57 | if kind == 1 # doc | ||
4805 | 58 | print pre + 'Doc' + "\n" | ||
4806 | 59 | print pre + " Children:" + "\n" | ||
4807 | 60 | printIterator(item.getChildren(), pre+" ") | ||
4808 | 61 | end | ||
4809 | 62 | if kind == 2 # element | ||
4810 | 63 | nodeName = Zorba_api::Item.createEmptyItem() | ||
4811 | 64 | item.getNodeName(nodeName) | ||
4812 | 65 | typeItem = item.getType() | ||
4813 | 66 | print pre + "Start Element: ", nodeName.getStringValue() + " \ttype:", typeItem.getStringValue() + "\n" | ||
4814 | 67 | print pre + " Attributes:" + "\n" | ||
4815 | 68 | printIterator(item.getAttributes(), pre+" ") | ||
4816 | 69 | print pre + " Children:" + "\n" | ||
4817 | 70 | printIterator(item.getChildren(), pre+" ") | ||
4818 | 71 | print pre + "End Element: " + nodeName.getStringValue() + "\n" | ||
4819 | 72 | end | ||
4820 | 73 | if kind == 3 # attribute | ||
4821 | 74 | nodeName = Zorba_api::Item.createEmptyItem() | ||
4822 | 75 | item.getNodeName(nodeName) | ||
4823 | 76 | typeItem = item.getType() | ||
4824 | 77 | print pre + "Attribute: " + nodeName.getStringValue() + "= '" + item.getStringValue() + "'"" \ttype:" + typeItem.getStringValue() + "\n" | ||
4825 | 78 | print pre+" Atomization value:" + "\n" | ||
4826 | 79 | printIterator(item.getAtomizationValue(), pre+" ") | ||
4827 | 80 | end | ||
4828 | 81 | if kind == 4 # text | ||
4829 | 82 | typeItem = item.getType() | ||
4830 | 83 | print pre + "Text: " + item.getStringValue() + " \ttype:", typeItem.getStringValue() + "\n" | ||
4831 | 84 | print pre+" Atomization value:" + "\n" | ||
4832 | 85 | printIterator(item.getAtomizationValue(), pre+" ") | ||
4833 | 86 | end | ||
4834 | 87 | if kind == 5 # pi | ||
4835 | 88 | nodeName = Zorba_api::Item.createEmptyItem() | ||
4836 | 89 | item.getNodeName(nodeName) | ||
4837 | 90 | print pre + "Pi: " + nodeName.getStringValue() + "\n" | ||
4838 | 91 | end | ||
4839 | 92 | if kind == 6 # comment | ||
4840 | 93 | print pre + "Comment: " + item.getStringValue() + "\n" | ||
4841 | 94 | end | ||
4842 | 95 | else | ||
4843 | 96 | print pre+"Item not Node, not Atomic" + "\n" | ||
4844 | 97 | end | ||
4845 | 98 | end | ||
4846 | 99 | |||
4847 | 100 | store = Zorba_api::InMemoryStore.getInstance() | ||
4848 | 101 | zorba = Zorba_api::Zorba.getInstance(store) | ||
4849 | 102 | |||
4850 | 103 | print "Running: XQuery execute - Get Iterator and print info from its items" + "\n" | ||
4851 | 104 | test(zorba) | ||
4852 | 105 | print "Success" + "\n" | ||
4853 | 106 | |||
4854 | 107 | zorba.shutdown() | ||
4855 | 108 | Zorba_api::InMemoryStore.shutdown(store) | ||
4856 | 0 | 109 | ||
4857 | === added file 'swig/ruby/tests/test09.rb' | |||
4858 | --- swig/ruby/tests/test09.rb 1970-01-01 00:00:00 +0000 | |||
4859 | +++ swig/ruby/tests/test09.rb 2012-03-26 20:16:18 +0000 | |||
4860 | @@ -0,0 +1,81 @@ | |||
4861 | 1 | # Copyright 2006-2011 The FLWOR Foundation. | ||
4862 | 2 | # | ||
4863 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
4864 | 4 | # you may not use this file except in compliance with the License. | ||
4865 | 5 | # You may obtain a copy of the License at | ||
4866 | 6 | # | ||
4867 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
4868 | 8 | # | ||
4869 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
4870 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
4871 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
4872 | 12 | # See the License for the specific language governing permissions and | ||
4873 | 13 | # limitations under the License. | ||
4874 | 14 | |||
4875 | 15 | import sys | ||
4876 | 16 | sys.path.insert(0, '@pythonPath@') | ||
4877 | 17 | import zorba_api | ||
4878 | 18 | |||
4879 | 19 | |||
4880 | 20 | def test(zorba) | ||
4881 | 21 | xquery = zorba.compileQuery("<a>text-a1<b at1='att1' at2='{1+2}'>text-b1</b>text-a2</a>") | ||
4882 | 22 | |||
4883 | 23 | saxHandler = zorba_api.SAX2ContentHandlerProxy() | ||
4884 | 24 | saxHandler.setStartDocumentHandler(startDocumentHandler); | ||
4885 | 25 | saxHandler.setEndDocumentHandler(endDocumentHandler); | ||
4886 | 26 | saxHandler.setStartElementHandler(startElementHandler); | ||
4887 | 27 | saxHandler.setEndElementHandler(endElementHandler); | ||
4888 | 28 | saxHandler.setCharactersHandler(charactersHandler); | ||
4889 | 29 | saxHandler.setProcessingInstructionHandler(processingInstructionHandler); | ||
4890 | 30 | saxHandler.setIgnorableWhitespaceHandler(ignorableWhitespaceHandler); | ||
4891 | 31 | saxHandler.setStartPrefixMappingHandler(startPrefixMappingHandler); | ||
4892 | 32 | saxHandler.setEndPrefixMappingHandler(endPrefixMappingHandler); | ||
4893 | 33 | saxHandler.setSkippedEntityHandler(skippedEntityHandler); | ||
4894 | 34 | xquery.executeSAX(saxHandler) | ||
4895 | 35 | |||
4896 | 36 | return | ||
4897 | 37 | |||
4898 | 38 | |||
4899 | 39 | def startDocumentHandler(): | ||
4900 | 40 | print "Start Document" | ||
4901 | 41 | return | ||
4902 | 42 | def endDocumentHandler(): | ||
4903 | 43 | print "End Document" | ||
4904 | 44 | return | ||
4905 | 45 | def startElementHandler(URI, localName, QName, SAXAttributes): | ||
4906 | 46 | print "Start Element - ", QName | ||
4907 | 47 | return | ||
4908 | 48 | def endElementHandler(URI, localName, QName): | ||
4909 | 49 | print "End Element - ", QName | ||
4910 | 50 | return | ||
4911 | 51 | def charactersHandler(text): | ||
4912 | 52 | print "Characters - ", text | ||
4913 | 53 | return | ||
4914 | 54 | def processingInstructionHandler(target, data): | ||
4915 | 55 | print "Processing Instruction" | ||
4916 | 56 | return | ||
4917 | 57 | def ignorableWhitespaceHandler(text): | ||
4918 | 58 | print "Ignorable Whitespace - ", text | ||
4919 | 59 | return | ||
4920 | 60 | def startPrefixMappingHandler(prefix, URI): | ||
4921 | 61 | print "Start Prefix Mapping - ", prefix | ||
4922 | 62 | return | ||
4923 | 63 | def endPrefixMappingHandler(prefix): | ||
4924 | 64 | print "End Prefix Mapping - ", prefix | ||
4925 | 65 | return | ||
4926 | 66 | def skippedEntityHandler(name): | ||
4927 | 67 | print "Skipped Entity - ", name | ||
4928 | 68 | return | ||
4929 | 69 | |||
4930 | 70 | |||
4931 | 71 | store = zorba_api.InMemoryStore_getInstance() | ||
4932 | 72 | zorba = zorba_api.Zorba_getInstance(store) | ||
4933 | 73 | |||
4934 | 74 | print "Running: XQuery execute - executeSAX" | ||
4935 | 75 | test(zorba) | ||
4936 | 76 | print "Success" | ||
4937 | 77 | |||
4938 | 78 | |||
4939 | 79 | zorba.shutdown() | ||
4940 | 80 | zorba_api.InMemoryStore_shutdown(store) | ||
4941 | 81 | |||
4942 | 0 | 82 | ||
4943 | === added file 'swig/ruby/tests/test10.rb' | |||
4944 | --- swig/ruby/tests/test10.rb 1970-01-01 00:00:00 +0000 | |||
4945 | +++ swig/ruby/tests/test10.rb 2012-03-26 20:16:18 +0000 | |||
4946 | @@ -0,0 +1,46 @@ | |||
4947 | 1 | # Copyright 2006-2011 The FLWOR Foundation. | ||
4948 | 2 | # | ||
4949 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
4950 | 4 | # you may not use this file except in compliance with the License. | ||
4951 | 5 | # You may obtain a copy of the License at | ||
4952 | 6 | # | ||
4953 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
4954 | 8 | # | ||
4955 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
4956 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
4957 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
4958 | 12 | # See the License for the specific language governing permissions and | ||
4959 | 13 | # limitations under the License. | ||
4960 | 14 | |||
4961 | 15 | require '@rubyPath@/zorba_api' | ||
4962 | 16 | |||
4963 | 17 | def test(zorba) | ||
4964 | 18 | file = File.open("books.xml", "rb") | ||
4965 | 19 | contents = file.read | ||
4966 | 20 | |||
4967 | 21 | dataManager = zorba.getXmlDataManager() | ||
4968 | 22 | docIter = dataManager.parseXML(contents) | ||
4969 | 23 | docIter.open(); | ||
4970 | 24 | |||
4971 | 25 | doc = Zorba_api::Item.createEmptyItem() | ||
4972 | 26 | docIter.next(doc) | ||
4973 | 27 | |||
4974 | 28 | docIter.close() | ||
4975 | 29 | docIter.destroy() | ||
4976 | 30 | |||
4977 | 31 | xquery = zorba.compileQuery(".") | ||
4978 | 32 | dynCtx = xquery.getDynamicContext() | ||
4979 | 33 | dynCtx.setContextItem(doc) | ||
4980 | 34 | print xquery.execute() | ||
4981 | 35 | xquery.destroy() | ||
4982 | 36 | end | ||
4983 | 37 | |||
4984 | 38 | store = Zorba_api::InMemoryStore.getInstance() | ||
4985 | 39 | zorba = Zorba_api::Zorba.getInstance(store) | ||
4986 | 40 | |||
4987 | 41 | print "Running: XQuery execute - Get Iterator and print info from its items" | ||
4988 | 42 | test(zorba) | ||
4989 | 43 | print "Success" | ||
4990 | 44 | |||
4991 | 45 | zorba.shutdown() | ||
4992 | 46 | Zorba_api::InMemoryStore.shutdown(store) | ||
4993 | 0 | 47 | ||
4994 | === added file 'swig/ruby/tests/test11.rb' | |||
4995 | --- swig/ruby/tests/test11.rb 1970-01-01 00:00:00 +0000 | |||
4996 | +++ swig/ruby/tests/test11.rb 2012-03-26 20:16:18 +0000 | |||
4997 | @@ -0,0 +1,49 @@ | |||
4998 | 1 | # Copyright 2006-2011 The FLWOR Foundation. | ||
4999 | 2 | # | ||
5000 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
Looks good.