rdbxml 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2006 Steve Sloan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
data/README ADDED
@@ -0,0 +1,80 @@
1
+ = RDBXML -- XML Databases for Ruby
2
+
3
+ This package provides wrapper functions to the C++ APIS for BDB XML (Dbxml) and
4
+ BDB (Db) as well as pure-Ruby convenience functions (RDBXML). While the wrapper
5
+ layer should be more or less complete, the Ruby interface only supports basic
6
+ documents operations in this version of the library.
7
+
8
+ == Requirements
9
+ * Rake[http://rake.rubyforge.org] >= 7.0
10
+ * Berkely DBXML[http://dev.sleepycat.com/downloads/releasehistorybdbxml.html]
11
+
12
+ == Installation
13
+
14
+ === The Easy Way
15
+
16
+ RDBXML is distributed as a Ruby Gem for easy installation, e.g.
17
+ sudo gem install rdbxml
18
+
19
+ This will attempt to find the DBXML libaries/headers in the standard paths (plus
20
+ /usr/local/) and will use the interface files taken from the dbxml-2.2.13
21
+ distribution (the latest version, at the time of this writing).
22
+
23
+ === The Right Way
24
+
25
+ Due to tight dependencies, it's recommended that you obtain, build, and install
26
+ the latest version of the DBXML distribution (from
27
+ Sleepycat[http://dev.sleepycat.com/downloads/releasehistorybdbxml.html]), e.g.:
28
+ # fetch and extract
29
+ cd /tmp
30
+ wget http://downloads.sleepycat.com/dbxml-2.2.13.tar.gz
31
+ tar -xvzf dbxml-2.2.13.tar.gz
32
+ cd dbxml-2.2.13
33
+
34
+ # build (see DBXML docs for further instructions)
35
+ ./buildall.sh
36
+
37
+ # install
38
+ sudo cp -a /tmp/dbxml-2.2.13/install /usr/local
39
+ sudo ldconfig
40
+
41
+ This will ensure that you have the correct versions of the various BDB and
42
+ BDBXML libraries, as well as the current SWIG Interface definitions included in the
43
+ the DBXML distribution.
44
+
45
+ You then pass the location of the (built) DBXML distribution to the RDBXML build system:
46
+ DBXML_DIST=/tmp/dbxml-2.2.13 sudo gem install rdbxml
47
+
48
+ This will build, test, and install the RDBXML gem.
49
+
50
+ == Example Usage
51
+ require 'rubygems'
52
+ require 'rdbxml'
53
+
54
+ # create database directory
55
+ env_dir = './db-env'
56
+ Dir.mkdir env_dir unless File.exists? env_dir
57
+
58
+ # create environment, database, and container
59
+ env = RDBXML::env env_dir
60
+ db = RDBXML::XmlManager.new env, 0
61
+ docs = db['documents']
62
+
63
+ # Create document
64
+ docs['Document Name'] = '<doc>Documet XML</doc>'
65
+
66
+ # Read document
67
+ puts docs['Document Name'].to_s
68
+
69
+ == Disclaimer
70
+
71
+ This is an *alpha* relesae, intended to test the build system and the BDBXML API
72
+ wrappers. The Ruby-style interface is not yet terribly useful (you can read and
73
+ write whole documents), but I wanted to get this basic version released before I
74
+ went back and started adding functionality.
75
+
76
+ Please report any issues on the RDBXML Website[http://rubyforge.org/projects/rdbxml].
77
+
78
+ Author:: Steve Sloan (mailto:steve@finagle.org)
79
+ Copyright:: Copyright (c) 2006 Steve Sloan
80
+ License:: MIT
data/Rakefile ADDED
@@ -0,0 +1,100 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/swigextensiontask'
4
+ require 'rake/testtask'
5
+ require 'rake/rdoctask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/contrib/rubyforgepublisher'
8
+
9
+ dbxml_dist = ENV['DBXML_DIST']
10
+ if dbxml_dist
11
+ puts "*** Using DBXML distribution in #{dbxml_dist}"
12
+ Rake::ExtensionTask.env.update(
13
+ :swig_includedirs => [File.join( dbxml_dist, 'dbxml/dist/swig' ), '.'],
14
+ :includedirs => File.join( dbxml_dist, 'install/include' ),
15
+ :libdirs => File.join( dbxml_dist, 'install/lib' )
16
+ )
17
+ else
18
+ Rake::ExtensionTask.env.update(
19
+ :includedirs => '/usr/local/include',
20
+ :libdirs => '/usr/local/lib'
21
+ )
22
+ end
23
+
24
+ desc "Build the interface extension"
25
+ task :extensions => [:db, :dbxml]
26
+ CLEAN.include 'ext/*_wrap.cc'
27
+
28
+ desc "Build the BDB interface extension"
29
+ Rake::SWIGExtensionTask.new :db do |t|
30
+ t.dir = 'ext'
31
+ t.link_libs += ['db', 'db_cxx']
32
+ end
33
+
34
+ desc "Build the BDBXML interface extension"
35
+ Rake::SWIGExtensionTask.new :dbxml do |t|
36
+ t.dir = 'ext'
37
+ t.deps << 'dbxml_ruby.i'
38
+ t.link_libs += ['db', 'db_cxx', 'dbxml', 'xquery', 'xerces-c', 'pathan']
39
+ end
40
+
41
+ task :test => :extensions
42
+ Rake::TestTask.new do |t|
43
+ t.libs << "ext"
44
+ t.test_files = FileList['test/*_test.rb']
45
+ t.verbose = true
46
+ CLEAN.include 'test/*_test.db'
47
+ end
48
+
49
+ task :install => [:test, :clean] do end
50
+
51
+ rd = Rake::RDocTask.new :rdoc do |rdoc|
52
+ rdoc.rdoc_dir = 'html'
53
+ rdoc.title = "RDBXML -- XML Databases for Ruby"
54
+ rdoc.options += ['--line-numbers', '--inline-source', '--main', 'README', '--exclude', 'ext/*.c*']
55
+ rdoc.rdoc_files.include 'README', 'MIT-LICENSE'
56
+ rdoc.rdoc_files.include 'lib/**/*.rb'
57
+ rdoc.rdoc_files.include 'docs/**/*.rb', 'docs/**/*.rdoc'
58
+ rdoc.rdoc_files.include 'rake/**/*.rb'
59
+ end
60
+
61
+ GEM_VERSION = '0.1'
62
+ GEM_FILES = rd.rdoc_files + FileList[
63
+ 'Rakefile',
64
+ 'ext/**/*.i',
65
+ 'rake/**/*.rb',
66
+ 'test/**/*_test.rb',
67
+ ]
68
+
69
+ spec = Gem::Specification.new do |s|
70
+ s.platform = Gem::Platform::RUBY
71
+ s.name = 'rdbxml'
72
+ s.version = GEM_VERSION
73
+ s.date = Date.today.to_s
74
+ s.authors = ["Steve Sloan"]
75
+ s.summary = 'Provides wrappers for the BDBXML (and BDB) C++ APIs, plus pure Ruby extensions'
76
+ s.description = <<-END
77
+ END
78
+ s.files = GEM_FILES.to_a.delete_if {|f| f.include?('.svn')}
79
+ s.autorequire = 'rdbxml'
80
+ s.test_files = Dir["test/*_test.rb"]
81
+ s.add_dependency 'rake', '> 0.7.0'
82
+
83
+ s.extensions << './extconf.rb'
84
+ s.require_paths << 'ext'
85
+
86
+ s.has_rdoc = true
87
+ s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
88
+ s.rdoc_options = rd.options
89
+ end
90
+ Rake::GemPackageTask.new spec do |pkg|
91
+ pkg.need_zip = true
92
+ pkg.need_tar = true
93
+ end
94
+
95
+ task :default => :extensions
96
+ task :all => :extensions
97
+
98
+ #load 'publish.rf' if File.exist? 'publish.rf'
99
+
100
+
data/docs/db.rb ADDED
@@ -0,0 +1,6 @@
1
+ # = Db -- Berkly DB API Interface
2
+ #
3
+ # This module provides a wrapper around the BDB C++ API: http://www.sleepycat.com/xmldocs/api_cxx/api_core.html
4
+
5
+ module Db
6
+ end
data/docs/dbxml.rb ADDED
@@ -0,0 +1,6 @@
1
+ # = Dbxml -- Berkly DB XML API Interface
2
+ #
3
+ # This module provides a wrapper around the BDB XML C++ API: http://www.sleepycat.com/xmldocs/api_cxx/api_xml.html
4
+
5
+ module Dbxml
6
+ end
data/ext/db.i ADDED
@@ -0,0 +1,23 @@
1
+ %module db
2
+ %include "exception.i"
3
+ %include "typemaps.i"
4
+
5
+ %exception {
6
+ try {
7
+ $action
8
+ } catch ( DbException &ex ) {
9
+ static VALUE rb_DBException = rb_define_class("DBException", rb_eStandardError);
10
+ rb_raise( rb_DBException, ex.what() );
11
+ }
12
+ }
13
+
14
+ %ignore DbMpoolFile::get_transactional;
15
+ %include "db_cxx.h"
16
+
17
+ %{
18
+ #include "db_cxx.h"
19
+ %}
20
+
21
+ typedef unsigned int u_int32_t;
22
+ typedef int int32_t;
23
+
data/ext/dbxml.i ADDED
@@ -0,0 +1,1708 @@
1
+ %include "exception.i"
2
+ %include "typemaps.i"
3
+
4
+ %{
5
+ #include "db_cxx.h"
6
+ #include "dbxml/DbXml.hpp"
7
+ #include <errno.h>
8
+ #include <fstream>
9
+
10
+ using namespace DbXml;
11
+
12
+ class XmlIndexDeclaration {
13
+ public:
14
+ XmlIndexDeclaration() {}
15
+ XmlIndexDeclaration(const std::string &uri, const std::string &name, const std::string &index) : uri(uri), name(name), index(index) {}
16
+ #ifndef SWIGJAVA
17
+ const std::string &get_uri() const { return uri; }
18
+ const std::string &get_name() const { return name; }
19
+ const std::string &get_index() const { return index; }
20
+ #endif
21
+ std::string uri, name, index;
22
+ };
23
+
24
+ class XmlMetaData {
25
+ public:
26
+ XmlMetaData() {}
27
+ XmlMetaData(const std::string &uri, const std::string &name, const
28
+ XmlValue &value) : uri(uri), name(name), value(value) {}
29
+
30
+ const std::string &get_uri() const { return uri; }
31
+ const std::string &get_name() const { return name; }
32
+ const XmlValue &get_value() const { return value; }
33
+ std::string uri, name;
34
+ XmlValue value;
35
+ };
36
+
37
+ %}
38
+
39
+ #if defined(SWIGJAVA)
40
+ %include "std_string.i"
41
+ %include "dbxml_java.i"
42
+ #elif defined(SWIGPYTHON)
43
+ %include "std_string.i"
44
+ %include "dbxml_python.i"
45
+ #elif defined(SWIGTCL8)
46
+ %include "std_string.i"
47
+ %include "dbxml_tcl.i"
48
+ #elif defined(SWIGCSHARP)
49
+ %include "dbxml_csharp.i"
50
+ #elif defined(SWIGPHP4)
51
+ %include "std_string.i"
52
+ %include "dbxml_php4.i"
53
+ #elif defined(SWIGRUBY)
54
+ %include "dbxml_ruby.i"
55
+ #else
56
+ #error "Unknown SWIG target language"
57
+ #endif
58
+
59
+ #if defined(SWIGJAVA) || defined(SWIGPYTHON) || defined(SWIGCSHARP) || defined(SWIGTCL8) || defined(SWIGRUBY)
60
+ #define DBXML_USEOVERLOADS
61
+ #endif
62
+
63
+ #if defined(SWIGJAVA) || defined(SWIGPYTHON)
64
+ #define DBXML_USE_RESOLVER
65
+ #endif
66
+
67
+ typedef unsigned int u_int32_t;
68
+ typedef int int32_t;
69
+
70
+ class XmlManager;
71
+ class XmlDocument;
72
+ class XmlContainer;
73
+ class XmlIndexSpecification;
74
+ class XmlIndexLookup;
75
+ class XmlInputStream;
76
+ class XmlQueryContext;
77
+ class XmlResults;
78
+ class XmlUpdateContext;
79
+ class XmlValue;
80
+ class XmlQueryExpression;
81
+ class XmlModify;
82
+ class XmlTransaction;
83
+ class XmlMetaDataIterator;
84
+ class XmlStatistics;
85
+ #if defined(DBXML_USE_RESOLVER)
86
+ class XmlResolver;
87
+ #endif
88
+
89
+
90
+ #if defined(DBXML_USEOVERLOADS)
91
+ #define OVERLOAD_NAME(n)
92
+ #else
93
+ #define OVERLOAD_NAME(n) %rename(n)
94
+ #endif
95
+
96
+ // SWIG will generate a class per enumeration by default
97
+
98
+ #ifndef SWIGJAVA
99
+ // For Java, this is done differently
100
+ enum {
101
+ DB_CREATE, DB_DIRTY_READ, DB_EXCL,
102
+ DB_NOMMAP, DB_RDONLY, DB_THREAD,
103
+ DB_INIT_LOCK, DB_INIT_LOG, DB_INIT_MPOOL, DB_INIT_TXN,
104
+ DB_SALVAGE, DB_AGGRESSIVE
105
+ };
106
+
107
+ #endif
108
+
109
+
110
+ #ifdef SWIGJAVA
111
+ %javaconst(1);
112
+ #endif
113
+
114
+ //
115
+ // see DbXmlFwd.hpp for these enums
116
+ //
117
+ // Global flags
118
+ enum {
119
+ DBXML_ADOPT_DBENV = 0x00000001,
120
+ DBXML_ALLOW_EXTERNAL_ACCESS = 0x00000002,
121
+ DBXML_ALLOW_AUTO_OPEN = 0x00000004,
122
+ DBXML_ALLOW_VALIDATION = 0x00100000,
123
+ DBXML_TRANSACTIONAL = 0x00200000,
124
+ DBXML_REVERSE_ORDER = 0x00100000,
125
+ DBXML_INDEX_VALUES = 0x00200000,
126
+ DBXML_CACHE_DOCUMENTS = 0x00400000,
127
+ DBXML_CHKSUM = 0x00400000,
128
+ DBXML_ENCRYPT = 0x00800000,
129
+ DBXML_NO_INDEX_NODES = 0x10000000,
130
+ DBXML_GEN_NAME = 0x20000000,
131
+ DBXML_LAZY_DOCS = 0x40000000,
132
+ DBXML_INDEX_NODES = 0x80000000
133
+ };
134
+
135
+ // LogLevel
136
+ enum {
137
+ LEVEL_NONE = 0x00000000, ///< No debug levels are enabled.
138
+ LEVEL_DEBUG = 0x00000001, ///< Program execution tracing messages.
139
+ LEVEL_INFO = 0x00000002, ///< Informational, just for interest.
140
+ LEVEL_WARNING = 0x00000004, ///< For warnings, bad things but recoverable.
141
+ LEVEL_ERROR = 0x00000008, ///< For errors that can't be recovered from.
142
+ LEVEL_ALL = 0xFFFFFFFF ///< All debug levels are enabled.
143
+ };
144
+
145
+ // LogCategory
146
+ enum {
147
+ CATEGORY_NONE = 0x00000000,
148
+ CATEGORY_INDEXER = 0x00000001,
149
+ CATEGORY_QUERY = 0x00000002,
150
+ CATEGORY_OPTIMIZER = 0x00000004,
151
+ CATEGORY_DICTIONARY = 0x00000008,
152
+ CATEGORY_CONTAINER = 0x00000010,
153
+ CATEGORY_NODESTORE = 0x00000020,
154
+ CATEGORY_MANAGER = 0x00000040,
155
+ CATEGORY_ALL = 0xFFFFFFFF
156
+ };
157
+
158
+ //
159
+ // These strings are reproduced from src/dbxml/XmlNamespace.cpp.
160
+ // Using them as direct constants is simpler (from a SWIG point of view)
161
+ // than trying to reference their C++ values on demand. This means
162
+ // maintaining them together, if they change.
163
+ //
164
+ %constant const char *metaDataNamespace_uri = "http://www.sleepycat.com/2002/dbxml";
165
+ %constant const char *metaDataNamespace_prefix = "dbxml";
166
+ %constant const char *metaDataName_name = "name";
167
+ %constant const char *metaDataName_root = "root";
168
+
169
+ #ifdef SWIGTCL8
170
+ /* Put these at global scope for swig */
171
+ %typemap(in, numinputs = 0) int *majorp, int *minorp, int *patchp %{ $1 = NULL; %}
172
+ const char *dbxml_version(int *majorp, int *minorp, int *patchp);
173
+ void setLogLevel(enum LogLevel level, bool enabled) {
174
+ DbXml::setLogLevel(level, enabled)
175
+ }
176
+ void setLogCategory(enum LogCategory category, bool enabled) {
177
+ DbXml::setLogCategory(category, enabled)
178
+ }
179
+ #endif /* SWIGTCL8 */
180
+
181
+ /*
182
+ * All the methods that return pointers to allocated memory.
183
+ * Required so the memory is freed when the objects are deleted.
184
+ */
185
+ %newobject XmlManager::createContainer(const std::string &);
186
+ %newobject XmlManager::createContainer(const std::string &, // name
187
+ u_int32_t, //flags
188
+ enum XmlContainer::ContainerType=
189
+ XmlContainer::NodeContainer,
190
+ int mode=0); // mode
191
+ %newobject XmlManager::createContainer(XmlTransaction &, const std::string &);
192
+ %newobject XmlManager::createContainer(XmlTransaction &, const std::string &,
193
+ u_int32_t, // flags
194
+ enum XmlContainer::ContainerType=
195
+ XmlContainer::NodeContainer,
196
+ int mode=0); // mode
197
+ %newobject XmlManager::openContainer(const std::string &);
198
+ %newobject XmlManager::openContainer(const std::string &, u_int32_t);
199
+ %newobject XmlManager::openContainer(XmlTransaction &, const std::string &);
200
+ %newobject XmlManager::openContainer(XmlTransaction &, const std::string &,
201
+ u_int32_t);
202
+ %newobject XmlManager::openContainer(XmlTransaction &, const std::string &,
203
+ u_int32_t,
204
+ enum XmlContainer::ContainerType,
205
+ int mode = 0);
206
+ %newobject XmlManager::openContainer(const std::string &,
207
+ u_int32_t,
208
+ enum XmlContainer::ContainerType,
209
+ int mode = 0);
210
+ %newobject XmlManager::createDocument();
211
+
212
+ %newobject XmlManager::createQueryContext(enum XmlQueryContext::ReturnType,
213
+ enum XmlQueryContext::EvaluationType);
214
+ %newobject XmlManager::createQueryContext(enum XmlQueryContext::ReturnType);
215
+ %newobject XmlManager::createQueryContext();
216
+
217
+ %newobject XmlManager::createUpdateContext();
218
+
219
+ %newobject XmlManager::prepare(const std::string &, XmlQueryContext &);
220
+ %newobject XmlManager::prepare(XmlTransaction &, const std::string &,
221
+ XmlQueryContext &);
222
+ %newobject XmlManager::query(const std::string &, XmlQueryContext &, u_int32_t);
223
+ %newobject XmlManager::query(XmlTransaction &, const std::string &,
224
+ XmlQueryContext &, u_int32_t);
225
+ %newobject XmlManager::query(const std::string &, XmlQueryContext &);
226
+ %newobject XmlManager::query(XmlTransaction &, const std::string &,
227
+ XmlQueryContext &);
228
+ %newobject XmlManager::createResults();
229
+ %newobject XmlManager::createModify();
230
+
231
+
232
+ %newobject XmlManager::createTransaction(DbTxn *);
233
+ #ifndef SWIGJAVA
234
+ %newobject XmlManager::createTransaction();
235
+ %newobject XmlManager::createTransaction(u_int32_t);
236
+ %newobject XmlTransaction::createChild(u_int32_t);
237
+ %newobject XmlTransaction::createChild();
238
+ #endif
239
+
240
+ %newobject XmlContainer::getIndexSpecification() const;
241
+ %newobject XmlContainer::getIndexSpecification(XmlTransaction&) const;
242
+ %newobject XmlContainer::getIndexSpecification(XmlTransaction&,
243
+ u_int32_t flags) const;
244
+ %newobject XmlManager::createIndexLookup(
245
+ XmlContainer &cont,
246
+ const std::string &uri,
247
+ const std::string &name,
248
+ const std::string &index,
249
+ const XmlValue &value = XmlValue(),
250
+ enum XmlIndexLookup::Operation op = XmlIndexLookup::NONE);
251
+
252
+ %newobject XmlIndexLookup::execute(
253
+ XmlQueryContext &ctx, u_int32_t flags = 0) const;
254
+ %newobject XmlIndexLookup::execute(
255
+ XmlTransaction &, XmlQueryContext &ctx, u_int32_t flags = 0) const;
256
+
257
+ #ifndef SWIGJAVA
258
+ %newobject XmlContainer::getDocument(const std::string&);
259
+ %newobject XmlContainer::getDocument(XmlTransaction&, const std::string&);
260
+ #endif
261
+ %newobject XmlContainer::getDocument(const std::string&, u_int32_t);
262
+ %newobject XmlContainer::getDocument(XmlTransaction&, const std::string&,
263
+ u_int32_t);
264
+ %newobject XmlContainer::getAllDocuments(u_int32_t);
265
+ %newobject XmlContainer::getAllDocuments(XmlTransaction&, u_int32_t);
266
+ %newobject XmlContainer::lookupIndex(XmlQueryContext &, const std::string &,
267
+ const std::string &, const std::string &);
268
+ %newobject XmlContainer::lookupIndex(XmlQueryContext &, const std::string &,
269
+ const std::string &, const std::string &,
270
+ const XmlValue &, u_int32_t);
271
+ %newobject XmlContainer::lookupIndex(XmlQueryContext &, const std::string &,
272
+ const std::string &, const std::string &,
273
+ const XmlValue &);
274
+ %newobject XmlContainer::lookupIndex(XmlQueryContext &, const std::string &,
275
+ const std::string &, const std::string &,
276
+ const std::string &, const std::string &);
277
+ %newobject XmlContainer::lookupIndex(XmlQueryContext &, const std::string &,
278
+ const std::string &, const std::string &,
279
+ const std::string &, const std::string &,
280
+ const XmlValue &, u_int32_t);
281
+ %newobject XmlContainer::lookupIndex(XmlQueryContext &, const std::string &,
282
+ const std::string &, const std::string &,
283
+ const std::string &, const std::string &,
284
+ const XmlValue &);
285
+ %newobject XmlContainer::lookupIndex(XmlTransaction &, XmlQueryContext &,
286
+ const std::string &, const std::string &,
287
+ const std::string &);
288
+ %newobject XmlContainer::lookupIndex(XmlTransaction &, XmlQueryContext &,
289
+ const std::string &, const std::string &,
290
+ const std::string &, const XmlValue &,
291
+ u_int32_t);
292
+ %newobject XmlContainer::lookupIndex(XmlTransaction &, XmlQueryContext &,
293
+ const std::string &, const std::string &,
294
+ const std::string &, const XmlValue &);
295
+ %newobject XmlContainer::lookupIndex(XmlTransaction &, XmlQueryContext &,
296
+ const std::string &, const std::string &,
297
+ const std::string &, const std::string &,
298
+ const std::string &);
299
+ %newobject XmlContainer::lookupIndex(XmlTransaction &, XmlQueryContext &,
300
+ const std::string &, const std::string &,
301
+ const std::string &, const std::string &,
302
+ const std::string &, const XmlValue &,
303
+ u_int32_t);
304
+ %newobject XmlContainer::lookupIndex(XmlTransaction &, XmlQueryContext &,
305
+ const std::string &, const std::string &,
306
+ const std::string &, const std::string &,
307
+ const std::string &, const XmlValue &);
308
+ %newobject XmlContainer::lookupStatistics(const std::string &,
309
+ const std::string &, const std::string &);
310
+ %newobject XmlContainer::lookupStatistics(const std::string &,
311
+ const std::string &, const std::string &,
312
+ const XmlValue &);
313
+ %newobject XmlContainer::lookupStatistics(const std::string &,
314
+ const std::string &, const std::string &,
315
+ const std::string &, const std::string &);
316
+ %newobject XmlContainer::lookupStatistics(const std::string &,
317
+ const std::string &, const std::string &,
318
+ const std::string &, const std::string &,
319
+ const XmlValue &);
320
+ %newobject XmlContainer::lookupStatistics(XmlTransaction &,
321
+ const std::string &, const std::string &,
322
+ const std::string &);
323
+ %newobject XmlContainer::lookupStatistics(XmlTransaction &,
324
+ const std::string &, const std::string &,
325
+ const std::string &, const XmlValue &);
326
+ %newobject XmlContainer::lookupStatistics(XmlTransaction &,
327
+ const std::string &, const std::string &,
328
+ const std::string &, const std::string &,
329
+ const std::string &);
330
+ %newobject XmlContainer::lookupStatistics(XmlTransaction &,
331
+ const std::string &, const std::string &,
332
+ const std::string &, const std::string &,
333
+ const std::string &, const XmlValue &);
334
+
335
+ %newobject XmlDocument::getContent() const;
336
+ %newobject XmlDocument::getMetaDataIterator() const;
337
+ %newobject XmlDocument::getContentAsXmlInputStream() const;
338
+
339
+ %newobject XmlQueryContext::getVariableValue(const std::string&) const;
340
+
341
+ %newobject XmlQueryExpression::execute(XmlQueryContext &, u_int32_t) const;
342
+ %newobject XmlQueryExpression::execute(XmlQueryContext &) const;
343
+ %newobject XmlQueryExpression::execute(const XmlValue &, XmlQueryContext &,
344
+ u_int32_t) const;
345
+ %newobject XmlQueryExpression::execute(const XmlValue &, XmlQueryContext &) const;
346
+ %newobject XmlQueryExpression::execute(XmlTransaction &, XmlQueryContext &,
347
+ u_int32_t) const;
348
+ %newobject XmlQueryExpression::execute(XmlTransaction &, XmlQueryContext &) const;
349
+ %newobject XmlQueryExpression::execute(XmlTransaction &, const XmlValue &,
350
+ XmlQueryContext &, u_int32_t) const;
351
+ %newobject XmlQueryExpression::execute(XmlTransaction &, const XmlValue &,
352
+ XmlQueryContext &) const;
353
+
354
+
355
+ #if defined(SWIGJAVA) || defined(SWIGPYTHON) || defined(SWIGPHP4) || defined(SWIGRUBY)
356
+ %newobject XmlResults::next();
357
+ %newobject XmlResults::previous();
358
+ %newobject XmlResults::peek();
359
+ #endif
360
+
361
+ #ifdef SWIGTCL8
362
+ %newobject XmlValue::asDocument(const XmlQueryContext*) const;
363
+ #endif
364
+
365
+ %newobject XmlValue::getParentNode() const;
366
+ %newobject XmlValue::getFirstChild() const;
367
+ %newobject XmlValue::getLastChild() const;
368
+ %newobject XmlValue::getPreviousSibling() const;
369
+ %newobject XmlValue::getNextSibling() const;
370
+ %newobject XmlValue::getAttributes() const;
371
+ %newobject XmlValue::getOwnerElement() const;
372
+ %newobject XmlValue::asBinary() const;
373
+
374
+ %newobject XmlIndexSpecification::find(const std::string&, const std::string&);
375
+ %newobject XmlIndexSpecification::next();
376
+
377
+ %newobject XmlMetaDataIterator::next();
378
+
379
+ #if defined(DBXML_USE_RESOLVER)
380
+ %newobject XmlResolver::resolveSchema(XmlTransaction*, XmlManager&, const std::string&, const std::string&) const;
381
+ %newobject XmlResolver::resolveEntity(XmlTransaction*, XmlManager&, const std::string&, const std::string&) const;
382
+ #endif
383
+
384
+ #ifdef SWIGJAVA
385
+ %nodefault XmlManager;
386
+ #endif
387
+
388
+ class XmlManager
389
+ {
390
+ public:
391
+
392
+ #ifndef SWIGJAVA
393
+ XmlManager();
394
+ #endif
395
+ #ifndef SWIGJAVA
396
+ OVERLOAD_NAME(XmlManagerWithFlags)
397
+ XmlManager(u_int32_t flags);
398
+ #endif
399
+ OVERLOAD_NAME(XmlManagerFromEnv)
400
+ XmlManager(DbEnv *dbEnv, u_int32_t flags);
401
+ ~XmlManager();
402
+
403
+ #ifndef SWIGJAVA
404
+ void setDefaultContainerFlags(u_int32_t flags);
405
+ u_int32_t getDefaultContainerFlags();
406
+ #endif
407
+ void setDefaultPageSize(u_int32_t pageSize);
408
+ u_int32_t getDefaultPageSize();
409
+ void setDefaultSequenceIncrement(u_int32_t incr);
410
+ u_int32_t getDefaultSequenceIncrement();
411
+ void setDefaultContainerType(enum XmlContainer::ContainerType type);
412
+ enum XmlContainer::ContainerType getDefaultContainerType();
413
+ #ifndef SWIGJAVA
414
+ DbEnv *getDbEnv();
415
+ #endif
416
+ const std::string &getHome() const;
417
+ #if defined(DBXML_USE_RESOLVER)
418
+ void registerResolver(const XmlResolver &resolver);
419
+ #endif
420
+
421
+ int existsContainer(const std::string &name);
422
+ void removeContainer(const std::string &name);
423
+ OVERLOAD_NAME(removeContainerWithTxn)
424
+ void removeContainer(XmlTransaction &txn, const std::string &name);
425
+ void renameContainer(const std::string &oldName,
426
+ const std::string &newName);
427
+ OVERLOAD_NAME(renameContainerWithTxn)
428
+ void renameContainer(XmlTransaction &txn, const std::string &oldName,
429
+ const std::string &newName);
430
+ void upgradeContainer(const std::string &name, XmlUpdateContext &uc);
431
+ void reindexContainer(const std::string &name, XmlUpdateContext &uc,
432
+ u_int32_t flags = 0);
433
+ void reindexContainer(XmlTransaction &txn, const std::string &name,
434
+ XmlUpdateContext &uc, u_int32_t flags = 0);
435
+ %extend {
436
+
437
+ XmlInputStream* createStdInInputStream() const {
438
+ return self->createStdInInputStream();
439
+ }
440
+
441
+ XmlInputStream* createLocalFileInputStream(
442
+ const std::string &filename) const {
443
+ return self->createLocalFileInputStream(filename);
444
+ }
445
+
446
+ // The following method does not work correctly with Java
447
+ // because the JNI layer copies the Java String, then
448
+ // releases it upon return, leaving an invalid buffer.
449
+ // It appears to work for Python
450
+ //
451
+ XmlInputStream* createMemBufInputStream(
452
+ const char *bytes, const unsigned int count,
453
+ const char *id, const bool adopt = false) const {
454
+ return self->createMemBufInputStream(bytes,
455
+ count,
456
+ id, adopt);
457
+ }
458
+ // This form *always* adopts the buffer, copied or not
459
+ // It is supplied for use by Java, primarily
460
+ OVERLOAD_NAME(createMemBufInputStreamCopy)
461
+ XmlInputStream* createMemBufInputStream(
462
+ const char *bytes, const unsigned int count,
463
+ const bool copyBuffer) const {
464
+ return self->createMemBufInputStream(bytes,
465
+ count,
466
+ copyBuffer);
467
+ }
468
+
469
+ OVERLOAD_NAME(createURLInputStreamWithPublicID)
470
+ XmlInputStream* createURLInputStream(
471
+ const std::string &baseId,
472
+ const std::string &systemId,
473
+ const std::string &publicId) const {
474
+ return self->createURLInputStream(baseId, systemId, publicId);
475
+ }
476
+
477
+ XmlInputStream* createURLInputStream(
478
+ const std::string &baseId,
479
+ const std::string &systemId) const {
480
+ return self->createURLInputStream(baseId, systemId);
481
+ }
482
+
483
+ #ifndef SWIGJAVA // these are implemented in pure java
484
+ XmlContainer *createContainer(const std::string &name) {
485
+ return new XmlContainer(self->createContainer(name));
486
+ }
487
+ OVERLOAD_NAME(createContainerWithTxn)
488
+ XmlContainer *createContainer(
489
+ XmlTransaction &txn, const std::string &name) {
490
+ return new XmlContainer(self->createContainer(txn, name));
491
+ }
492
+ OVERLOAD_NAME(openContainerWithTxn)
493
+ XmlContainer *openContainer(XmlTransaction &txn,
494
+ const std::string &name) {
495
+ return new XmlContainer(self->openContainer(txn, name));
496
+ }
497
+ XmlContainer *openContainer(const std::string &name) {
498
+ return new XmlContainer(self->openContainer(name));
499
+ }
500
+ #endif // SWIGJAVA
501
+
502
+ OVERLOAD_NAME(createContainerWithFlags)
503
+ XmlContainer *createContainer(
504
+ const std::string &name, u_int32_t flags,
505
+ enum XmlContainer::ContainerType type =
506
+ XmlContainer::NodeContainer,
507
+ int mode = 0) {
508
+ return new XmlContainer(
509
+ self->createContainer(name, flags, type, mode));
510
+ }
511
+
512
+ OVERLOAD_NAME(createContainerWithTxnAndFlags)
513
+ XmlContainer *createContainer(
514
+ XmlTransaction &txn, const std::string &name, u_int32_t flags,
515
+ enum XmlContainer::ContainerType type =
516
+ XmlContainer::NodeContainer,
517
+ int mode = 0) {
518
+ return new XmlContainer(self->createContainer(txn, name, flags,
519
+ type, mode));
520
+ }
521
+
522
+ OVERLOAD_NAME(openContainerWithFlags)
523
+ XmlContainer *openContainer(const std::string &name, u_int32_t flags) {
524
+ return new XmlContainer(self->openContainer(name, flags));
525
+ }
526
+ OVERLOAD_NAME(openContainerWithTxnAndFlags)
527
+ XmlContainer *openContainer(XmlTransaction &txn,
528
+ const std::string &name, u_int32_t flags) {
529
+ return new XmlContainer(self->openContainer(txn, name, flags));
530
+ }
531
+ OVERLOAD_NAME(openContainerWithType)
532
+ XmlContainer *openContainer(const std::string &name,
533
+ u_int32_t flags,
534
+ enum XmlContainer::ContainerType type,
535
+ int mode = 0) {
536
+ return new XmlContainer(self->openContainer(name,
537
+ flags, type, mode));
538
+ }
539
+ OVERLOAD_NAME(openContainerWithTxnAndType)
540
+ XmlContainer *openContainer(XmlTransaction &txn,
541
+ const std::string &name,
542
+ u_int32_t flags,
543
+ enum XmlContainer::ContainerType type,
544
+ int mode = 0) {
545
+ return new XmlContainer(self->openContainer(txn, name,
546
+ flags, type, mode));
547
+ }
548
+ }
549
+ %extend {
550
+ void dumpContainer(const std::string &name, const char *filename) {
551
+ std::ofstream out(filename);
552
+ self->dumpContainer(name, &out);
553
+ out.close();
554
+ }
555
+
556
+ void loadContainer(const std::string &name, const char *filename,
557
+ XmlUpdateContext &uc) {
558
+ std::ifstream in(filename);
559
+ unsigned long lineno = 0;
560
+ self->loadContainer(name, &in, &lineno, uc);
561
+ in.close();
562
+ }
563
+ void verifyContainer(const std::string &name, const char *filename,
564
+ u_int32_t flags = 0) {
565
+ std::ofstream out;
566
+ if (flags & DB_SALVAGE)
567
+ out.open(filename);
568
+ self->verifyContainer(name, &out, flags);
569
+ if (flags & DB_SALVAGE)
570
+ out.close();
571
+ }
572
+ XmlDocument *createDocument() {
573
+ return new XmlDocument(self->createDocument());
574
+ }
575
+
576
+ XmlQueryContext *createQueryContext(
577
+ enum XmlQueryContext::ReturnType rt,
578
+ enum XmlQueryContext::EvaluationType et) {
579
+ return new XmlQueryContext(self->createQueryContext(rt, et));
580
+ }
581
+
582
+
583
+ OVERLOAD_NAME(createQueryContextDefaultAll)
584
+ XmlQueryContext *createQueryContext() {
585
+ return new XmlQueryContext(self->createQueryContext(
586
+ XmlQueryContext::LiveValues, XmlQueryContext::Eager));
587
+ }
588
+
589
+ OVERLOAD_NAME(createQueryContextDefaultEvalType)
590
+ XmlQueryContext *createQueryContext(
591
+ enum XmlQueryContext::ReturnType rt) {
592
+ return new XmlQueryContext(self->createQueryContext(rt, XmlQueryContext::Eager));
593
+ }
594
+
595
+ XmlUpdateContext *createUpdateContext() {
596
+ return new XmlUpdateContext(self->createUpdateContext());
597
+ }
598
+
599
+ XmlQueryExpression *prepare(const std::string &query,
600
+ XmlQueryContext &context) {
601
+ return new XmlQueryExpression(self->prepare(query, context));
602
+ }
603
+ OVERLOAD_NAME(prepareWithTxn)
604
+ XmlQueryExpression *prepare(XmlTransaction &txn,
605
+ const std::string &query,
606
+ XmlQueryContext &context){
607
+ return new XmlQueryExpression(self->prepare(
608
+ txn,query, context));
609
+ }
610
+ XmlResults *query(const std::string &query, XmlQueryContext &context,
611
+ u_int32_t flags) {
612
+ return new XmlResults(self->query(query, context, flags));
613
+ }
614
+ OVERLOAD_NAME(queryWithTxn)
615
+ XmlResults *query(XmlTransaction &txn, const std::string &query,
616
+ XmlQueryContext &context, u_int32_t flags) {
617
+ return new XmlResults(self->query(txn, query, context, flags));
618
+ }
619
+
620
+ OVERLOAD_NAME(queryDefaultFlags)
621
+ XmlResults *query(const std::string &query, XmlQueryContext &context) {
622
+ return new XmlResults(self->query(query, context, 0));
623
+ }
624
+ OVERLOAD_NAME(queryWithTxnDefaultFlags)
625
+ XmlResults *query(XmlTransaction &txn, const std::string &query,
626
+ XmlQueryContext &context) {
627
+ return new XmlResults(self->query(txn, query, context, 0));
628
+ }
629
+
630
+
631
+ XmlResults *createResults() {
632
+ return new XmlResults(self->createResults());
633
+ }
634
+
635
+ XmlModify *createModify() {
636
+ return new XmlModify(self->createModify());
637
+ }
638
+
639
+ OVERLOAD_NAME(createTransactionFromDbTxn)
640
+ XmlTransaction *createTransaction(DbTxn *toAdopt) {
641
+ return new XmlTransaction(self->createTransaction(toAdopt));
642
+ }
643
+ #ifndef SWIGJAVA
644
+ XmlTransaction *createTransaction(u_int32_t flags) {
645
+ return new XmlTransaction(self->createTransaction(flags));
646
+ }
647
+
648
+ OVERLOAD_NAME(createTransactionDefaultFlags)
649
+ XmlTransaction *createTransaction() {
650
+ return new XmlTransaction(self->createTransaction((u_int32_t)0));
651
+ }
652
+ #endif
653
+
654
+ XmlIndexLookup *createIndexLookup(
655
+ XmlContainer &cont,
656
+ const std::string &uri, const std::string &name,
657
+ const std::string &index,
658
+ const XmlValue &value = XmlValue(),
659
+ enum XmlIndexLookup::Operation op = XmlIndexLookup::NONE) {
660
+ return new XmlIndexLookup(self->createIndexLookup(cont, uri,name,
661
+ index, value,
662
+ op));
663
+ }
664
+
665
+ #ifndef SWIGTCL8
666
+ // These methods are at global scope (namespace DbXml)
667
+ // in C++ and in Tcl.
668
+ static void setLogLevel(enum LogLevel level, bool enabled) {
669
+ DbXml::setLogLevel(level, enabled);
670
+ }
671
+
672
+ static void setLogCategory(enum LogCategory category, bool enabled) {
673
+ DbXml::setLogCategory(category, enabled);
674
+ }
675
+ static int get_version_major() {
676
+ int major;
677
+ (void)dbxml_version(&major, NULL, NULL);
678
+ return major;
679
+ }
680
+
681
+ static int get_version_minor() {
682
+ int minor;
683
+ (void)dbxml_version(NULL, &minor, NULL);
684
+ return minor;
685
+ }
686
+
687
+ static int get_version_patch() {
688
+ int patch;
689
+ (void)dbxml_version(NULL, NULL, &patch);
690
+ return patch;
691
+ }
692
+
693
+ static const char *get_version_string() {
694
+ return dbxml_version(NULL, NULL, NULL);
695
+ }
696
+ #endif /* !SWIGTCL8 */
697
+ } /* extend */
698
+ };
699
+
700
+ class XmlIndexLookup
701
+ {
702
+ public:
703
+ enum // Operation
704
+ {
705
+ NONE,
706
+ EQ,
707
+ GT,
708
+ GTE,
709
+ LT,
710
+ LTE
711
+ };
712
+ #ifndef SWIGJAVA
713
+ XmlIndexLookup();
714
+ #endif
715
+ XmlIndexLookup(const XmlIndexLookup &o);
716
+ ~XmlIndexLookup();
717
+ bool isNull() const;
718
+ const std::string &getIndex() const;
719
+ void setIndex(const std::string &index);
720
+
721
+ const std::string &getNodeURI() const;
722
+ const std::string &getNodeName() const;
723
+ void setNode(const std::string &uri, const std::string &name);
724
+
725
+ const std::string &getParentURI() const;
726
+ const std::string &getParentName() const;
727
+ void setParent(const std::string &uri, const std::string &name);
728
+
729
+ const XmlValue &getLowBoundValue() const;
730
+ enum XmlIndexLookup::Operation getLowBoundOperation() const;
731
+ void setLowBound(const XmlValue &value,
732
+ enum XmlIndexLookup::Operation op);
733
+
734
+ const XmlValue &getHighBoundValue() const;
735
+ enum XmlIndexLookup::Operation getHighBoundOperation() const;
736
+ void setHighBound(const XmlValue &value,
737
+ enum XmlIndexLookup::Operation op);
738
+
739
+ const XmlContainer &getContainer() const;
740
+ void setContainer(XmlContainer &container);
741
+ %extend {
742
+ XmlResults *execute(XmlQueryContext &context,
743
+ u_int32_t flags = 0) const {
744
+ return new XmlResults(self->execute(context, flags));
745
+ }
746
+ OVERLOAD_NAME(executeWithTxn)
747
+ XmlResults *execute(XmlTransaction &txn, XmlQueryContext &context,
748
+ u_int32_t flags = 0) const {
749
+ return new XmlResults(self->execute(txn, context, flags));
750
+ }
751
+ }
752
+
753
+ };
754
+
755
+ class XmlContainer
756
+ {
757
+ public:
758
+ enum // ContainerType
759
+ {
760
+ WholedocContainer,
761
+ NodeContainer
762
+ };
763
+ #ifndef SWIGJAVA
764
+ XmlContainer();
765
+ #endif
766
+ XmlContainer(const XmlContainer &o);
767
+ ~XmlContainer();
768
+
769
+ void sync();
770
+ #ifndef SWIGJAVA
771
+ void close();
772
+ #endif SWIGJAVA
773
+
774
+ bool addAlias(const std::string &alias);
775
+ bool removeAlias(const std::string &alias);
776
+
777
+ XmlManager &getManager();
778
+
779
+ const std::string &getName() const;
780
+ enum XmlContainer::ContainerType getContainerType() const;
781
+ bool getIndexNodes() const;
782
+ u_int32_t getPageSize() const;
783
+
784
+ void setIndexSpecification(const XmlIndexSpecification &index,
785
+ XmlUpdateContext &uc);
786
+ void addIndex(const std::string &uri, const std::string &name,
787
+ const std::string &index, XmlUpdateContext &uc);
788
+ OVERLOAD_NAME(addIndexWithTypes)
789
+ void addIndex(const std::string &uri, const std::string &name,
790
+ enum XmlIndexSpecification::Type indexType,
791
+ enum XmlValue::Type syntaxType,
792
+ XmlUpdateContext &uc);
793
+ void deleteIndex(const std::string &uri, const std::string &name,
794
+ const std::string &index, XmlUpdateContext &uc);
795
+ void replaceIndex(const std::string &uri, const std::string &name,
796
+ const std::string &index, XmlUpdateContext &uc);
797
+
798
+ void addDefaultIndex(const std::string &index, XmlUpdateContext &uc);
799
+ void deleteDefaultIndex(const std::string &index, XmlUpdateContext &uc);
800
+ void replaceDefaultIndex(const std::string &index, XmlUpdateContext &uc);
801
+
802
+ OVERLOAD_NAME(setIndexSpecificationWithTxn)
803
+ void setIndexSpecification(XmlTransaction &txn,
804
+ const XmlIndexSpecification &index,
805
+ XmlUpdateContext &uc);
806
+ OVERLOAD_NAME(addIndexWithTxn)
807
+ void addIndex(XmlTransaction &txn, const std::string &uri,
808
+ const std::string &name, const std::string &index,
809
+ XmlUpdateContext &uc);
810
+ OVERLOAD_NAME(addIndexWithTypesAndTxn)
811
+ void addIndex(XmlTransaction &txn,
812
+ const std::string &uri, const std::string &name,
813
+ enum XmlIndexSpecification::Type indexType,
814
+ enum XmlValue::Type syntaxType,
815
+ XmlUpdateContext &uc);
816
+ OVERLOAD_NAME(deleteIndexWithTxn)
817
+ void deleteIndex(XmlTransaction &txn, const std::string &uri,
818
+ const std::string &name, const std::string &index,
819
+ XmlUpdateContext &uc);
820
+ OVERLOAD_NAME(replaceIndexWithTxn)
821
+ void replaceIndex(XmlTransaction &txn, const std::string &uri,
822
+ const std::string &name, const std::string &index,
823
+ XmlUpdateContext &uc);
824
+
825
+ OVERLOAD_NAME(addDefaultIndexWithTxn)
826
+ void addDefaultIndex(XmlTransaction &txn, const std::string &index,
827
+ XmlUpdateContext &uc);
828
+ OVERLOAD_NAME(deleteDefaultIndexWithTxn)
829
+ void deleteDefaultIndex(XmlTransaction &txn, const std::string &index,
830
+ XmlUpdateContext &uc);
831
+ OVERLOAD_NAME(replaceDefaultIndexWithTxn)
832
+ void replaceDefaultIndex(XmlTransaction &txn, const std::string &index,
833
+ XmlUpdateContext &uc);
834
+
835
+
836
+
837
+ void putDocument(XmlDocument &document, XmlUpdateContext &context,
838
+ u_int32_t flags = 0);
839
+ OVERLOAD_NAME(putDocumentAsString)
840
+ std::string putDocument(const std::string &name, const std::string &contents,
841
+ XmlUpdateContext &context, u_int32_t flags = 0);
842
+ void deleteDocument(XmlDocument &document,
843
+ XmlUpdateContext &context);
844
+ OVERLOAD_NAME(deleteDocumentByName)
845
+ void deleteDocument(const std::string &name,
846
+ XmlUpdateContext &context);
847
+ void updateDocument(XmlDocument &document,
848
+ XmlUpdateContext &context);
849
+
850
+ OVERLOAD_NAME(putDocumentAsInputSource)
851
+ std::string putDocument(const std::string &name,
852
+ XmlInputStream *input,
853
+ XmlUpdateContext &context,
854
+ u_int32_t flags = 0);
855
+
856
+ OVERLOAD_NAME(putDocumentAsInputSourceWithTxn)
857
+ std::string putDocument(XmlTransaction &txn,
858
+ const std::string &name,
859
+ XmlInputStream *input,
860
+ XmlUpdateContext &context,
861
+ u_int32_t flags = 0);
862
+ OVERLOAD_NAME(putDocumentWithTxn)
863
+ void putDocument(XmlTransaction &txn, XmlDocument &document,
864
+ XmlUpdateContext &context, u_int32_t flags = 0);
865
+ OVERLOAD_NAME(putDocumentAsStringWithTxn)
866
+ std::string putDocument(XmlTransaction &txn,
867
+ const std::string &name,
868
+ const std::string &contents,
869
+ XmlUpdateContext &context,
870
+ u_int32_t flags = 0);
871
+ OVERLOAD_NAME(deleteDocumentWithTxn)
872
+ void deleteDocument(XmlTransaction &txn, XmlDocument &document,
873
+ XmlUpdateContext &context);
874
+ OVERLOAD_NAME(deleteDocumentByNameWithTxn)
875
+ void deleteDocument(XmlTransaction &txn, const std::string &name,
876
+ XmlUpdateContext &context);
877
+ OVERLOAD_NAME(updateDocumentWithTxn)
878
+ void updateDocument(XmlTransaction &txn, XmlDocument &document,
879
+ XmlUpdateContext &context);
880
+
881
+ size_t getNumDocuments();
882
+ OVERLOAD_NAME(getNumDocumentWithTxn)
883
+ size_t getNumDocuments(XmlTransaction &txn);
884
+
885
+ %extend {
886
+ XmlIndexSpecification *getIndexSpecification() const {
887
+ return new XmlIndexSpecification(self->getIndexSpecification());
888
+ }
889
+ OVERLOAD_NAME(getIndexSpecificationWithTxn)
890
+ XmlIndexSpecification *getIndexSpecification(
891
+ XmlTransaction &txn) const {
892
+ return new XmlIndexSpecification(
893
+ self->getIndexSpecification(txn));
894
+ }
895
+ OVERLOAD_NAME(getIndexSpecificationWithFlagsAndTxn)
896
+ XmlIndexSpecification *getIndexSpecification(
897
+ XmlTransaction &txn, u_int32_t flags) const {
898
+ return new XmlIndexSpecification(
899
+ self->getIndexSpecification(txn, flags));
900
+ }
901
+ #ifndef SWIGJAVA
902
+ XmlDocument *getDocument(const std::string &name) {
903
+ return new XmlDocument(self->getDocument(name, 0));
904
+ }
905
+ OVERLOAD_NAME(getDocumentWithTxn)
906
+ XmlDocument *getDocument(XmlTransaction &txn, const std::string &name)
907
+ {
908
+ return new XmlDocument(self->getDocument(txn, name, 0));
909
+ }
910
+ #endif
911
+ OVERLOAD_NAME(getDocumentWithFlags)
912
+ XmlDocument *getDocument(const std::string &name, u_int32_t flags) {
913
+ return new XmlDocument(self->getDocument(name, flags));
914
+ }
915
+ OVERLOAD_NAME(getDocumentWithFlagsAndTxn)
916
+ XmlDocument *getDocument(XmlTransaction &txn, const std::string &name,
917
+ u_int32_t flags) {
918
+ return new XmlDocument(self->getDocument(txn, name, flags));
919
+ }
920
+ XmlResults *getAllDocuments(u_int32_t flags) {
921
+ return new XmlResults(self->getAllDocuments(flags));
922
+ }
923
+ OVERLOAD_NAME(getAllDocumentWithTxn)
924
+ XmlResults *getAllDocuments(XmlTransaction &txn, u_int32_t flags) {
925
+ return new XmlResults(self->getAllDocuments(txn, flags));
926
+ }
927
+
928
+ XmlResults *lookupIndex(XmlQueryContext &context, const std::string &uri,
929
+ const std::string &name, const std::string &index,
930
+ const XmlValue &value = XmlValue(),
931
+ u_int32_t flags = 0) {
932
+ return new XmlResults(
933
+ self->lookupIndex(context, uri, name, index,
934
+ value, flags));
935
+ }
936
+ OVERLOAD_NAME(lookupEdgeIndex)
937
+ XmlResults *lookupIndex(XmlQueryContext &context, const std::string &uri,
938
+ const std::string &name,
939
+ const std::string &parent_uri,
940
+ const std::string &parent_name,
941
+ const std::string &index,
942
+ const XmlValue &value = XmlValue(),
943
+ u_int32_t flags = 0) {
944
+ return new XmlResults(self->lookupIndex(context, uri, name,
945
+ parent_uri, parent_name,
946
+ index, value, flags));
947
+ }
948
+ OVERLOAD_NAME(lookupIndexWithTxn)
949
+ XmlResults *lookupIndex(XmlTransaction &txn, XmlQueryContext &context,
950
+ const std::string &uri, const std::string &name,
951
+ const std::string &index,
952
+ const XmlValue &value = XmlValue(),
953
+ u_int32_t flags = 0) {
954
+ return new XmlResults(self->lookupIndex(txn, context, uri, name,
955
+ index, value, flags));
956
+ }
957
+ OVERLOAD_NAME(lookupEdgeIndexWithTxn)
958
+ XmlResults *lookupIndex(XmlTransaction &txn, XmlQueryContext &context,
959
+ const std::string &uri, const std::string &name,
960
+ const std::string &parent_uri,
961
+ const std::string &parent_name,
962
+ const std::string &index,
963
+ const XmlValue &value = XmlValue(),
964
+ u_int32_t flags = 0) {
965
+ return new XmlResults(self->lookupIndex(txn, context, uri, name,
966
+ parent_uri, parent_name,
967
+ index, value, flags));
968
+ }
969
+ XmlStatistics *lookupStatistics(const std::string &uri,
970
+ const std::string &name,
971
+ const std::string &index,
972
+ const XmlValue &value = XmlValue()) {
973
+ return new XmlStatistics(self->lookupStatistics(uri, name, index,
974
+ value));
975
+ }
976
+ OVERLOAD_NAME(lookupEdgeStatistics)
977
+ XmlStatistics *lookupStatistics(const std::string &uri,
978
+ const std::string &name,
979
+ const std::string &parent_uri,
980
+ const std::string &parent_name,
981
+ const std::string &index,
982
+ const XmlValue &value = XmlValue()) {
983
+ return new XmlStatistics(self->lookupStatistics(uri, name,
984
+ parent_uri,
985
+ parent_name,
986
+ index, value));
987
+ }
988
+
989
+ OVERLOAD_NAME(lookupStatisticsWithTxn)
990
+ XmlStatistics *lookupStatistics(XmlTransaction &txn,
991
+ const std::string &uri,
992
+ const std::string &name,
993
+ const std::string &index,
994
+ const XmlValue &value = XmlValue()) {
995
+ return new XmlStatistics(self->lookupStatistics(txn, uri, name,
996
+ index, value));
997
+ }
998
+
999
+ OVERLOAD_NAME(lookupEdgeStatisticsWithTxn)
1000
+ XmlStatistics *lookupStatistics(XmlTransaction &txn,
1001
+ const std::string &uri,
1002
+ const std::string &name,
1003
+ const std::string &parent_uri,
1004
+ const std::string &parent_name,
1005
+ const std::string &index,
1006
+ const XmlValue &value = XmlValue()) {
1007
+ return new XmlStatistics(self->lookupStatistics(txn, uri, name,
1008
+ parent_uri,
1009
+ parent_name,
1010
+ index, value));
1011
+ }
1012
+ } /* %extend */
1013
+ };
1014
+
1015
+ class XmlDocument
1016
+ {
1017
+ public:
1018
+ #ifndef SWIGJAVA
1019
+ XmlDocument();
1020
+ #endif
1021
+ XmlDocument(const XmlDocument &o);
1022
+ ~XmlDocument();
1023
+
1024
+ void setName(const std::string &name);
1025
+ std::string getName() const;
1026
+
1027
+ #if !defined(SWIGTCL8) && !defined(SWIGPYTHON) && !defined(SWIGPHP4)
1028
+ /*
1029
+ * don't trust conversions with non utf-8 encodings
1030
+ * may be able to enable with some extra code/test
1031
+ * force use of XmlData-based methods
1032
+ */
1033
+ void setContent(const std::string &content);
1034
+ OVERLOAD_NAME(setContentWithXmlData)
1035
+ #endif
1036
+ void setContent(const XmlData &content);
1037
+
1038
+ // input stream is owned by caller
1039
+ XmlInputStream *getContentAsXmlInputStream() const;
1040
+ // input stream is donated to callee
1041
+ void setContentAsXmlInputStream(XmlInputStream *adopted);
1042
+
1043
+ void fetchAllData();
1044
+ void setMetaData(const std::string &uri,
1045
+ const std::string &name, const XmlValue &value);
1046
+ bool getMetaData(const std::string &uri, const std::string &name,
1047
+ XmlValue &value);
1048
+ void removeMetaData(const std::string &uri, const std::string &name);
1049
+ OVERLOAD_NAME(setMetaDataWithXmlData)
1050
+ void setMetaData(const std::string &uri,
1051
+ const std::string &name, const XmlData &value);
1052
+ #ifndef SWIGJAVA
1053
+ OVERLOAD_NAME(getMetaDataAsXmlData)
1054
+ bool getMetaData(const std::string &uri, const std::string &name,
1055
+ XmlData &value);
1056
+ #endif
1057
+ %extend {
1058
+ std::string getContentAsString() const {
1059
+ std::string s;
1060
+ return self->getContent(s);
1061
+ }
1062
+ const XmlData *getContent() const {
1063
+ return new XmlData(self->getContent());
1064
+ }
1065
+ const XmlData *getMetaData(const std::string &uri, const std::string &name) {
1066
+ XmlData data;
1067
+ bool ret = self->getMetaData(uri, name, data);
1068
+ if (ret)
1069
+ return new XmlData(data);
1070
+ return 0;
1071
+ }
1072
+ XmlMetaDataIterator *getMetaDataIterator() const {
1073
+ return new XmlMetaDataIterator(self->getMetaDataIterator());
1074
+ }
1075
+ }
1076
+ };
1077
+
1078
+ class XmlMetaDataIterator
1079
+ {
1080
+ public:
1081
+ XmlMetaDataIterator(const XmlMetaDataIterator &o);
1082
+ ~XmlMetaDataIterator();
1083
+
1084
+ void reset();
1085
+
1086
+ %extend {
1087
+ XmlMetaData *next() {
1088
+ XmlMetaData *idecl = new XmlMetaData;
1089
+ if (self->next(idecl->uri, idecl->name, idecl->value))
1090
+ return idecl;
1091
+ else
1092
+ delete idecl;
1093
+ return NULL;
1094
+ }
1095
+ }
1096
+ #if defined(SWIGPYTHON)
1097
+ %pythoncode %{
1098
+ def __iter__(self): return self
1099
+ %}
1100
+ #endif
1101
+
1102
+ };
1103
+
1104
+ // A SWIG-only class to wrap the results of the
1105
+ // XmlMetaDataIterator
1106
+ class XmlMetaData {
1107
+ public:
1108
+ ~XmlMetaData();
1109
+
1110
+ const std::string &get_uri() const;
1111
+ const std::string &get_name() const;
1112
+ const XmlValue &get_value() const;
1113
+ };
1114
+
1115
+ class XmlQueryContext
1116
+ {
1117
+ public:
1118
+ enum // ReturnType
1119
+ {
1120
+ DeadValues,
1121
+ LiveValues
1122
+ };
1123
+
1124
+ enum // EvaluationType
1125
+ {
1126
+ Eager,
1127
+ Lazy
1128
+ };
1129
+
1130
+ /// Constructor.
1131
+ #ifndef SWIGJAVA
1132
+ XmlQueryContext();
1133
+ #endif
1134
+ XmlQueryContext(const XmlQueryContext &o);
1135
+ ~XmlQueryContext();
1136
+
1137
+ void setNamespace(const std::string &prefix, const std::string &uri);
1138
+ std::string getNamespace(const std::string &prefix);
1139
+ void removeNamespace(const std::string &prefix);
1140
+ void clearNamespaces(void);
1141
+
1142
+ void setVariableValue(const std::string &name, const XmlValue &value);
1143
+ void setVariableValue(const std::string &name, XmlResults &value);
1144
+
1145
+ void setBaseURI(const std::string &baseURI);
1146
+ std::string getBaseURI() const;
1147
+ void setReturnType(enum XmlQueryContext::ReturnType type);
1148
+ enum XmlQueryContext::ReturnType getReturnType() const;
1149
+ void setEvaluationType(
1150
+ enum XmlQueryContext::EvaluationType type);
1151
+ enum XmlQueryContext::EvaluationType getEvaluationType() const;
1152
+ void setDefaultCollection(const std::string &uri);
1153
+ std::string getDefaultCollection() const;
1154
+
1155
+ %extend {
1156
+ XmlValue *getVariableValue(const std::string &name) const {
1157
+ XmlValue *value = new XmlValue;
1158
+ try {
1159
+ if (self->getVariableValue(name, *value))
1160
+ return value;
1161
+ else {
1162
+ delete value;
1163
+ return NULL;
1164
+ }
1165
+ }
1166
+ catch(...) {
1167
+ delete value;
1168
+ throw;
1169
+ }
1170
+ }
1171
+
1172
+ XmlResults *getVariableValues(const std::string &name) const {
1173
+ XmlResults *res = new XmlResults();
1174
+ try {
1175
+ if (self->getVariableValue(name, *res))
1176
+ return res;
1177
+ else {
1178
+ delete res;
1179
+ return NULL;
1180
+ }
1181
+ }
1182
+ catch(...) {
1183
+ delete res;
1184
+ throw;
1185
+ }
1186
+ }
1187
+
1188
+ #ifdef SWIGTCL8
1189
+ const std::string get(const char *name) const {
1190
+ XmlValue value;
1191
+ return self->getVariableValue(name, value) ? value.asString() : "";
1192
+ }
1193
+
1194
+ void set(const std::string &name, const std::string &value) {
1195
+ XmlValue xval(value);
1196
+ self->setVariableValue(name, xval);
1197
+ }
1198
+
1199
+ void setDebugVariable(const std::string &var) {
1200
+ self->setVariableValue("dbxml:debug", var);
1201
+ }
1202
+ #endif /* SWIGTCL8 */
1203
+ } /* %extend */
1204
+ };
1205
+
1206
+ class XmlResults
1207
+ {
1208
+ public:
1209
+ #ifndef SWIGJAVA
1210
+ XmlResults();
1211
+ #endif
1212
+ ~XmlResults();
1213
+ XmlResults(const XmlResults &results);
1214
+
1215
+ bool hasNext();
1216
+ bool hasPrevious();
1217
+ #if defined(SWIGJAVA) || defined(SWIGPYTHON) || defined(SWIGPHP4) || defined(SWIGRUBY)
1218
+ %extend {
1219
+ XmlValue *next() {
1220
+ XmlValue *value = new XmlValue;
1221
+ if (self->next(*value))
1222
+ return value;
1223
+ else {
1224
+ delete value;
1225
+ return NULL;
1226
+ }
1227
+ }
1228
+ XmlValue *previous() {
1229
+ XmlValue *value = new XmlValue;
1230
+ if (self->previous(*value))
1231
+ return value;
1232
+ else {
1233
+ delete value;
1234
+ return NULL;
1235
+ }
1236
+ }
1237
+ XmlValue *peek() {
1238
+ XmlValue *value = new XmlValue;
1239
+ if (self->peek(*value))
1240
+ return value;
1241
+ else {
1242
+ delete value;
1243
+ return NULL;
1244
+ }
1245
+ }
1246
+ } /* %extend */
1247
+ #else
1248
+ bool next(XmlValue &value);
1249
+ bool previous(XmlValue &value);
1250
+ bool peek(XmlValue &value);
1251
+ #endif
1252
+
1253
+ OVERLOAD_NAME(nextDocument)
1254
+ bool next(XmlDocument &document);
1255
+ OVERLOAD_NAME(previousDocument)
1256
+ bool previous(XmlDocument &document);
1257
+ OVERLOAD_NAME(peekDocument)
1258
+ bool peek(XmlDocument &document);
1259
+
1260
+ #if defined(SWIGPYTHON)
1261
+ %pythoncode %{
1262
+ def __iter__(self): return self
1263
+ %}
1264
+ #endif
1265
+ void reset();
1266
+ size_t size() const;
1267
+ void add(const XmlValue &value);
1268
+
1269
+ };
1270
+
1271
+ class XmlUpdateContext
1272
+ {
1273
+ public:
1274
+ #ifndef SWIGJAVA
1275
+ XmlUpdateContext();
1276
+ #endif
1277
+ XmlUpdateContext(const XmlUpdateContext &o);
1278
+ virtual ~XmlUpdateContext();
1279
+
1280
+ void setApplyChangesToContainers(bool applyChanges);
1281
+ bool getApplyChangesToContainers() const;
1282
+ };
1283
+
1284
+
1285
+ class XmlValue
1286
+ {
1287
+ public:
1288
+ //NOTE: these enumerations MUST match those in XmlValue.hpp
1289
+ enum //NodeType
1290
+ {
1291
+ ELEMENT_NODE = 1,
1292
+ ATTRIBUTE_NODE = 2,
1293
+ TEXT_NODE = 3,
1294
+ CDATA_SECTION_NODE = 4,
1295
+ ENTITY_REFERENCE_NODE = 5,
1296
+ ENTITY_NODE = 6,
1297
+ PROCESSING_INSTRUCTION_NODE = 7,
1298
+ COMMENT_NODE = 8,
1299
+ DOCUMENT_NODE = 9,
1300
+ DOCUMENT_TYPE_NODE = 10,
1301
+ DOCUMENT_FRAGMENT_NODE = 11,
1302
+ NOTATION_NODE = 12
1303
+ };
1304
+
1305
+ enum // Type
1306
+ {
1307
+ NONE = 0,
1308
+ NODE = 3,
1309
+
1310
+ /// abstract type (separates type ids for DB XML and
1311
+ /// XML Schema atomic types)
1312
+ ANY_SIMPLE_TYPE = 10,
1313
+
1314
+ ANY_URI = 11,
1315
+ BASE_64_BINARY = 12,
1316
+ BOOLEAN = 13,
1317
+ DATE = 14,
1318
+ DATE_TIME = 15,
1319
+ /// not a built-in primitive type
1320
+ DAY_TIME_DURATION = 16,
1321
+ DECIMAL = 17,
1322
+ DOUBLE = 18,
1323
+ DURATION = 19,
1324
+ FLOAT = 20,
1325
+ G_DAY = 21,
1326
+ G_MONTH = 22,
1327
+ G_MONTH_DAY = 23,
1328
+ G_YEAR = 24,
1329
+ G_YEAR_MONTH = 25,
1330
+ HEX_BINARY = 26,
1331
+ NOTATION = 27,
1332
+ QNAME = 28,
1333
+ STRING = 29,
1334
+ TIME = 30,
1335
+ /// not a built-in primitive type
1336
+ YEAR_MONTH_DURATION= 31,
1337
+
1338
+ /// untyped atomic data
1339
+ UNTYPED_ATOMIC = 32,
1340
+ BINARY = 40
1341
+ };
1342
+ XmlValue();
1343
+ XmlValue(const XmlValue &other);
1344
+ OVERLOAD_NAME(XmlValueFromString)
1345
+ XmlValue(const std::string &v);
1346
+ OVERLOAD_NAME(XmlValueFromDouble)
1347
+ XmlValue(double v);
1348
+ #ifndef SWIGTCL8
1349
+ // Not included in Tcl because there is no way to distinguish between
1350
+ // a boolean and a number.
1351
+ OVERLOAD_NAME(XmlValueFromBool)
1352
+ XmlValue(bool v);
1353
+ #endif
1354
+ OVERLOAD_NAME(XmlValueFromDocument)
1355
+ XmlValue(const XmlDocument &document);
1356
+ OVERLOAD_NAME(XmlValueTypedFromString)
1357
+ XmlValue(enum XmlValue::Type type, const std::string &v);
1358
+ OVERLOAD_NAME(XmlValueTypedFromXmlData)
1359
+ XmlValue(enum XmlValue::Type type, const XmlData &dbt);
1360
+
1361
+ ~XmlValue();
1362
+ enum XmlValue::Type getType() const;
1363
+ bool isNull() const;
1364
+ bool isType(enum XmlValue::Type type) const;
1365
+
1366
+ bool isNumber() const;
1367
+ bool isString() const;
1368
+ bool isBoolean() const;
1369
+ bool isBinary() const;
1370
+ bool isNode() const;
1371
+
1372
+ double asNumber() const;
1373
+ std::string asString() const;
1374
+ OVERLOAD_NAME(asStringEncoded)
1375
+ std::string asString(const std::string &encoding) const;
1376
+ bool asBoolean() const;
1377
+ %extend {
1378
+ XmlData * asBinary() const {
1379
+ XmlData data = self->asBinary();
1380
+ return new XmlData(data);
1381
+ }
1382
+ }
1383
+ #ifndef SWIGTCL8
1384
+ XmlDocument asDocument() const;
1385
+ #else
1386
+ %extend {
1387
+ XmlDocument *asDocument() const {
1388
+ return new XmlDocument(self->asDocument());
1389
+ }
1390
+ }
1391
+ #endif
1392
+ bool equals(const XmlValue &value) const;
1393
+
1394
+ std::string getNodeName() const;
1395
+ std::string getNodeValue() const;
1396
+ std::string getNamespaceURI() const;
1397
+ std::string getPrefix() const;
1398
+ std::string getLocalName() const;
1399
+ short getNodeType() const;
1400
+
1401
+ %extend {
1402
+ XmlValue *getParentNode() const {
1403
+ return new XmlValue(self->getParentNode());
1404
+ }
1405
+ XmlValue *getFirstChild() const {
1406
+ return new XmlValue(self->getFirstChild());
1407
+ }
1408
+ XmlValue *getLastChild() const {
1409
+ return new XmlValue(self->getLastChild());
1410
+ }
1411
+ XmlValue *getPreviousSibling() const {
1412
+ return new XmlValue(self->getPreviousSibling());
1413
+ }
1414
+ XmlValue *getNextSibling() const {
1415
+ return new XmlValue(self->getNextSibling());
1416
+ }
1417
+ XmlResults *getAttributes() const {
1418
+ return new XmlResults(self->getAttributes());
1419
+ }
1420
+ XmlValue *getOwnerElement() const {
1421
+ return new XmlValue(self->getOwnerElement());
1422
+ }
1423
+
1424
+ // allows scripted languages to emulate operator=
1425
+ static void setValue(XmlValue &to, const XmlValue &from) {
1426
+ to = from;
1427
+ }
1428
+ }
1429
+ };
1430
+
1431
+ class XmlIndexSpecification {
1432
+ public:
1433
+ enum //Type
1434
+ {
1435
+ UNIQUE_OFF = 0x00000000,
1436
+ UNIQUE_ON = 0x10000000,
1437
+
1438
+ PATH_NONE = 0x00000000,
1439
+ PATH_NODE = 0x01000000,
1440
+ PATH_EDGE = 0x02000000,
1441
+
1442
+ NODE_NONE = 0x00000000,
1443
+ NODE_ELEMENT = 0x00010000,
1444
+ NODE_ATTRIBUTE = 0x00020000,
1445
+ NODE_METADATA = 0x00030000,
1446
+
1447
+ KEY_NONE = 0x00000000,
1448
+ KEY_PRESENCE = 0x00000100,
1449
+ KEY_EQUALITY = 0x00000200,
1450
+ KEY_SUBSTRING = 0x00000300
1451
+ };
1452
+ #ifndef SWIGJAVA
1453
+ XmlIndexSpecification();
1454
+ #endif
1455
+ virtual ~XmlIndexSpecification();
1456
+
1457
+ void addIndex(const std::string &uri, const std::string &name,
1458
+ enum XmlIndexSpecification::Type type,
1459
+ enum XmlValue::Type syntax);
1460
+ OVERLOAD_NAME(addIndexAsString)
1461
+ void addIndex(const std::string &uri, const std::string &name,
1462
+ const std::string &index);
1463
+ void deleteIndex(const std::string &uri, const std::string &name,
1464
+ enum XmlIndexSpecification::Type type,
1465
+ enum XmlValue::Type syntax);
1466
+ OVERLOAD_NAME(deleteIndexAsString)
1467
+ void deleteIndex(const std::string &uri, const std::string &name,
1468
+ const std::string &index);
1469
+ void replaceIndex(const std::string &uri, const std::string &name,
1470
+ enum XmlIndexSpecification::Type type,
1471
+ enum XmlValue::Type syntax);
1472
+ OVERLOAD_NAME(replaceIndexAsString)
1473
+ void replaceIndex(const std::string &uri, const std::string &name,
1474
+ const std::string &index);
1475
+
1476
+ void addDefaultIndex(enum XmlIndexSpecification::Type type,
1477
+ enum XmlValue::Type syntax);
1478
+ OVERLOAD_NAME(addDefaultIndexAsString)
1479
+ void addDefaultIndex(const std::string &index);
1480
+ void deleteDefaultIndex(enum XmlIndexSpecification::Type type,
1481
+ enum XmlValue::Type syntax);
1482
+ OVERLOAD_NAME(deleteDefaultIndexAsString)
1483
+ void deleteDefaultIndex(const std::string &index);
1484
+ void replaceDefaultIndex(enum XmlIndexSpecification::Type type,
1485
+ enum XmlValue::Type syntax);
1486
+ OVERLOAD_NAME(replaceDefaultIndexAsString)
1487
+ void replaceDefaultIndex(const std::string &index);
1488
+
1489
+ void reset();
1490
+
1491
+ %extend {
1492
+ XmlIndexDeclaration *find(const std::string &uri,
1493
+ const std::string &name) {
1494
+ XmlIndexDeclaration *idecl =
1495
+ new XmlIndexDeclaration(uri, name, "");
1496
+ if (self->find(idecl->uri, idecl->name, idecl->index))
1497
+ return idecl;
1498
+ else {
1499
+ delete idecl;
1500
+ return NULL;
1501
+ }
1502
+ }
1503
+
1504
+ XmlIndexDeclaration *next() {
1505
+ XmlIndexDeclaration *idecl = new XmlIndexDeclaration;
1506
+ if (self->next(idecl->uri, idecl->name, idecl->index))
1507
+ return idecl;
1508
+ else {
1509
+ delete idecl;
1510
+ return NULL;
1511
+ }
1512
+ }
1513
+ }
1514
+ std::string getDefaultIndex() const;
1515
+
1516
+ static enum XmlValue::Type getValueType(const std::string &index);
1517
+
1518
+ #if defined(SWIGPYTHON)
1519
+ %pythoncode %{
1520
+ def __iter__(self): return self
1521
+ %}
1522
+ #endif
1523
+ };
1524
+
1525
+ #ifndef SWIGJAVA
1526
+ class XmlIndexDeclaration {
1527
+ public:
1528
+ ~XmlIndexDeclaration();
1529
+
1530
+ const std::string &get_uri() const;
1531
+ const std::string &get_name() const;
1532
+ const std::string &get_index() const;
1533
+ };
1534
+ #endif
1535
+
1536
+ class XmlQueryExpression
1537
+ {
1538
+ public:
1539
+ #ifndef SWIGJAVA
1540
+ XmlQueryExpression();
1541
+ #endif
1542
+ XmlQueryExpression(const XmlQueryExpression &queryExpression);
1543
+ ~XmlQueryExpression();
1544
+
1545
+ const std::string & getQuery() const;
1546
+ std::string getQueryPlan() const;
1547
+
1548
+ %extend {
1549
+ XmlResults *execute(XmlQueryContext &context,
1550
+ u_int32_t flags = 0) const {
1551
+ return new XmlResults(self->execute(context, flags));
1552
+ }
1553
+ OVERLOAD_NAME(executeWithContextItem)
1554
+ XmlResults *execute(const XmlValue &contextItem,
1555
+ XmlQueryContext &context,
1556
+ u_int32_t flags = 0) const {
1557
+ return new XmlResults(
1558
+ self->execute(contextItem, context, flags));
1559
+ }
1560
+ OVERLOAD_NAME(executeWithTxn)
1561
+ XmlResults *execute(XmlTransaction &txn, XmlQueryContext &context,
1562
+ u_int32_t flags = 0) const {
1563
+ return new XmlResults(self->execute(txn, context, flags));
1564
+ }
1565
+ OVERLOAD_NAME(executeWithContextItemAndTxn)
1566
+ XmlResults *execute(XmlTransaction &txn, const XmlValue &contextItem,
1567
+ XmlQueryContext &context,
1568
+ u_int32_t flags = 0) const {
1569
+ return new XmlResults(self->execute(txn, contextItem,
1570
+ context, flags));
1571
+ }
1572
+ }
1573
+ };
1574
+
1575
+ class XmlInputStream
1576
+ {
1577
+ #if defined(SWIGJAVA)
1578
+ protected:
1579
+ XmlInputStream();
1580
+ #endif
1581
+ public:
1582
+ virtual ~XmlInputStream();
1583
+ // SWIG needs to know about pure virtuals; otherwise,
1584
+ // a reference will be generated.
1585
+ virtual unsigned int curPos() const = 0;
1586
+ virtual unsigned int readBytes(char *toFill,
1587
+ const unsigned int maxToRead) = 0;
1588
+ %extend {
1589
+ // allow wrapped languages to free C++ memory in the event
1590
+ // object is not donated to putDocument().
1591
+ void freeMemory() {
1592
+ delete self;
1593
+ }
1594
+ }
1595
+ };
1596
+
1597
+ #if defined(DBXML_USE_RESOLVER)
1598
+
1599
+ #if defined(SWIGJAVA)
1600
+ %apply const std::string & {std::string &};
1601
+ #endif
1602
+
1603
+ class XmlResolver
1604
+ {
1605
+ protected:
1606
+ XmlResolver();
1607
+ public:
1608
+ virtual ~XmlResolver();
1609
+ virtual bool resolveDocument(XmlTransaction *txn,XmlManager &mgr,
1610
+ const std::string &uri, XmlValue &res) const;
1611
+ virtual bool resolveCollection(XmlTransaction *txn, XmlManager &mgr,
1612
+ const std::string &uri, XmlResults &res) const;
1613
+ virtual XmlInputStream *resolveSchema(XmlTransaction *txn, XmlManager &mgr,
1614
+ const std::string &schemaLocation,
1615
+ const std::string &nameSpace) const;
1616
+ virtual XmlInputStream *resolveEntity(XmlTransaction *txn, XmlManager &mgr,
1617
+ const std::string &systemId,
1618
+ const std::string &publicId) const;
1619
+ };
1620
+ #endif
1621
+
1622
+ class XmlModify
1623
+ {
1624
+ public:
1625
+ enum // XmlObject
1626
+ {
1627
+ Element,
1628
+ Attribute,
1629
+ Text,
1630
+ ProcessingInstruction,
1631
+ Comment
1632
+ };
1633
+ #ifndef SWIGJAVA
1634
+ XmlModify();
1635
+ #endif
1636
+ XmlModify(const XmlModify &o);
1637
+ ~XmlModify();
1638
+
1639
+ void addInsertBeforeStep(const XmlQueryExpression &selectionExpr,
1640
+ enum XmlModify::XmlObject type,
1641
+ const std::string &name,
1642
+ const std::string &content);
1643
+ void addInsertAfterStep(const XmlQueryExpression &selectionExpr,
1644
+ enum XmlModify::XmlObject type,
1645
+ const std::string &name,
1646
+ const std::string &content);
1647
+ void addAppendStep(const XmlQueryExpression &selectionExpr,
1648
+ enum XmlModify::XmlObject type,
1649
+ const std::string &name,
1650
+ const std::string &content, int location = -1);
1651
+ void addUpdateStep(const XmlQueryExpression &selectionExpr,
1652
+ const std::string &content);
1653
+ void addRemoveStep(const XmlQueryExpression &selectionExpr);
1654
+ void addRenameStep(const XmlQueryExpression &selectionExpr,
1655
+ const std::string &newName);
1656
+
1657
+ void setNewEncoding(const std::string &newEncoding);
1658
+
1659
+ unsigned int execute(XmlValue &toModify, XmlQueryContext &context,
1660
+ XmlUpdateContext &uc) const;
1661
+ OVERLOAD_NAME(executeOnResults)
1662
+ unsigned int execute(XmlResults &toModify, XmlQueryContext &context,
1663
+ XmlUpdateContext &uc) const;
1664
+ OVERLOAD_NAME(executeWithTxn)
1665
+ unsigned int execute(XmlTransaction &txn, XmlValue &toModify,
1666
+ XmlQueryContext &context,
1667
+ XmlUpdateContext &uc) const;
1668
+ OVERLOAD_NAME(executeOnResultsWithTxn)
1669
+ unsigned int execute(XmlTransaction &txn, XmlResults &toModify,
1670
+ XmlQueryContext &context,
1671
+ XmlUpdateContext &uc) const;
1672
+ };
1673
+
1674
+ class XmlTransaction
1675
+ {
1676
+ public:
1677
+ ~XmlTransaction();
1678
+ #ifndef SWIGJAVA
1679
+ XmlTransaction();
1680
+ XmlTransaction(const XmlTransaction &);
1681
+
1682
+ void abort();
1683
+ void commit(u_int32_t flags);
1684
+
1685
+ %extend {
1686
+ XmlTransaction *createChild(u_int32_t flags = 0) {
1687
+ return new XmlTransaction(self->createChild(flags));
1688
+ }
1689
+ OVERLOAD_NAME(commitDefaultFlags)
1690
+ void commit() {
1691
+ self->commit(0);
1692
+ }
1693
+ }
1694
+
1695
+ DbTxn *getDbTxn();
1696
+ #endif // !SWIGJAVA
1697
+ };
1698
+
1699
+ class XmlStatistics
1700
+ {
1701
+ public:
1702
+ XmlStatistics(const XmlStatistics&);
1703
+ ~XmlStatistics();
1704
+
1705
+ double getNumberOfIndexedKeys() const;
1706
+ double getNumberOfUniqueKeys() const;
1707
+ double getSumKeyValueSize() const;
1708
+ };