rdbxml 2.3.10 → 2.4.13.2

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006 Steve Sloan
1
+ Copyright (c) 2006-2009 Steve Sloan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc ADDED
@@ -0,0 +1,33 @@
1
+ = RDBXML -- XML Databases for Ruby
2
+
3
+ This package provides wrapper functions to the C++ API for Oracle Berkeley
4
+ DB XML (Dbxml) and as well as pure-Ruby convenience functions (RDBXML).
5
+
6
+ == Requirements
7
+ * Rake[http://rake.rubyforge.org] >= 7.0
8
+ * Oracle {Berkeley DB XML}[http://www.oracle.com/technology/products/berkeley-db/xml/index.html] = 2.4.13
9
+
10
+ == Example Usage
11
+ require 'rubygems'
12
+ require 'rdbxml'
13
+
14
+ # create database directory
15
+ env_dir = './db-env'
16
+ Dir.mkdir env_dir unless File.exists? env_dir
17
+
18
+ # create environment, database, and container
19
+ env = RDBXML::env env_dir
20
+ db = RDBXML::XmlManager.new env, 0
21
+ docs = db['documents']
22
+
23
+ # Create document
24
+ docs['Document Name'] = '<doc>Document XML</doc>'
25
+
26
+ # Read document
27
+ puts docs['Document Name'].to_s
28
+
29
+ Author:: Steve Sloan (mailto:steve@finagle.org)
30
+ Website:: http://rdbxml.rubyforge.org
31
+ Rubyforge:: http://rubyforge.org/projects/rdbxml
32
+ Copyright:: Copyright (c) 2006-2009 Steve Sloan
33
+ License:: MIT
data/Rakefile CHANGED
@@ -5,95 +5,51 @@ require 'rake/testtask'
5
5
  require 'rake/rdoctask'
6
6
  require 'rake/gempackagetask'
7
7
  require 'rake/contrib/rubyforgepublisher'
8
+ require 'fileutils'
8
9
 
9
- GEM_VERSION = '2.3.10'
10
-
11
- dbxml_dist = ENV['DBXML_DIST']
12
- if dbxml_dist
13
- puts "*** Using DBXML distribution in #{dbxml_dist}"
14
- Rake::ExtensionTask.env.update(
15
- :swig_includedirs => [File.join( dbxml_dist, 'dbxml/dist/swig' ), '.'],
16
- :includedirs => File.join( dbxml_dist, 'install/include' ),
17
- :libdirs => File.join( dbxml_dist, 'install/lib' )
18
- )
19
- else
20
- Rake::ExtensionTask.env.update(
21
- :includedirs => '/usr/local/include',
22
- :libdirs => '/usr/local/lib'
23
- )
24
- end
10
+ GEM_VERSION = '2.4.13.2'
11
+ ifacedir = File.join( File.dirname(__FILE__), 'ext' )
12
+ Rake::ExtensionTask.env[:swig_includedirs] << ifacedir
25
13
 
26
14
  desc "Build the interface extension"
27
- task :extensions => [:db, :dbxml]
28
-
29
- desc "Build the BDB interface extension"
30
- Rake::SWIGExtensionTask.new :db do |t|
31
- t.dir = 'ext'
32
- t.link_libs += ['db', 'db_cxx']
33
- end
15
+ task :extensions => :dbxml
34
16
 
35
17
  desc "Build the BDBXML interface extension"
36
18
  Rake::SWIGExtensionTask.new :dbxml do |t|
37
19
  t.dir = 'ext'
38
- t.deps[:dbxml] << :dbxml_ruby
39
- t.link_libs += ['db', 'db_cxx', 'dbxml', 'xqilla', 'xerces-c']
20
+ t.deps[:dbxml] += [ :'db-minimal', :dbxml_ruby ]
21
+ t.link_libs += ['db', 'db_cxx', 'dbxml-2.4', 'xqilla', 'xerces-c']
40
22
  end
41
- CLEAN.exclude 'ext/dbxml_wrap.cc' # Hack for swig bug
42
23
 
43
24
  task :test => :extensions
44
25
  Rake::TestTask.new do |t|
45
- t.libs << "ext"
26
+ t.libs << 'ext'
46
27
  t.test_files = FileList['test/test_*.rb']
47
28
  t.verbose = true
48
29
  CLEAN.include 'test/test_*.db'
49
30
  end
50
31
 
51
- task :install => [:test, :clean] do end
52
-
53
- docs = Rake::RDocTask.new :rdoc do |rdoc|
54
- rdoc.rdoc_dir = 'html'
55
- rdoc.title = "RDBXML -- XML Databases for Ruby"
56
- rdoc.options += ['--line-numbers', '--inline-source', '--main', 'README', '--exclude', 'ext/*.c*']
57
- rdoc.rdoc_files.include 'README', 'MIT-LICENSE'
58
- rdoc.rdoc_files.include 'lib/**/*.rb'
59
- rdoc.rdoc_files.include 'docs/**/*.rb', 'docs/**/*.rdoc'
60
- rdoc.rdoc_files.include 'rake/**/*task.rb'
61
- end
62
-
63
- GEM_FILES = docs.rdoc_files + FileList[
64
- 'Rakefile',
65
- 'ext/**/*.i',
66
- 'ext/dbxml_wrap.cc', # Hack for SWIG bug
67
- 'rake/**/*.rb',
68
- 'test/**/test_*.rb',
69
- ]
70
-
71
- spec = Gem::Specification.new do |s|
72
- s.platform = Gem::Platform::RUBY
73
- s.name = 'rdbxml'
74
- s.version = GEM_VERSION
75
- s.date = Date.today.to_s
76
- s.authors = ["Steve Sloan"]
77
- s.summary = 'Provides wrappers for the BDB XML C++ APIs, plus pure Ruby extensions'
78
- # s.description =
79
- s.files = GEM_FILES.to_a.delete_if {|f| f.include?('.svn')}
80
- s.autorequire = 'rdbxml'
81
- s.test_files = Dir["test/test_*.rb"]
82
- s.add_dependency 'rake', '> 0.7.0'
83
-
84
- s.extensions << './extconf.rb'
85
- s.require_paths << 'ext'
86
-
87
- s.has_rdoc = true
88
- s.extra_rdoc_files = docs.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
89
- s.rdoc_options = docs.options
90
- end
91
- Rake::GemPackageTask.new spec do |pkg|
92
- pkg.need_zip = true
93
- pkg.need_tar = true
32
+ if File.exist? 'rdbxml.gemspec'
33
+ spec = Gem::Specification.load 'rdbxml.gemspec'
34
+ Rake::GemPackageTask.new spec do |pkg|
35
+ pkg.need_zip = true
36
+ pkg.need_tar = true
37
+ end
94
38
  end
95
39
 
96
- task :default => :extensions
97
- task :all => :extensions
40
+ # docs = Rake::RDocTask.new :rdoc do |rdoc|
41
+ # rdoc.rdoc_dir = 'html'
42
+ # rdoc.title = "RDBXML -- XML Database for Ruby"
43
+ # rdoc.options += ['--line-numbers', '--inline-source', '--main', 'README.rdoc', '--exclude', 'ext/*.c*']
44
+ # rdoc.rdoc_files.include 'README.rdoc', 'MIT-LICENSE'
45
+ # rdoc.rdoc_files.include 'lib/**/*.rb'
46
+ # rdoc.rdoc_files.include 'docs/**/*.rb', 'docs/**/*.rdoc'
47
+ # rdoc.rdoc_files.include 'rake/**/*task.rb'
48
+ # end
49
+ # if File.exist? 'publish.rake'
50
+ # load 'publish.rake'
51
+ # task :cruise => :publish
52
+ # end
53
+
54
+ task :default => [ :extensions, :test, :clean ]
98
55
 
99
- load 'publish.rf' if File.exist? 'publish.rf'
data/docs/dbxml.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  # = Dbxml -- Berkly DB XML API Interface
2
2
  #
3
- # This module provides a wrapper around the BDB XML C++ API: http://www.sleepycat.com/xmldocs/api_cxx/api_xml.html
3
+ # This module provides a wrapper around the {Berkeley DB XML C++ API}[http://www.oracle.com/technology/documentation/berkeley-db/xml/api_cxx/frame.html]
4
4
 
5
5
  module Dbxml
6
6
  end
7
+
8
+ # Wraps and extends the DbEnv[http://www.oracle.com/technology/documentation/berkeley-db/xml/api_cxx/env_class.html] class.
9
+ class Dbxml::DbEnv
10
+ end
data/ext/db-minimal.i ADDED
@@ -0,0 +1,78 @@
1
+ class DbTxn
2
+ {
3
+ public:
4
+ int abort();
5
+ int commit(u_int32_t flags);
6
+ int discard(u_int32_t flags);
7
+ u_int32_t id();
8
+ int set_timeout(db_timeout_t timeout, u_int32_t flags);
9
+
10
+ private:
11
+ // Note: use DbEnv::txn_begin() to get pointers to a DbTxn,
12
+ // and call DbTxn::abort() or DbTxn::commit rather than
13
+ // delete to release them.
14
+ //
15
+ DbTxn();
16
+ virtual ~DbTxn();
17
+ };
18
+
19
+ class DbEnv
20
+ {
21
+ public:
22
+ // After using this constructor, you can set any needed
23
+ // parameters for the environment using the set_* methods.
24
+ // Then call open() to finish initializing the environment
25
+ // and attaching it to underlying files.
26
+ //
27
+ DbEnv(u_int32_t flags);
28
+ virtual ~DbEnv();
29
+
30
+ // These methods match those in the C interface.
31
+ //
32
+ virtual int close(u_int32_t);
33
+ virtual int dbremove(DbTxn *txn, const char *name, const char *subdb,
34
+ u_int32_t flags);
35
+ virtual int dbrename(DbTxn *txn, const char *name, const char *subdb,
36
+ const char *newname, u_int32_t flags);
37
+ virtual int open(const char *, u_int32_t, int);
38
+ virtual int remove(const char *, u_int32_t);
39
+ virtual int set_cachesize(u_int32_t, u_int32_t, int);
40
+ virtual int set_data_dir(const char *);
41
+ virtual int set_encrypt(const char *, u_int32_t);
42
+ virtual void set_errpfx(const char *);
43
+ virtual int set_flags(u_int32_t, int);
44
+ virtual int set_lg_bsize(u_int32_t);
45
+ virtual int set_lg_dir(const char *);
46
+ virtual int set_lg_max(u_int32_t);
47
+ virtual int set_lg_regionmax(u_int32_t);
48
+ virtual int set_lk_detect(u_int32_t);
49
+ virtual int set_lk_max_lockers(u_int32_t);
50
+ virtual int set_lk_max_locks(u_int32_t);
51
+ virtual int set_lk_max_objects(u_int32_t);
52
+ virtual int set_mp_mmapsize(size_t);
53
+ virtual int set_shm_key(long);
54
+ virtual int set_timeout(db_timeout_t, u_int32_t);
55
+ virtual int set_tmp_dir(const char *);
56
+ virtual int mutex_set_tas_spins(u_int32_t);
57
+ virtual int set_tx_max(u_int32_t);
58
+ virtual int set_verbose(u_int32_t which, int);
59
+
60
+ // Version information. A static method so it can be obtained anytime.
61
+ //
62
+ static char *version(int *major, int *minor, int *patch);
63
+
64
+ // Convert DB errors to strings
65
+ static char *strerror(int);
66
+
67
+ // Transaction functions
68
+ //
69
+ %extend {
70
+ DbTxn *txn_begin(DbTxn *pid, u_int32_t flags) {
71
+ DbTxn *txn;
72
+ self->txn_begin(pid, &txn, flags);
73
+ return txn;
74
+ }
75
+ }
76
+ virtual int txn_checkpoint(u_int32_t kbyte, u_int32_t min,
77
+ u_int32_t flags);
78
+ };
data/ext/dbxml.i CHANGED
@@ -7,7 +7,48 @@
7
7
  #include <errno.h>
8
8
  #include <fstream>
9
9
 
10
+ /* compat w/pre-4.4 */
11
+ #ifndef DB_READ_COMMITTED
12
+ #define DB_READ_COMMITTED DB_DEGREE_2
13
+ #define DB_READ_UNCOMMITTED DB_DIRTY_READ
14
+ #endif
15
+
16
+ /* If these are not defined, there are no equivalents; just make things compile */
17
+ #ifndef DB_TXN_SNAPSHOT
18
+ #define DB_TXN_SNAPSHOT -1
19
+ #define DB_MULTIVERSION -1
20
+ #endif
21
+ %}
22
+
23
+ #if !defined(SWIGJAVA)
24
+ %{
10
25
  using namespace DbXml;
26
+ %}
27
+ #endif
28
+
29
+ #if defined(SWIGJAVA)
30
+ %include "std_string.i"
31
+ %include "dbxml_java.i"
32
+ #elif defined(SWIGPYTHON)
33
+ %include "std_string.i"
34
+ %include "dbxml_python.i"
35
+ #elif defined(SWIGTCL8)
36
+ %include "std_string.i"
37
+ %include "dbxml_tcl.i"
38
+ #elif defined(SWIGCSHARP)
39
+ %include "dbxml_csharp.i"
40
+ #elif defined(SWIGPHP4)
41
+ %include "std_string.i"
42
+ %include "dbxml_php4.i"
43
+ #elif defined(SWIGRUBY)
44
+ %include "std_string.i"
45
+ %include "std_except.i"
46
+ %include "dbxml_ruby.i"
47
+ #else
48
+ #error "Unknown SWIG target language"
49
+ #endif
50
+
51
+ %{
11
52
 
12
53
  class XmlIndexDeclaration {
13
54
  public:
@@ -36,33 +77,13 @@ public:
36
77
 
37
78
  %}
38
79
 
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
80
  // DBXML_USEOVERLOADS -- defined when a language supports overloaded
60
81
  // functions. If defined, the "OVERLOAD_NAME" macro is a no-op
61
82
  #if defined(SWIGJAVA) || defined(SWIGPYTHON) || defined(SWIGCSHARP) || defined(SWIGTCL8) || defined(SWIGRUBY)
62
83
  #define DBXML_USEOVERLOADS
63
84
  #endif
64
85
 
65
- #if defined(SWIGJAVA) || defined(SWIGPYTHON)
86
+ #if defined(SWIGJAVA) || defined(SWIGPYTHON) || defined(SWIGRUBY)
66
87
  #define DBXML_USE_RESOLVER
67
88
  #endif
68
89
 
@@ -70,19 +91,25 @@ public:
70
91
  typedef int int32_t;
71
92
 
72
93
  class XmlManager;
94
+ #ifndef SWIGJAVA
73
95
  class XmlDocument;
96
+ #endif
74
97
  class XmlContainer;
75
98
  class XmlIndexSpecification;
76
99
  class XmlIndexLookup;
77
100
  class XmlInputStream;
78
- class XmlQueryContext;
79
101
  class XmlResults;
80
102
  class XmlUpdateContext;
103
+ #ifndef SWIGJAVA
104
+ class XmlQueryContext;
81
105
  class XmlValue;
106
+ #endif
82
107
  class XmlQueryExpression;
83
108
  class XmlModify;
84
109
  class XmlTransaction;
110
+ #ifndef SWIGJAVA
85
111
  class XmlMetaDataIterator;
112
+ #endif
86
113
  class XmlStatistics;
87
114
  class XmlEventReader;
88
115
  class XmlEventWriter;
@@ -103,11 +130,23 @@ class XmlResolver;
103
130
  #ifndef SWIGJAVA
104
131
  // For Java, this is done differently
105
132
  enum {
106
- DB_CREATE, DB_READ_UNCOMMITTED, DB_DIRTY_READ,
107
- DB_EXCL, DB_NOMMAP, DB_RDONLY, DB_THREAD,
108
- DB_READ_COMMITTED, DB_DEGREE_2,
109
- DB_INIT_LOCK, DB_INIT_LOG, DB_INIT_MPOOL, DB_INIT_TXN,
110
- DB_SALVAGE, DB_AGGRESSIVE
133
+ DB_CREATE,
134
+ DB_READ_UNCOMMITTED,
135
+ DB_DIRTY_READ,
136
+ DB_EXCL,
137
+ DB_NOMMAP,
138
+ DB_RDONLY,
139
+ DB_THREAD,
140
+ DB_READ_COMMITTED,
141
+ DB_DEGREE_2,
142
+ DB_INIT_LOCK,
143
+ DB_INIT_LOG,
144
+ DB_INIT_MPOOL,
145
+ DB_INIT_TXN,
146
+ DB_SALVAGE,
147
+ DB_AGGRESSIVE,
148
+ DB_TXN_SNAPSHOT,
149
+ DB_MULTIVERSION
111
150
  };
112
151
 
113
152
  #endif
@@ -128,19 +167,23 @@ enum {
128
167
  //
129
168
  // Global flags
130
169
  enum {
131
- DBXML_ADOPT_DBENV = 0x00000001,
170
+ DBXML_ADOPT_DBENV = 0x00000001,
132
171
  DBXML_ALLOW_EXTERNAL_ACCESS = 0x00000002,
133
- DBXML_ALLOW_AUTO_OPEN = 0x00000004,
172
+ DBXML_ALLOW_AUTO_OPEN = 0x00000004,
134
173
  DBXML_ALLOW_VALIDATION = 0x00100000,
135
174
  DBXML_TRANSACTIONAL = 0x00200000,
136
175
  DBXML_CHKSUM = 0x00400000,
137
176
  DBXML_ENCRYPT = 0x00800000,
138
177
  DBXML_INDEX_NODES = 0x01000000,
139
- DBXML_NO_INDEX_NODES = 0x02000000,
178
+ DBXML_NO_INDEX_NODES = 0x00010000,
179
+ DBXML_STATISTICS = 0x02000000,
180
+ DBXML_NO_STATISTICS = 0x04000000,
140
181
  DBXML_REVERSE_ORDER = 0x00100000,
141
182
  DBXML_INDEX_VALUES = 0x00200000,
142
183
  DBXML_CACHE_DOCUMENTS = 0x00400000,
143
184
  DBXML_LAZY_DOCS = 0x00800000,
185
+ DBXML_DOCUMENT_PROJECTION = 0x80000000,
186
+ DBXML_NO_AUTO_COMMIT = 0x00010000,
144
187
  DBXML_WELL_FORMED_ONLY = 0x01000000,
145
188
  DBXML_GEN_NAME = 0x02000000
146
189
  };
@@ -254,7 +297,11 @@ void setLogCategory(enum LogCategory category, bool enabled) {
254
297
  %newobject XmlContainer::getIndexSpecification(XmlTransaction&) const;
255
298
  %newobject XmlContainer::getIndexSpecification(XmlTransaction&,
256
299
  u_int32_t flags) const;
300
+ #ifdef SWIGJAVA
301
+ %newobject XmlManager::createIndexLookupInternal(
302
+ #else
257
303
  %newobject XmlManager::createIndexLookup(
304
+ #endif
258
305
  XmlContainer &cont,
259
306
  const std::string &uri,
260
307
  const std::string &name,
@@ -270,15 +317,17 @@ void setLogCategory(enum LogCategory category, bool enabled) {
270
317
  #ifndef SWIGJAVA
271
318
  %newobject XmlContainer::getDocument(const std::string&);
272
319
  %newobject XmlContainer::getDocument(XmlTransaction&, const std::string&);
273
- %newobject XmlContainer::getNode(const std::string&);
274
- %newobject XmlContainer::getNode(XmlTransaction&, const std::string&);
275
320
  #endif
276
321
  %newobject XmlContainer::getDocument(const std::string&, u_int32_t);
277
322
  %newobject XmlContainer::getDocument(XmlTransaction&, const std::string&,
278
323
  u_int32_t);
324
+ #ifndef SWIGJAVA
279
325
  %newobject XmlContainer::getNode(const std::string&, u_int32_t);
326
+ %newobject XmlContainer::getNode(XmlTransaction&, const std::string&);
327
+ %newobject XmlContainer::getNode(const std::string&);
280
328
  %newobject XmlContainer::getNode(XmlTransaction&, const std::string&,
281
329
  u_int32_t);
330
+ #endif
282
331
  %newobject XmlContainer::getAllDocuments(u_int32_t);
283
332
  %newobject XmlContainer::getAllDocuments(XmlTransaction&, u_int32_t);
284
333
  %newobject XmlContainer::lookupIndex(XmlQueryContext &, const std::string &,
@@ -349,11 +398,11 @@ void setLogCategory(enum LogCategory category, bool enabled) {
349
398
  const std::string &, const std::string &,
350
399
  const std::string &, const std::string &,
351
400
  const std::string &, const XmlValue &);
352
-
401
+ #ifndef SWIGJAVA
353
402
  %newobject XmlDocument::getContent() const;
354
403
  %newobject XmlDocument::getMetaDataIterator() const;
355
404
  %newobject XmlDocument::getContentAsXmlInputStream() const;
356
-
405
+ #endif
357
406
  %newobject XmlQueryContext::getVariableValue(const std::string&) const;
358
407
 
359
408
  %newobject XmlQueryExpression::execute(XmlQueryContext &, u_int32_t) const;
@@ -370,7 +419,7 @@ void setLogCategory(enum LogCategory category, bool enabled) {
370
419
  XmlQueryContext &) const;
371
420
 
372
421
 
373
- #if defined(SWIGJAVA) || defined(SWIGPYTHON) || defined(SWIGPHP4) || defined(SWIGRUBY)
422
+ #if defined(SWIGPYTHON) || defined(SWIGPHP4) || defined(SWIGRUBY)
374
423
  %newobject XmlResults::next();
375
424
  %newobject XmlResults::previous();
376
425
  %newobject XmlResults::peek();
@@ -380,6 +429,7 @@ void setLogCategory(enum LogCategory category, bool enabled) {
380
429
  %newobject XmlValue::asDocument(const XmlQueryContext*) const;
381
430
  #endif
382
431
 
432
+ #ifndef SWIGJAVA
383
433
  %newobject XmlValue::getParentNode() const;
384
434
  %newobject XmlValue::getFirstChild() const;
385
435
  %newobject XmlValue::getLastChild() const;
@@ -389,12 +439,12 @@ void setLogCategory(enum LogCategory category, bool enabled) {
389
439
  %newobject XmlValue::getOwnerElement() const;
390
440
  %newobject XmlValue::asBinary() const;
391
441
  %newobject XmlValue::loadNodeHandle() const;
392
-
442
+ #endif
393
443
  %newobject XmlIndexSpecification::find(const std::string&, const std::string&);
394
444
  %newobject XmlIndexSpecification::next();
395
-
445
+ #ifndef SWIGJAVA
396
446
  %newobject XmlMetaDataIterator::next();
397
-
447
+ #endif
398
448
  #if defined(DBXML_USE_RESOLVER)
399
449
  %newobject XmlResolver::resolveSchema(XmlTransaction*, XmlManager&, const std::string&, const std::string&) const;
400
450
  %newobject XmlResolver::resolveEntity(XmlTransaction*, XmlManager&, const std::string&, const std::string&) const;
@@ -431,9 +481,10 @@ OVERLOAD_NAME(XmlManagerFromEnv)
431
481
  u_int32_t getDefaultSequenceIncrement();
432
482
  void setDefaultContainerType(enum XmlContainer::ContainerType type);
433
483
  enum XmlContainer::ContainerType getDefaultContainerType();
434
- #ifndef SWIGJAVA
435
- DbEnv *getDbEnv();
436
- #endif
484
+ // getDbEnv() does not readily translate to scripting interfaces. If users
485
+ // need it, they should create and save it themselves.
486
+ // DbEnv *getDbEnv();
487
+
437
488
  const std::string &getHome() const;
438
489
  #if defined(DBXML_USE_RESOLVER)
439
490
  void registerResolver(const XmlResolver &resolver);
@@ -452,6 +503,14 @@ OVERLOAD_NAME(renameContainerWithTxn)
452
503
  void renameContainer(XmlTransaction &txn, const std::string &oldName,
453
504
  const std::string &newName);
454
505
  void upgradeContainer(const std::string &name, XmlUpdateContext &uc);
506
+ #ifdef SWIGJAVA
507
+ void compactContainer(const std::string &name, XmlUpdateContext &uc);
508
+ void compactContainer(XmlTransaction &txn, const std::string &name,
509
+ XmlUpdateContext &uc);
510
+ void truncateContainer(const std::string &name, XmlUpdateContext &uc);
511
+ void truncateContainer(XmlTransaction &txn, const std::string &name,
512
+ XmlUpdateContext &uc);
513
+ #else
455
514
  void compactContainer(const std::string &name, XmlUpdateContext &uc,
456
515
  u_int32_t flags = 0);
457
516
  void compactContainer(XmlTransaction &txn, const std::string &name,
@@ -460,6 +519,7 @@ OVERLOAD_NAME(renameContainerWithTxn)
460
519
  u_int32_t flags = 0);
461
520
  void truncateContainer(XmlTransaction &txn, const std::string &name,
462
521
  XmlUpdateContext &uc, u_int32_t flags = 0);
522
+ #endif
463
523
  void reindexContainer(const std::string &name, XmlUpdateContext &uc,
464
524
  u_int32_t flags = 0);
465
525
  void reindexContainer(XmlTransaction &txn, const std::string &name,
@@ -601,17 +661,15 @@ OVERLOAD_NAME(openContainerWithTxnAndType)
601
661
  if (flags & DB_SALVAGE)
602
662
  out.close();
603
663
  }
664
+ #ifndef SWIGJAVA
604
665
  XmlDocument *createDocument() {
605
666
  return new XmlDocument(self->createDocument());
606
667
  }
607
-
608
668
  XmlQueryContext *createQueryContext(
609
669
  enum XmlQueryContext::ReturnType rt,
610
670
  enum XmlQueryContext::EvaluationType et) {
611
671
  return new XmlQueryContext(self->createQueryContext(rt, et));
612
672
  }
613
-
614
-
615
673
  OVERLOAD_NAME(createQueryContextDefaultAll)
616
674
  XmlQueryContext *createQueryContext() {
617
675
  return new XmlQueryContext(self->createQueryContext(
@@ -623,11 +681,10 @@ OVERLOAD_NAME(createQueryContextDefaultEvalType)
623
681
  enum XmlQueryContext::ReturnType rt) {
624
682
  return new XmlQueryContext(self->createQueryContext(rt, XmlQueryContext::Eager));
625
683
  }
626
-
627
684
  XmlUpdateContext *createUpdateContext() {
628
685
  return new XmlUpdateContext(self->createUpdateContext());
629
686
  }
630
-
687
+ #endif
631
688
  XmlQueryExpression *prepare(const std::string &query,
632
689
  XmlQueryContext &context) {
633
690
  return new XmlQueryExpression(self->prepare(query, context));
@@ -639,8 +696,8 @@ OVERLOAD_NAME(prepareWithTxn)
639
696
  return new XmlQueryExpression(self->prepare(
640
697
  txn,query, context));
641
698
  }
642
- XmlResults *query(const std::string &query, XmlQueryContext &context,
643
- u_int32_t flags) {
699
+ XmlResults *query(const std::string &query, XmlQueryContext &context,
700
+ u_int32_t flags) {
644
701
  return new XmlResults(self->query(query, context, flags));
645
702
  }
646
703
  OVERLOAD_NAME(queryWithTxn)
@@ -682,8 +739,11 @@ OVERLOAD_NAME(createTransactionDefaultFlags)
682
739
  return new XmlTransaction(self->createTransaction((u_int32_t)0));
683
740
  }
684
741
  #endif
685
-
742
+ #ifdef SWIGJAVA
743
+ XmlIndexLookup *createIndexLookupInternal(
744
+ #else
686
745
  XmlIndexLookup *createIndexLookup(
746
+ #endif
687
747
  XmlContainer &cont,
688
748
  const std::string &uri, const std::string &name,
689
749
  const std::string &index,
@@ -743,8 +803,8 @@ public:
743
803
  };
744
804
  #ifndef SWIGJAVA
745
805
  XmlIndexLookup();
746
- #endif
747
806
  XmlIndexLookup(const XmlIndexLookup &o);
807
+ #endif
748
808
  ~XmlIndexLookup();
749
809
  bool isNull() const;
750
810
  const std::string &getIndex() const;
@@ -757,19 +817,37 @@ public:
757
817
  const std::string &getParentURI() const;
758
818
  const std::string &getParentName() const;
759
819
  void setParent(const std::string &uri, const std::string &name);
760
-
820
+ #ifndef SWIGJAVA
761
821
  const XmlValue &getLowBoundValue() const;
822
+ #endif
762
823
  enum XmlIndexLookup::Operation getLowBoundOperation() const;
824
+ #ifdef SWIGJAVA
825
+ %rename(setLowBoundInternal) setLowBound;
763
826
  void setLowBound(const XmlValue &value,
764
827
  enum XmlIndexLookup::Operation op);
765
-
828
+ #else
829
+ void setLowBound(const XmlValue &value,
830
+ enum XmlIndexLookup::Operation op);
831
+ #endif
832
+ #ifndef SWIGJAVA
766
833
  const XmlValue &getHighBoundValue() const;
834
+ #endif
767
835
  enum XmlIndexLookup::Operation getHighBoundOperation() const;
836
+ #ifdef SWIGJAVA
837
+ %rename(setHighBoundInternal) setHighBound;
768
838
  void setHighBound(const XmlValue &value,
769
839
  enum XmlIndexLookup::Operation op);
770
-
840
+ #else
841
+ void setHighBound(const XmlValue &value,
842
+ enum XmlIndexLookup::Operation op);
843
+ #endif
844
+ #ifndef SWIGJAVA
771
845
  const XmlContainer &getContainer() const;
772
846
  void setContainer(XmlContainer &container);
847
+ #else
848
+ %rename(setContainerInternal) setContainer;
849
+ void setContainer(XmlContainer &container);
850
+ #endif
773
851
  %extend {
774
852
  XmlResults *execute(XmlQueryContext &context,
775
853
  u_int32_t flags = 0) const {
@@ -870,25 +948,28 @@ OVERLOAD_NAME(replaceDefaultIndexWithTxn)
870
948
  void replaceDefaultIndex(XmlTransaction &txn, const std::string &index,
871
949
  XmlUpdateContext &uc);
872
950
 
873
-
874
-
951
+ #ifndef SWIGJAVA
875
952
  void putDocument(XmlDocument &document, XmlUpdateContext &context,
876
953
  u_int32_t flags = 0);
954
+ #endif
877
955
  OVERLOAD_NAME(putDocumentAsString)
878
956
  std::string putDocument(const std::string &name, const std::string &contents,
879
957
  XmlUpdateContext &context, u_int32_t flags = 0);
880
958
  OVERLOAD_NAME(putDocumentAsEventReader)
881
959
  std::string putDocument(const std::string &name, XmlEventReader &reader,
882
960
  XmlUpdateContext &context, u_int32_t flags = 0);
961
+ #ifndef SWIGJAVA
883
962
  OVERLOAD_NAME(putDocumentAsEventWriter)
884
963
  XmlEventWriter &putDocumentAsEventWriter(XmlDocument &document,
885
964
  XmlUpdateContext &context,
886
965
  u_int32_t flags = 0);
887
966
  void deleteDocument(XmlDocument &document,
888
967
  XmlUpdateContext &context);
968
+ #endif
889
969
  OVERLOAD_NAME(deleteDocumentByName)
890
970
  void deleteDocument(const std::string &name,
891
971
  XmlUpdateContext &context);
972
+ #ifndef SWIGJAVA
892
973
  void updateDocument(XmlDocument &document,
893
974
  XmlUpdateContext &context);
894
975
 
@@ -904,9 +985,11 @@ OVERLOAD_NAME(putDocumentAsInputSourceWithTxn)
904
985
  XmlInputStream *input,
905
986
  XmlUpdateContext &context,
906
987
  u_int32_t flags = 0);
988
+
907
989
  OVERLOAD_NAME(putDocumentWithTxn)
908
990
  void putDocument(XmlTransaction &txn, XmlDocument &document,
909
991
  XmlUpdateContext &context, u_int32_t flags = 0);
992
+ #endif
910
993
  OVERLOAD_NAME(putDocumentAsStringWithTxn)
911
994
  std::string putDocument(XmlTransaction &txn,
912
995
  const std::string &name,
@@ -919,6 +1002,7 @@ OVERLOAD_NAME(putDocumentAsEventReaderWithTxn)
919
1002
  XmlEventReader &reader,
920
1003
  XmlUpdateContext &context,
921
1004
  u_int32_t flags = 0);
1005
+ #ifndef SWIGJAVA
922
1006
  OVERLOAD_NAME(putDocumentAsEventWriterWithTxn)
923
1007
  XmlEventWriter &putDocumentAsEventWriter(XmlTransaction &txn,
924
1008
  XmlDocument &document,
@@ -927,13 +1011,15 @@ OVERLOAD_NAME(putDocumentAsEventWriterWithTxn)
927
1011
  OVERLOAD_NAME(deleteDocumentWithTxn)
928
1012
  void deleteDocument(XmlTransaction &txn, XmlDocument &document,
929
1013
  XmlUpdateContext &context);
1014
+ #endif
930
1015
  OVERLOAD_NAME(deleteDocumentByNameWithTxn)
931
1016
  void deleteDocument(XmlTransaction &txn, const std::string &name,
932
1017
  XmlUpdateContext &context);
1018
+ #ifndef SWIGJAVA
933
1019
  OVERLOAD_NAME(updateDocumentWithTxn)
934
1020
  void updateDocument(XmlTransaction &txn, XmlDocument &document,
935
1021
  XmlUpdateContext &context);
936
-
1022
+ #endif
937
1023
  size_t getNumDocuments();
938
1024
  OVERLOAD_NAME(getNumDocumentWithTxn)
939
1025
  size_t getNumDocuments(XmlTransaction &txn);
@@ -971,16 +1057,6 @@ OVERLOAD_NAME(getNodeWithTxn)
971
1057
  {
972
1058
  return new XmlValue(self->getNode(txn, name, 0));
973
1059
  }
974
- #endif
975
- OVERLOAD_NAME(getDocumentWithFlags)
976
- XmlDocument *getDocument(const std::string &name, u_int32_t flags) {
977
- return new XmlDocument(self->getDocument(name, flags));
978
- }
979
- OVERLOAD_NAME(getDocumentWithFlagsAndTxn)
980
- XmlDocument *getDocument(XmlTransaction &txn, const std::string &name,
981
- u_int32_t flags) {
982
- return new XmlDocument(self->getDocument(txn, name, flags));
983
- }
984
1060
  OVERLOAD_NAME(getNodeWithFlags)
985
1061
  XmlValue *getNode(const std::string &name, u_int32_t flags) {
986
1062
  return new XmlValue(self->getNode(name, flags));
@@ -991,6 +1067,18 @@ OVERLOAD_NAME(getNodeWithFlagsAndTxn)
991
1067
  return new XmlValue(self->getNode(txn, name, flags));
992
1068
  }
993
1069
 
1070
+ OVERLOAD_NAME(getDocumentWithFlags)
1071
+ XmlDocument *getDocument(const std::string &name, u_int32_t flags) {
1072
+ return new XmlDocument(self->getDocument(name, flags));
1073
+ }
1074
+ OVERLOAD_NAME(getDocumentWithFlagsAndTxn)
1075
+ XmlDocument *getDocument(XmlTransaction &txn, const std::string &name,
1076
+ u_int32_t flags) {
1077
+ return new XmlDocument(self->getDocument(txn, name, flags));
1078
+ }
1079
+
1080
+ #endif
1081
+
994
1082
  XmlResults *getAllDocuments(u_int32_t flags) {
995
1083
  return new XmlResults(self->getAllDocuments(flags));
996
1084
  }
@@ -1085,18 +1173,13 @@ OVERLOAD_NAME(lookupEdgeStatisticsWithTxn)
1085
1173
  }
1086
1174
  } /* %extend */
1087
1175
  };
1088
-
1089
- #ifdef SWIGJAVA
1090
- %rename(setContentAsXmlInputStream_java) XmlDocument::setContentAsXmlInputStream;
1091
- %rename(setContentAsEventReader_java) XmlDocument::setContentAsEventReader;
1092
- #endif
1093
-
1176
+ #ifndef SWIGJAVA
1094
1177
  class XmlDocument
1095
1178
  {
1096
1179
  public:
1097
- #ifndef SWIGJAVA
1180
+
1098
1181
  XmlDocument();
1099
- #endif
1182
+
1100
1183
  XmlDocument(const XmlDocument &o);
1101
1184
  ~XmlDocument();
1102
1185
 
@@ -1122,7 +1205,6 @@ OVERLOAD_NAME(setContentWithXmlData)
1122
1205
 
1123
1206
  XmlEventReader &getContentAsEventReader() const;
1124
1207
  void setContentAsEventReader(XmlEventReader &reader);
1125
-
1126
1208
  void getContentAsEventWriter(XmlEventWriter &writer);
1127
1209
 
1128
1210
  void fetchAllData();
@@ -1134,11 +1216,9 @@ OVERLOAD_NAME(setContentWithXmlData)
1134
1216
  OVERLOAD_NAME(setMetaDataWithXmlData)
1135
1217
  void setMetaData(const std::string &uri,
1136
1218
  const std::string &name, const XmlData &value);
1137
- #ifndef SWIGJAVA
1138
1219
  OVERLOAD_NAME(getMetaDataAsXmlData)
1139
1220
  bool getMetaData(const std::string &uri, const std::string &name,
1140
1221
  XmlData &value);
1141
- #endif
1142
1222
  %extend {
1143
1223
  std::string getContentAsString() const {
1144
1224
  std::string s;
@@ -1205,7 +1285,6 @@ class XmlQueryContext
1205
1285
  public:
1206
1286
  enum // ReturnType
1207
1287
  {
1208
- DeadValues,
1209
1288
  LiveValues
1210
1289
  };
1211
1290
 
@@ -1216,9 +1295,7 @@ public:
1216
1295
  };
1217
1296
 
1218
1297
  /// Constructor.
1219
- #ifndef SWIGJAVA
1220
1298
  XmlQueryContext();
1221
- #endif
1222
1299
  XmlQueryContext(const XmlQueryContext &o);
1223
1300
  ~XmlQueryContext();
1224
1301
 
@@ -1226,10 +1303,8 @@ public:
1226
1303
  std::string getNamespace(const std::string &prefix);
1227
1304
  void removeNamespace(const std::string &prefix);
1228
1305
  void clearNamespaces(void);
1229
-
1230
1306
  void setVariableValue(const std::string &name, const XmlValue &value);
1231
1307
  void setVariableValue(const std::string &name, XmlResults &value);
1232
-
1233
1308
  void setBaseURI(const std::string &baseURI);
1234
1309
  std::string getBaseURI() const;
1235
1310
  void setReturnType(enum XmlQueryContext::ReturnType type);
@@ -1275,7 +1350,6 @@ public:
1275
1350
  throw;
1276
1351
  }
1277
1352
  }
1278
-
1279
1353
  #ifdef SWIGTCL8
1280
1354
  const std::string get(const char *name) const {
1281
1355
  XmlValue value;
@@ -1293,7 +1367,7 @@ public:
1293
1367
  #endif /* SWIGTCL8 */
1294
1368
  } /* %extend */
1295
1369
  };
1296
-
1370
+ #endif //SWIGJAVA
1297
1371
  class XmlResults
1298
1372
  {
1299
1373
  public:
@@ -1301,11 +1375,13 @@ public:
1301
1375
  XmlResults();
1302
1376
  #endif
1303
1377
  ~XmlResults();
1378
+ #ifndef SWIGJAVA
1304
1379
  XmlResults(const XmlResults &results);
1305
-
1380
+ #endif
1306
1381
  bool hasNext();
1307
1382
  bool hasPrevious();
1308
- #if defined(SWIGJAVA) || defined(SWIGPYTHON) || defined(SWIGPHP4) || defined(SWIGRUBY)
1383
+ bool isNull() const;
1384
+ #if defined(SWIGPYTHON) || defined(SWIGPHP4) || defined(SWIGRUBY)
1309
1385
  %extend {
1310
1386
  XmlValue *next() {
1311
1387
  XmlValue *value = new XmlValue;
@@ -1335,41 +1411,43 @@ public:
1335
1411
  }
1336
1412
  }
1337
1413
  } /* %extend */
1414
+ #elif defined(SWIGJAVA)
1338
1415
  #else
1339
1416
  bool next(XmlValue &value);
1340
1417
  bool previous(XmlValue &value);
1341
1418
  bool peek(XmlValue &value);
1342
1419
  #endif
1343
1420
  enum XmlQueryContext::EvaluationType getEvaluationType() const;
1421
+ #ifndef SWIGJAVA
1344
1422
  OVERLOAD_NAME(nextDocument)
1345
1423
  bool next(XmlDocument &document);
1346
1424
  OVERLOAD_NAME(previousDocument)
1347
1425
  bool previous(XmlDocument &document);
1348
1426
  OVERLOAD_NAME(peekDocument)
1349
1427
  bool peek(XmlDocument &document);
1350
-
1428
+ #endif
1351
1429
  #if defined(SWIGPYTHON)
1352
1430
  %pythoncode %{
1353
1431
  def __iter__(self): return self
1354
1432
  %}
1355
1433
  #endif
1434
+ #ifndef SWIGJAVA
1356
1435
  void reset();
1357
1436
  size_t size() const;
1358
1437
  void add(const XmlValue &value);
1359
-
1438
+ #else
1439
+ size_t size() const;
1440
+ %rename(resetInternal) reset;
1441
+ void reset();
1442
+ #endif
1360
1443
  };
1361
-
1444
+ #ifndef SWIGJAVA
1362
1445
  class XmlUpdateContext
1363
1446
  {
1364
1447
  public:
1365
- #ifndef SWIGJAVA
1366
1448
  XmlUpdateContext();
1367
- #endif
1368
1449
  XmlUpdateContext(const XmlUpdateContext &o);
1369
1450
  virtual ~XmlUpdateContext();
1370
-
1371
- void setApplyChangesToContainers(bool applyChanges);
1372
- bool getApplyChangesToContainers() const;
1373
1451
  };
1374
1452
 
1375
1453
 
@@ -1377,6 +1455,7 @@ class XmlValue
1377
1455
  {
1378
1456
  public:
1379
1457
  //NOTE: these enumerations MUST match those in XmlValue.hpp
1458
+ //The values should be copied to xml/src/java/com/sleepycat/dbxml/XmlValue.java
1380
1459
  enum //NodeType
1381
1460
  {
1382
1461
  ELEMENT_NODE = 1,
@@ -1464,8 +1543,6 @@ OVERLOAD_NAME(XmlValueTypedFromXmlData)
1464
1543
 
1465
1544
  double asNumber() const;
1466
1545
  std::string asString() const;
1467
- OVERLOAD_NAME(asStringEncoded)
1468
- std::string asString(const std::string &encoding) const;
1469
1546
  bool asBoolean() const;
1470
1547
  %extend {
1471
1548
  XmlData * asBinary() const {
@@ -1522,6 +1599,7 @@ OVERLOAD_NAME(asStringEncoded)
1522
1599
  }
1523
1600
  }
1524
1601
  };
1602
+ #endif /* SWIGJAVA */
1525
1603
 
1526
1604
  class XmlIndexSpecification {
1527
1605
  public:
@@ -1639,6 +1717,7 @@ public:
1639
1717
 
1640
1718
  const std::string & getQuery() const;
1641
1719
  std::string getQueryPlan() const;
1720
+ bool isUpdateExpression() const;
1642
1721
 
1643
1722
  %extend {
1644
1723
  XmlResults *execute(XmlQueryContext &context,
@@ -1772,8 +1851,6 @@ OVERLOAD_NAME(addAppendStepWithResults)
1772
1851
  void addRenameStep(const XmlQueryExpression &selectionExpr,
1773
1852
  const std::string &newName);
1774
1853
 
1775
- void setNewEncoding(const std::string &newEncoding);
1776
-
1777
1854
  unsigned int execute(XmlValue &toModify, XmlQueryContext &context,
1778
1855
  XmlUpdateContext &uc) const;
1779
1856
  OVERLOAD_NAME(executeOnResults)
@@ -1831,6 +1908,8 @@ public:
1831
1908
 
1832
1909
  class XmlEventReader
1833
1910
  {
1911
+ protected:
1912
+ XmlEventReader();
1834
1913
  public:
1835
1914
  enum { // XmlEventType
1836
1915
  StartElement,
@@ -1867,7 +1946,7 @@ public:
1867
1946
  // add an explicit call
1868
1947
  %extend {
1869
1948
  const unsigned char *getValue() const {
1870
- int len;
1949
+ size_t len;
1871
1950
  return self->getValue(len);
1872
1951
  }
1873
1952
  }
@@ -1875,8 +1954,8 @@ public:
1875
1954
  // byte length is not useful for Java. It may not
1876
1955
  // be for other languages -- need to check
1877
1956
  %extend {
1878
- int getValueLength() const {
1879
- int len;
1957
+ size_t getValueLength() const {
1958
+ size_t len;
1880
1959
  (void)self->getValue(len);
1881
1960
  return len;
1882
1961
  }
@@ -1910,6 +1989,8 @@ public:
1910
1989
 
1911
1990
  class XmlEventWriter
1912
1991
  {
1992
+ protected:
1993
+ XmlEventWriter();
1913
1994
  public:
1914
1995
  ~XmlEventWriter();
1915
1996
  void close();
@@ -1919,11 +2000,27 @@ public:
1919
2000
  const unsigned char *uri,
1920
2001
  const unsigned char *value,
1921
2002
  bool isSpecified);
1922
-
2003
+ // If length parameter is 0, the library will perform
2004
+ // the counting. This should be done if string length
2005
+ // is != to the UTF-8 byte count (e.g. multi-byte chars)
1923
2006
  void writeText(enum XmlEventReader::XmlEventType type,
1924
2007
  const unsigned char *text,
1925
- int length);
2008
+ size_t length);
2009
+ void writeDTD(const unsigned char *dtd, size_t length);
1926
2010
 
2011
+ // There is a problem with the Tcl overload here...
2012
+ #if defined(DBXML_USEOVERLOADS) && !defined(SWIGTCL8)
2013
+ // Add no-length overloads
2014
+ %extend {
2015
+ void writeText(enum XmlEventReader::XmlEventType type,
2016
+ const unsigned char *text) {
2017
+ self->writeText(type, text, 0);
2018
+ }
2019
+ void writeDTD(const unsigned char *dtd) {
2020
+ self->writeDTD(dtd, 0);
2021
+ }
2022
+ }
2023
+ #endif
1927
2024
  void writeProcessingInstruction(const unsigned char *target,
1928
2025
  const unsigned char *data);
1929
2026
 
@@ -1936,7 +2033,6 @@ public:
1936
2033
  const unsigned char *prefix,
1937
2034
  const unsigned char *uri);
1938
2035
 
1939
- void writeDTD(const unsigned char *dtd, int length);
1940
2036
  void writeStartDocument(const unsigned char *version,
1941
2037
  const unsigned char *encoding,
1942
2038
  const unsigned char *standalone);
@@ -1950,9 +2046,14 @@ public:
1950
2046
  class XmlEventReaderToWriter
1951
2047
  {
1952
2048
  public:
2049
+ #ifndef SWIGJAVA
1953
2050
  XmlEventReaderToWriter(XmlEventReader &reader,
1954
2051
  XmlEventWriter &writer,
1955
2052
  bool ownsReader);
2053
+ #endif
2054
+ XmlEventReaderToWriter(XmlEventReader &reader,
2055
+ XmlEventWriter &writer,
2056
+ bool ownsReader, bool ownsWriter);
1956
2057
  ~XmlEventReaderToWriter();
1957
2058
 
1958
2059
  void start();