rdbxml 0.6 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -7,7 +7,7 @@ progress.
7
7
 
8
8
  == Requirements
9
9
  * Rake[http://rake.rubyforge.org] >= 7.0
10
- * Berkely DBXML[http://dev.sleepycat.com/downloads/releasehistorybdbxml.html]
10
+ * Oracle BDB XML[http://www.oracle.com/technology/products/berkeley-db/xml/index.html]
11
11
 
12
12
  == Installation
13
13
 
@@ -17,34 +17,22 @@ RDBXML is distributed as a Ruby Gem for easy installation, e.g.
17
17
  sudo gem install rdbxml
18
18
 
19
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
20
+ /usr/local/) and will use the interface files taken from the dbxml-2.3.10
21
21
  distribution (the latest version, at the time of this writing).
22
22
 
23
23
  === The Right Way
24
24
 
25
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
26
+ the latest version of the DBXML distribution from
27
+ Oracle[http://www.oracle.com/technology/software/products/berkeley-db/xml/index.html].
40
28
 
41
29
  This will ensure that you have the correct versions of the various BDB and
42
30
  BDBXML libraries, as well as the current SWIG Interface definitions included in
43
31
  the DBXML distribution.
44
32
 
45
33
  You then pass the location of the (built) DBXML distribution to the RDBXML build
46
- system:
47
- DBXML_DIST=/tmp/dbxml-2.2.13 sudo gem install rdbxml
34
+ system, e.g.:
35
+ DBXML_DIST=/tmp/dbxml-2.3.10 sudo gem install rdbxml
48
36
 
49
37
  This will build, test, and install the RDBXML gem.
50
38
 
@@ -76,5 +64,5 @@ any issues on the RDBXML Website[http://rubyforge.org/projects/rdbxml].
76
64
  Author:: Steve Sloan (mailto:steve@finagle.org)
77
65
  Website:: http://rdbxml.rubyforge.org
78
66
  Rubyforge:: http://rubyforge.org/projects/rdbxml
79
- Copyright:: Copyright (c) 2006 Steve Sloan
67
+ Copyright:: Copyright (c) 2007 Steve Sloan
80
68
  License:: MIT
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rake/rdoctask'
6
6
  require 'rake/gempackagetask'
7
7
  require 'rake/contrib/rubyforgepublisher'
8
8
 
9
- GEM_VERSION = '0.6'
9
+ GEM_VERSION = '0.7'
10
10
 
11
11
  dbxml_dist = ENV['DBXML_DIST']
12
12
  if dbxml_dist
@@ -36,7 +36,7 @@ desc "Build the BDBXML interface extension"
36
36
  Rake::SWIGExtensionTask.new :dbxml do |t|
37
37
  t.dir = 'ext'
38
38
  t.deps[:dbxml] << :dbxml_ruby
39
- t.link_libs += ['db', 'db_cxx', 'dbxml', 'xquery', 'xerces-c', 'pathan']
39
+ t.link_libs += ['db', 'db_cxx', 'dbxml', 'xqilla', 'xerces-c']
40
40
  end
41
41
 
42
42
  task :test => :extensions
@@ -49,7 +49,7 @@ end
49
49
 
50
50
  task :install => [:test, :clean] do end
51
51
 
52
- rd = Rake::RDocTask.new :rdoc do |rdoc|
52
+ docs = Rake::RDocTask.new :rdoc do |rdoc|
53
53
  rdoc.rdoc_dir = 'html'
54
54
  rdoc.title = "RDBXML -- XML Databases for Ruby"
55
55
  rdoc.options += ['--line-numbers', '--inline-source', '--main', 'README', '--exclude', 'ext/*.c*']
@@ -59,7 +59,7 @@ rd = Rake::RDocTask.new :rdoc do |rdoc|
59
59
  rdoc.rdoc_files.include 'rake/**/*task.rb'
60
60
  end
61
61
 
62
- GEM_FILES = rd.rdoc_files + FileList[
62
+ GEM_FILES = docs.rdoc_files + FileList[
63
63
  'Rakefile',
64
64
  'ext/**/*.i',
65
65
  'rake/**/*.rb',
@@ -83,8 +83,8 @@ spec = Gem::Specification.new do |s|
83
83
  s.require_paths << 'ext'
84
84
 
85
85
  s.has_rdoc = true
86
- s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
87
- s.rdoc_options = rd.options
86
+ s.extra_rdoc_files = docs.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
87
+ s.rdoc_options = docs.options
88
88
  end
89
89
  Rake::GemPackageTask.new spec do |pkg|
90
90
  pkg.need_zip = true
@@ -95,5 +95,3 @@ task :default => :extensions
95
95
  task :all => :extensions
96
96
 
97
97
  load 'publish.rf' if File.exist? 'publish.rf'
98
-
99
-
data/ext/dbxml.i CHANGED
@@ -56,6 +56,8 @@ public:
56
56
  #error "Unknown SWIG target language"
57
57
  #endif
58
58
 
59
+ // DBXML_USEOVERLOADS -- defined when a language supports overloaded
60
+ // functions. If defined, the "OVERLOAD_NAME" macro is a no-op
59
61
  #if defined(SWIGJAVA) || defined(SWIGPYTHON) || defined(SWIGCSHARP) || defined(SWIGTCL8) || defined(SWIGRUBY)
60
62
  #define DBXML_USEOVERLOADS
61
63
  #endif
@@ -64,7 +66,7 @@ public:
64
66
  #define DBXML_USE_RESOLVER
65
67
  #endif
66
68
 
67
- typedef unsigned int u_int32_t;
69
+ //typedef unsigned int u_int32_t;
68
70
  typedef int int32_t;
69
71
 
70
72
  class XmlManager;
@@ -82,6 +84,9 @@ class XmlModify;
82
84
  class XmlTransaction;
83
85
  class XmlMetaDataIterator;
84
86
  class XmlStatistics;
87
+ class XmlEventReader;
88
+ class XmlEventWriter;
89
+ class XmlEventReaderToWriter;
85
90
  #if defined(DBXML_USE_RESOLVER)
86
91
  class XmlResolver;
87
92
  #endif
@@ -98,8 +103,9 @@ class XmlResolver;
98
103
  #ifndef SWIGJAVA
99
104
  // For Java, this is done differently
100
105
  enum {
101
- DB_CREATE, DB_DIRTY_READ, DB_EXCL,
102
- DB_NOMMAP, DB_RDONLY, DB_THREAD,
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,
103
109
  DB_INIT_LOCK, DB_INIT_LOG, DB_INIT_MPOOL, DB_INIT_TXN,
104
110
  DB_SALVAGE, DB_AGGRESSIVE
105
111
  };
@@ -111,6 +117,12 @@ enum {
111
117
  %javaconst(1);
112
118
  #endif
113
119
 
120
+ // This directive will turn all instances of u_int32_t in
121
+ // this file into int for the purposes of typemaps and typing.
122
+ // For various reaons, as of SWIG 1.3.29, this works better,
123
+ // and should not cause any actual failures anywhere.
124
+ %apply int {u_int32_t};
125
+
114
126
  //
115
127
  // see DbXmlFwd.hpp for these enums
116
128
  //
@@ -119,17 +131,18 @@ enum {
119
131
  DBXML_ADOPT_DBENV = 0x00000001,
120
132
  DBXML_ALLOW_EXTERNAL_ACCESS = 0x00000002,
121
133
  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
134
+ DBXML_ALLOW_VALIDATION = 0x00100000,
135
+ DBXML_TRANSACTIONAL = 0x00200000,
136
+ DBXML_CHKSUM = 0x00400000,
137
+ DBXML_ENCRYPT = 0x00800000,
138
+ DBXML_INDEX_NODES = 0x01000000,
139
+ DBXML_NO_INDEX_NODES = 0x02000000,
140
+ DBXML_REVERSE_ORDER = 0x00100000,
141
+ DBXML_INDEX_VALUES = 0x00200000,
142
+ DBXML_CACHE_DOCUMENTS = 0x00400000,
143
+ DBXML_LAZY_DOCS = 0x00800000,
144
+ DBXML_WELL_FORMED_ONLY = 0x01000000,
145
+ DBXML_GEN_NAME = 0x02000000
133
146
  };
134
147
 
135
148
  // LogLevel
@@ -257,10 +270,15 @@ void setLogCategory(enum LogCategory category, bool enabled) {
257
270
  #ifndef SWIGJAVA
258
271
  %newobject XmlContainer::getDocument(const std::string&);
259
272
  %newobject XmlContainer::getDocument(XmlTransaction&, const std::string&);
273
+ %newobject XmlContainer::getNode(const std::string&);
274
+ %newobject XmlContainer::getNode(XmlTransaction&, const std::string&);
260
275
  #endif
261
276
  %newobject XmlContainer::getDocument(const std::string&, u_int32_t);
262
277
  %newobject XmlContainer::getDocument(XmlTransaction&, const std::string&,
263
278
  u_int32_t);
279
+ %newobject XmlContainer::getNode(const std::string&, u_int32_t);
280
+ %newobject XmlContainer::getNode(XmlTransaction&, const std::string&,
281
+ u_int32_t);
264
282
  %newobject XmlContainer::getAllDocuments(u_int32_t);
265
283
  %newobject XmlContainer::getAllDocuments(XmlTransaction&, u_int32_t);
266
284
  %newobject XmlContainer::lookupIndex(XmlQueryContext &, const std::string &,
@@ -370,6 +388,7 @@ void setLogCategory(enum LogCategory category, bool enabled) {
370
388
  %newobject XmlValue::getAttributes() const;
371
389
  %newobject XmlValue::getOwnerElement() const;
372
390
  %newobject XmlValue::asBinary() const;
391
+ %newobject XmlValue::loadNodeHandle() const;
373
392
 
374
393
  %newobject XmlIndexSpecification::find(const std::string&, const std::string&);
375
394
  %newobject XmlIndexSpecification::next();
@@ -379,6 +398,7 @@ void setLogCategory(enum LogCategory category, bool enabled) {
379
398
  #if defined(DBXML_USE_RESOLVER)
380
399
  %newobject XmlResolver::resolveSchema(XmlTransaction*, XmlManager&, const std::string&, const std::string&) const;
381
400
  %newobject XmlResolver::resolveEntity(XmlTransaction*, XmlManager&, const std::string&, const std::string&) const;
401
+ %newobject XmlResolver::resolveModule(XmlTransaction*, XmlManager&, const std::string&, const std::string&) const;
382
402
  #endif
383
403
 
384
404
  #ifdef SWIGJAVA
@@ -403,6 +423,7 @@ OVERLOAD_NAME(XmlManagerFromEnv)
403
423
  #ifndef SWIGJAVA
404
424
  void setDefaultContainerFlags(u_int32_t flags);
405
425
  u_int32_t getDefaultContainerFlags();
426
+ u_int32_t getFlags() const;
406
427
  #endif
407
428
  void setDefaultPageSize(u_int32_t pageSize);
408
429
  u_int32_t getDefaultPageSize();
@@ -418,6 +439,9 @@ OVERLOAD_NAME(XmlManagerFromEnv)
418
439
  void registerResolver(const XmlResolver &resolver);
419
440
  #endif
420
441
 
442
+ int getImplicitTimezone() const;
443
+ void setImplicitTimezone(int tz);
444
+
421
445
  int existsContainer(const std::string &name);
422
446
  void removeContainer(const std::string &name);
423
447
  OVERLOAD_NAME(removeContainerWithTxn)
@@ -428,6 +452,14 @@ OVERLOAD_NAME(renameContainerWithTxn)
428
452
  void renameContainer(XmlTransaction &txn, const std::string &oldName,
429
453
  const std::string &newName);
430
454
  void upgradeContainer(const std::string &name, XmlUpdateContext &uc);
455
+ void compactContainer(const std::string &name, XmlUpdateContext &uc,
456
+ u_int32_t flags = 0);
457
+ void compactContainer(XmlTransaction &txn, const std::string &name,
458
+ XmlUpdateContext &uc, u_int32_t flags = 0);
459
+ void truncateContainer(const std::string &name, XmlUpdateContext &uc,
460
+ u_int32_t flags = 0);
461
+ void truncateContainer(XmlTransaction &txn, const std::string &name,
462
+ XmlUpdateContext &uc, u_int32_t flags = 0);
431
463
  void reindexContainer(const std::string &name, XmlUpdateContext &uc,
432
464
  u_int32_t flags = 0);
433
465
  void reindexContainer(XmlTransaction &txn, const std::string &name,
@@ -752,6 +784,11 @@ public:
752
784
 
753
785
  };
754
786
 
787
+ #ifdef SWIGJAVA
788
+ %ignore putDocument(const std::string &name, XmlEventReader &reader, XmlUpdateContext &context);
789
+ %ignore putDocument(XmlTransaction &txn, const std::string &name, XmlEventReader &reader, XmlUpdateContext &context);
790
+ #endif
791
+
755
792
  class XmlContainer
756
793
  {
757
794
  public:
@@ -769,13 +806,14 @@ public:
769
806
  void sync();
770
807
  #ifndef SWIGJAVA
771
808
  void close();
809
+ u_int32_t getFlags() const;
772
810
  #endif SWIGJAVA
773
811
 
774
812
  bool addAlias(const std::string &alias);
775
813
  bool removeAlias(const std::string &alias);
776
-
814
+ #ifndef SWIGJAVA
777
815
  XmlManager &getManager();
778
-
816
+ #endif
779
817
  const std::string &getName() const;
780
818
  enum XmlContainer::ContainerType getContainerType() const;
781
819
  bool getIndexNodes() const;
@@ -838,7 +876,14 @@ OVERLOAD_NAME(replaceDefaultIndexWithTxn)
838
876
  u_int32_t flags = 0);
839
877
  OVERLOAD_NAME(putDocumentAsString)
840
878
  std::string putDocument(const std::string &name, const std::string &contents,
841
- XmlUpdateContext &context, u_int32_t flags = 0);
879
+ XmlUpdateContext &context, u_int32_t flags = 0);
880
+ OVERLOAD_NAME(putDocumentAsEventReader)
881
+ std::string putDocument(const std::string &name, XmlEventReader &reader,
882
+ XmlUpdateContext &context, u_int32_t flags = 0);
883
+ OVERLOAD_NAME(putDocumentAsEventWriter)
884
+ XmlEventWriter &putDocumentAsEventWriter(XmlDocument &document,
885
+ XmlUpdateContext &context,
886
+ u_int32_t flags = 0);
842
887
  void deleteDocument(XmlDocument &document,
843
888
  XmlUpdateContext &context);
844
889
  OVERLOAD_NAME(deleteDocumentByName)
@@ -868,6 +913,17 @@ OVERLOAD_NAME(putDocumentAsStringWithTxn)
868
913
  const std::string &contents,
869
914
  XmlUpdateContext &context,
870
915
  u_int32_t flags = 0);
916
+ OVERLOAD_NAME(putDocumentAsEventReaderWithTxn)
917
+ std::string putDocument(XmlTransaction &txn,
918
+ const std::string &name,
919
+ XmlEventReader &reader,
920
+ XmlUpdateContext &context,
921
+ u_int32_t flags = 0);
922
+ OVERLOAD_NAME(putDocumentAsEventWriterWithTxn)
923
+ XmlEventWriter &putDocumentAsEventWriter(XmlTransaction &txn,
924
+ XmlDocument &document,
925
+ XmlUpdateContext &context,
926
+ u_int32_t flags = 0);
871
927
  OVERLOAD_NAME(deleteDocumentWithTxn)
872
928
  void deleteDocument(XmlTransaction &txn, XmlDocument &document,
873
929
  XmlUpdateContext &context);
@@ -907,6 +963,14 @@ OVERLOAD_NAME(getDocumentWithTxn)
907
963
  {
908
964
  return new XmlDocument(self->getDocument(txn, name, 0));
909
965
  }
966
+ XmlValue *getNode(const std::string &name) {
967
+ return new XmlValue(self->getNode(name, 0));
968
+ }
969
+ OVERLOAD_NAME(getNodeWithTxn)
970
+ XmlValue *getNode(XmlTransaction &txn, const std::string &name)
971
+ {
972
+ return new XmlValue(self->getNode(txn, name, 0));
973
+ }
910
974
  #endif
911
975
  OVERLOAD_NAME(getDocumentWithFlags)
912
976
  XmlDocument *getDocument(const std::string &name, u_int32_t flags) {
@@ -917,6 +981,16 @@ OVERLOAD_NAME(getDocumentWithFlagsAndTxn)
917
981
  u_int32_t flags) {
918
982
  return new XmlDocument(self->getDocument(txn, name, flags));
919
983
  }
984
+ OVERLOAD_NAME(getNodeWithFlags)
985
+ XmlValue *getNode(const std::string &name, u_int32_t flags) {
986
+ return new XmlValue(self->getNode(name, flags));
987
+ }
988
+ OVERLOAD_NAME(getNodeWithFlagsAndTxn)
989
+ XmlValue *getNode(XmlTransaction &txn, const std::string &name,
990
+ u_int32_t flags) {
991
+ return new XmlValue(self->getNode(txn, name, flags));
992
+ }
993
+
920
994
  XmlResults *getAllDocuments(u_int32_t flags) {
921
995
  return new XmlResults(self->getAllDocuments(flags));
922
996
  }
@@ -1012,6 +1086,11 @@ OVERLOAD_NAME(lookupEdgeStatisticsWithTxn)
1012
1086
  } /* %extend */
1013
1087
  };
1014
1088
 
1089
+ #ifdef SWIGJAVA
1090
+ %rename(setContentAsXmlInputStream_java) XmlDocument::setContentAsXmlInputStream;
1091
+ %rename(setContentAsEventReader_java) XmlDocument::setContentAsEventReader;
1092
+ #endif
1093
+
1015
1094
  class XmlDocument
1016
1095
  {
1017
1096
  public:
@@ -1038,8 +1117,14 @@ OVERLOAD_NAME(setContentWithXmlData)
1038
1117
  // input stream is owned by caller
1039
1118
  XmlInputStream *getContentAsXmlInputStream() const;
1040
1119
  // input stream is donated to callee
1120
+
1041
1121
  void setContentAsXmlInputStream(XmlInputStream *adopted);
1042
1122
 
1123
+ XmlEventReader &getContentAsEventReader() const;
1124
+ void setContentAsEventReader(XmlEventReader &reader);
1125
+
1126
+ void getContentAsEventWriter(XmlEventWriter &writer);
1127
+
1043
1128
  void fetchAllData();
1044
1129
  void setMetaData(const std::string &uri,
1045
1130
  const std::string &name, const XmlValue &value);
@@ -1072,6 +1157,9 @@ OVERLOAD_NAME(getMetaDataAsXmlData)
1072
1157
  XmlMetaDataIterator *getMetaDataIterator() const {
1073
1158
  return new XmlMetaDataIterator(self->getMetaDataIterator());
1074
1159
  }
1160
+ bool equals(const XmlDocument &other) const {
1161
+ return (*self == other);
1162
+ }
1075
1163
  }
1076
1164
  };
1077
1165
 
@@ -1151,6 +1239,9 @@ public:
1151
1239
  enum XmlQueryContext::EvaluationType getEvaluationType() const;
1152
1240
  void setDefaultCollection(const std::string &uri);
1153
1241
  std::string getDefaultCollection() const;
1242
+ void interruptQuery();
1243
+ void setQueryTimeoutSeconds(u_int32_t secs);
1244
+ u_int32_t getQueryTimeoutSeconds() const;
1154
1245
 
1155
1246
  %extend {
1156
1247
  XmlValue *getVariableValue(const std::string &name) const {
@@ -1249,7 +1340,7 @@ public:
1249
1340
  bool previous(XmlValue &value);
1250
1341
  bool peek(XmlValue &value);
1251
1342
  #endif
1252
-
1343
+ enum XmlQueryContext::EvaluationType getEvaluationType() const;
1253
1344
  OVERLOAD_NAME(nextDocument)
1254
1345
  bool next(XmlDocument &document);
1255
1346
  OVERLOAD_NAME(previousDocument)
@@ -1360,6 +1451,8 @@ OVERLOAD_NAME(XmlValueTypedFromXmlData)
1360
1451
 
1361
1452
  ~XmlValue();
1362
1453
  enum XmlValue::Type getType() const;
1454
+ std::string getTypeURI() const;
1455
+ std::string getTypeName() const;
1363
1456
  bool isNull() const;
1364
1457
  bool isType(enum XmlValue::Type type) const;
1365
1458
 
@@ -1389,6 +1482,8 @@ OVERLOAD_NAME(asStringEncoded)
1389
1482
  }
1390
1483
  }
1391
1484
  #endif
1485
+ XmlEventReader &asEventReader() const;
1486
+ std::string getNodeHandle() const;
1392
1487
  bool equals(const XmlValue &value) const;
1393
1488
 
1394
1489
  std::string getNodeName() const;
@@ -1607,15 +1702,23 @@ protected:
1607
1702
  public:
1608
1703
  virtual ~XmlResolver();
1609
1704
  virtual bool resolveDocument(XmlTransaction *txn,XmlManager &mgr,
1610
- const std::string &uri, XmlValue &res) const;
1705
+ const std::string &uri,
1706
+ XmlValue &reslt) const;
1611
1707
  virtual bool resolveCollection(XmlTransaction *txn, XmlManager &mgr,
1612
- const std::string &uri, XmlResults &res) const;
1708
+ const std::string &uri,
1709
+ XmlResults &reslt) const;
1613
1710
  virtual XmlInputStream *resolveSchema(XmlTransaction *txn, XmlManager &mgr,
1614
1711
  const std::string &schemaLocation,
1615
1712
  const std::string &nameSpace) const;
1616
1713
  virtual XmlInputStream *resolveEntity(XmlTransaction *txn, XmlManager &mgr,
1617
1714
  const std::string &systemId,
1618
1715
  const std::string &publicId) const;
1716
+
1717
+ virtual bool resolveModuleLocation(
1718
+ XmlTransaction *txn, XmlManager &mgr,
1719
+ const std::string &nameSpace, XmlResults &reslt) const;
1720
+ virtual XmlInputStream *resolveModule(XmlTransaction *txn, XmlManager &mgr,
1721
+ const std::string &moduleLocation, const std::string &nameSpace) const;
1619
1722
  };
1620
1723
  #endif
1621
1724
 
@@ -1640,14 +1743,29 @@ public:
1640
1743
  enum XmlModify::XmlObject type,
1641
1744
  const std::string &name,
1642
1745
  const std::string &content);
1746
+ OVERLOAD_NAME(addInsertBeforeStepWithResults)
1747
+ void addInsertBeforeStep(const XmlQueryExpression &selectionExpr,
1748
+ enum XmlModify::XmlObject type,
1749
+ const std::string &name,
1750
+ XmlResults &content);
1643
1751
  void addInsertAfterStep(const XmlQueryExpression &selectionExpr,
1644
1752
  enum XmlModify::XmlObject type,
1645
1753
  const std::string &name,
1646
1754
  const std::string &content);
1755
+ OVERLOAD_NAME(addInsertAfterStepWithResults)
1756
+ void addInsertAfterStep(const XmlQueryExpression &selectionExpr,
1757
+ enum XmlModify::XmlObject type,
1758
+ const std::string &name,
1759
+ XmlResults &content);
1647
1760
  void addAppendStep(const XmlQueryExpression &selectionExpr,
1648
1761
  enum XmlModify::XmlObject type,
1649
1762
  const std::string &name,
1650
1763
  const std::string &content, int location = -1);
1764
+ OVERLOAD_NAME(addAppendStepWithResults)
1765
+ void addAppendStep(const XmlQueryExpression &selectionExpr,
1766
+ enum XmlModify::XmlObject type,
1767
+ const std::string &name,
1768
+ XmlResults &content, int location = -1);
1651
1769
  void addUpdateStep(const XmlQueryExpression &selectionExpr,
1652
1770
  const std::string &content);
1653
1771
  void addRemoveStep(const XmlQueryExpression &selectionExpr);
@@ -1706,3 +1824,136 @@ public:
1706
1824
  double getNumberOfUniqueKeys() const;
1707
1825
  double getSumKeyValueSize() const;
1708
1826
  };
1827
+
1828
+ #ifdef SWIGJAVA
1829
+ %rename(closeInternal) XmlEventReader::close;
1830
+ #endif
1831
+
1832
+ class XmlEventReader
1833
+ {
1834
+ public:
1835
+ enum { // XmlEventType
1836
+ StartElement,
1837
+ EndElement,
1838
+ Characters,
1839
+ CDATA,
1840
+ Comment,
1841
+ Whitespace,
1842
+ StartDocument,
1843
+ EndDocument,
1844
+ StartEntityReference,
1845
+ EndEntityReference,
1846
+ ProcessingInstruction,
1847
+ DTD
1848
+ };
1849
+ ~XmlEventReader();
1850
+ void close();
1851
+
1852
+ void setReportEntityInfo(bool value);
1853
+ bool getReportEntityInfo() const;
1854
+ void setExpandEntities(bool value);
1855
+ bool getExpandEntities() const;
1856
+
1857
+ enum XmlEventReader::XmlEventType next();
1858
+ enum XmlEventReader::XmlEventType nextTag();
1859
+
1860
+ bool hasNext() const;
1861
+ enum XmlEventReader::XmlEventType getEventType() const;
1862
+
1863
+ const unsigned char *getNamespaceURI() const;
1864
+ const unsigned char *getLocalName() const;
1865
+ const unsigned char *getPrefix() const;
1866
+ // avoid the by-reference length parameter for non-C++, instead
1867
+ // add an explicit call
1868
+ %extend {
1869
+ const unsigned char *getValue() const {
1870
+ int len;
1871
+ return self->getValue(len);
1872
+ }
1873
+ }
1874
+ #ifndef SWIGJAVA
1875
+ // byte length is not useful for Java. It may not
1876
+ // be for other languages -- need to check
1877
+ %extend {
1878
+ int getValueLength() const {
1879
+ int len;
1880
+ (void)self->getValue(len);
1881
+ return len;
1882
+ }
1883
+ }
1884
+ #endif
1885
+
1886
+ int getAttributeCount() const;
1887
+ bool isAttributeSpecified(int index) const;
1888
+ const unsigned char *getAttributeLocalName(int index) const;
1889
+ const unsigned char *getAttributeNamespaceURI(int index) const;
1890
+ const unsigned char *getAttributePrefix(int index) const;
1891
+ const unsigned char *getAttributeValue(int index) const;
1892
+
1893
+ const unsigned char *getEncoding() const;
1894
+ const unsigned char *getVersion() const;
1895
+ const unsigned char *getSystemId() const;
1896
+ bool isStandalone() const;
1897
+ bool standaloneSet() const;
1898
+ bool encodingSet() const;
1899
+
1900
+ bool hasEntityEscapeInfo() const;
1901
+ bool needsEntityEscape(int index = 0) const;
1902
+ bool hasEmptyElementInfo() const;
1903
+ bool isEmptyElement() const;
1904
+ bool isWhiteSpace() const;
1905
+ };
1906
+
1907
+ #ifdef SWIGJAVA
1908
+ %rename(closeInternal) XmlEventWriter::close;
1909
+ #endif
1910
+
1911
+ class XmlEventWriter
1912
+ {
1913
+ public:
1914
+ ~XmlEventWriter();
1915
+ void close();
1916
+
1917
+ void writeAttribute(const unsigned char *localName,
1918
+ const unsigned char *prefix,
1919
+ const unsigned char *uri,
1920
+ const unsigned char *value,
1921
+ bool isSpecified);
1922
+
1923
+ void writeText(enum XmlEventReader::XmlEventType type,
1924
+ const unsigned char *text,
1925
+ int length);
1926
+
1927
+ void writeProcessingInstruction(const unsigned char *target,
1928
+ const unsigned char *data);
1929
+
1930
+ void writeStartElement(const unsigned char *localName,
1931
+ const unsigned char *prefix,
1932
+ const unsigned char *uri,
1933
+ int numAttributes,
1934
+ bool isEmpty);
1935
+ void writeEndElement(const unsigned char *localName,
1936
+ const unsigned char *prefix,
1937
+ const unsigned char *uri);
1938
+
1939
+ void writeDTD(const unsigned char *dtd, int length);
1940
+ void writeStartDocument(const unsigned char *version,
1941
+ const unsigned char *encoding,
1942
+ const unsigned char *standalone);
1943
+ void writeEndDocument();
1944
+
1945
+ void writeStartEntity(const unsigned char *name,
1946
+ bool expandedInfoFollows);
1947
+ void writeEndEntity(const unsigned char *name);
1948
+ };
1949
+
1950
+ class XmlEventReaderToWriter
1951
+ {
1952
+ public:
1953
+ XmlEventReaderToWriter(XmlEventReader &reader,
1954
+ XmlEventWriter &writer,
1955
+ bool ownsReader);
1956
+ ~XmlEventReaderToWriter();
1957
+
1958
+ void start();
1959
+ };
data/ext/dbxml_ruby.i CHANGED
@@ -48,11 +48,13 @@ public:
48
48
  UNKNOWN_INDEX, ///< The indexing strategy name is unknown.
49
49
  INVALID_VALUE, ///< An invalid parameter was passed.
50
50
  VERSION_MISMATCH, ///< The container version and the dbxml library version are not compatible.
51
- UNUSED_2, ///< Placeholder
51
+ EVENT_ERROR, ///< Error using the event reader
52
52
  CONTAINER_NOT_FOUND, ///< The specified container could not be found
53
53
  TRANSACTION_ERROR, ///< An XmlTransaction has already been committed or aborted
54
54
  UNIQUE_ERROR, ///< A uniqueness constraint has been violated
55
- NO_MEMORY_ERROR ///< An operation was unable to allocate memory
55
+ NO_MEMORY_ERROR, ///< Unable to allocate memory
56
+ OPERATION_TIMEOUT, ///< An operation timed out
57
+ OPERATION_INTERRUPTED ///< An operation was explicitly interrupted
56
58
  };
57
59
 
58
60
  explicit XmlException(const DbException &e, const char *file = 0, int line = 0);
data/extconf.rb CHANGED
@@ -1,37 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  DBXML_DIST=ENV['DBXML_DIST'] || './dbxml-2.2.13'
3
3
 
4
- # Build makefile that just calls rakefile
4
+ # Build wrapper makefile that just calls rakefile
5
5
  File.open( 'Makefile', 'w' ) do |mk|
6
6
  targets = ['all', 'clean', 'test', 'install']
7
7
  mk.puts ".PHONY: #{targets.join(' ')}\n"
8
8
  targets.each { |t| mk.puts "#{t}:\n\t@rake $@\n" }
9
9
  end
10
-
11
-
12
- =begin
13
- require 'mkmf2'
14
-
15
- MAKEFILE_CONFIG['CC'].gsub! 'gcc', 'g++'
16
- MAKEFILE_CONFIG['CPP'].gsub! 'gcc', 'g++'
17
-
18
- ###############################################################################
19
-
20
- #b.libs += ['db-4.3', 'db_cxx-4.3', 'dbxml-2.2', 'xquery-1.2', 'xerces-c', 'pathan']
21
-
22
- add_include_path File.join( DBXML_DIST, 'install', 'include' )
23
- add_library_path File.join( DBXML_DIST, 'install', 'lib' )
24
- require_library 'db', 'db_version', 'db.h'
25
- require_library 'db_cxx', 'DbEnv::version', 'db_cxx.h'
26
- declare_binary_library 'db', 'db_wrap.cc'
27
-
28
- #add_include_path File.join( DBXML_DIST, 'install', 'include', 'dbxml' )
29
- require_library 'xerces-c', 'XERCES_VERSIONSTR', 'xercesc/util/XercesVersion.hpp'
30
- require_library 'pathan'
31
- require_library 'xquery'
32
- require_library 'dbxml', 'DBXML_VERSION_STRING', 'dbxml/DbXmlFwd.hpp'
33
- declare_binary_library 'dbxml', 'dbxml_wrap.cc'
34
-
35
-
36
- File.open( 'Makefile', 'a' ) { |mk| mk.puts "DBXML_DIST=#{DBXML_DIST}", 'include Makefile.swig' }
37
- =end
data/lib/rdbxml.rb CHANGED
@@ -163,6 +163,12 @@ class Dbxml::XmlDocument
163
163
  while i.next do s += 1 end
164
164
  s
165
165
  end
166
+
167
+ def inspect
168
+ all = {}
169
+ self.each { |n, v| all[n] = v }
170
+ all.inspect
171
+ end
166
172
  end
167
173
 
168
174
  # Returns the document metadata[http://www.sleepycat.com/xmldocs/api_cxx/XmlDocument_getMetaData.html]
@@ -183,7 +189,7 @@ class Dbxml::XmlContainer
183
189
  begin
184
190
  getDocument name.to_s
185
191
  rescue Dbxml::XmlException => ex
186
- raise unless ex.err == XmlException::DOCUMENT_NOT_FOUND
192
+ raise unless ex.err == Dbxml::XmlException::DOCUMENT_NOT_FOUND
187
193
  nil
188
194
  end
189
195
  end
@@ -209,7 +215,7 @@ class Dbxml::XmlContainer
209
215
  begin
210
216
  putDocument doc, ctx, 0
211
217
  rescue Dbxml::XmlException => ex
212
- raise unless ex.err == XmlException::UNIQUE_ERROR
218
+ raise unless ex.err == Dbxml::XmlException::UNIQUE_ERROR
213
219
  d = self[doc.name]
214
220
  d.content = doc.content
215
221
  updateDocument d, ctx
@@ -2,6 +2,8 @@ require 'rake'
2
2
  require 'rake/clean'
3
3
  require 'rake/tasklib'
4
4
 
5
+ # Rake tasks to build Ruby extensions
6
+
5
7
  module Rake
6
8
 
7
9
  # Create a build task that will generate a Ruby extension (e.g. .so) from one or more
@@ -69,7 +71,7 @@ module Rake
69
71
  # - link_libs: <none>
70
72
  def set_defaults
71
73
  @lib_name ||= name.to_sym
72
- @objs ||= [name.to_sym]
74
+ @objs = [name.to_sym] unless @objs and @objs.any?
73
75
  @dir ||= '.'
74
76
  @link_libs ||= []
75
77
  end
@@ -79,10 +81,11 @@ module Rake
79
81
  output_objs = @objs.collect { |obj| filepath obj, :objext }
80
82
  output_lib = filepath lib_name, :dlext
81
83
 
82
- task name => output_lib do end
84
+ task name => output_lib
85
+
83
86
  file output_lib => output_objs do |t|
84
- sh_cmd :ldshared, {'-L' => :libdirs}, '-o', output_lib, output_objs,
85
- {'-l' => link_libs}, :libs #, :dldlibs, :librubyarg_shared
87
+ sh_cmd :ldshared, :dldflags, :ldflags, {'-L' => :libdirs}, '-o', output_lib, output_objs.join(' '),
88
+ link_libs.collect { |l| "-l#{l}" }.join(' '), :libs, :dldlibs, :librubyarg_shared
86
89
  end
87
90
 
88
91
  CLEAN.include output_objs
@@ -109,19 +112,23 @@ module Rake
109
112
 
110
113
  class << self
111
114
  # The default environment for all extensions.
115
+ @@DefaultEnv = {}
112
116
  def env
113
117
  @@DefaultEnv
114
118
  end
119
+ def env=(e)
120
+ @@DefaultEnv = e
121
+ end
115
122
 
123
+ Config::CONFIG.merge(ENV).each { |k, v| @@DefaultEnv[k.downcase.to_sym] = v }
116
124
  @@DefaultEnv = {
117
- :cxx => ENV['CXX'] || 'c++',
118
- :cxxflags => ENV['CXXFLAGS'] || '',
125
+ :cxx => 'c++',
126
+ :cxxflags => '',
119
127
  :c_exts => ['c'],
120
128
  :cpp_exts => ['cc', 'cxx', 'cpp'],
121
129
  :includedirs => [],
122
130
  :libdirs => [],
123
- }
124
- Config::CONFIG.each { |k, v| @@DefaultEnv[k.downcase.to_sym] = v }
131
+ }.update(@@DefaultEnv)
125
132
  end
126
133
 
127
134
  protected
@@ -153,7 +160,7 @@ module Rake
153
160
  else
154
161
  opt.to_s
155
162
  end
156
- end.join(' ')
163
+ end.join(' ').squeeze(' ')
157
164
  end
158
165
 
159
166
  def sh_cmd( cmd, *opts )
@@ -178,4 +185,4 @@ module Rake
178
185
 
179
186
  end
180
187
 
181
- end
188
+ end
@@ -41,10 +41,10 @@ module Rake
41
41
  # - link_libs: <none>
42
42
  def set_defaults
43
43
  super
44
- @objs ||= []
45
44
  @ifaces ||= [name.to_sym]
46
45
  @deps ||= Hash.new []
47
- end
46
+ @objs = []
47
+ end
48
48
 
49
49
  def define_tasks
50
50
  for iface in @ifaces
@@ -57,7 +57,6 @@ module Rake
57
57
  file src => deps.collect { |dep| filepath(dep, :swigext) } << iface
58
58
  end
59
59
  CLEAN.include src
60
-
61
60
  @objs << src.sub(/\.[^.]+$/, '.'+env[:objext])
62
61
  end
63
62
  super
@@ -75,13 +74,13 @@ module Rake
75
74
  end
76
75
  end
77
76
 
78
- ExtensionTask.env.update(
77
+ ExtensionTask.env = {
79
78
  :swig => 'swig',
80
79
  :swigext => 'i',
81
80
  :swig_cppext => '_wrap.cc',
82
81
  :swig_flags => ['-ruby', '-c++'],
83
82
  :swig_includedirs => ['.']
84
- )
83
+ }.update(ExtensionTask.env)
85
84
 
86
85
  protected
87
86
 
@@ -89,10 +88,11 @@ module Rake
89
88
  def verify_swig_version
90
89
  @@swig_version ||= IO.popen "#{env[:swig]} -version 2>&1" do |swig|
91
90
  banner = swig.readlines.reject { |l| l.strip.empty? }
92
- banner[0].match(/SWIG Version ([^ ]+)/i)[1]
91
+ banner = banner[0].match(/swig version ([^ ]+)/i)
92
+ banner and banner[1]
93
93
  end
94
- unless @@swig_version >= '1.3'
95
- raise "Need SWIG version 1.3 or later (have #{@@swig_version[0]})"
94
+ unless @@swig_version and @@swig_version >= '1.3'
95
+ raise "Need SWIG version 1.3 or later (have #{@@swig_version || 'none'})"
96
96
  end
97
97
  end
98
98
  end
data/test/test_rdbxml.rb CHANGED
@@ -38,7 +38,7 @@ class XmlValueTest < Test::Unit::TestCase
38
38
 
39
39
  def test_to_s
40
40
  assert_equal '123', XmlValue.new(123).to_s
41
- assert_equal '456.789', XmlValue.new(456.789).to_s
41
+ assert_equal 456.789, XmlValue.new(456.789).to_s.to_f
42
42
  assert_equal 'foo', XmlValue.new('foo').to_s
43
43
  end
44
44
 
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: rdbxml
5
5
  version: !ruby/object:Gem::Version
6
- version: "0.6"
7
- date: 2006-05-29 00:00:00 -07:00
6
+ version: "0.7"
7
+ date: 2007-09-30 00:00:00 -07:00
8
8
  summary: Provides wrappers for the BDB XML C++ APIs, plus pure Ruby extensions
9
9
  require_paths:
10
10
  - lib
@@ -26,26 +26,27 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
26
26
  platform: ruby
27
27
  signing_key:
28
28
  cert_chain:
29
+ post_install_message:
29
30
  authors:
30
31
  - Steve Sloan
31
32
  files:
32
33
  - README
33
34
  - MIT-LICENSE
34
35
  - lib/rdbxml.rb
35
- - docs/dbxml.rb
36
36
  - docs/db.rb
37
+ - docs/dbxml.rb
37
38
  - rake/extensiontask.rb
38
39
  - rake/swigextensiontask.rb
39
40
  - Rakefile
40
41
  - ext/dbxml.i
41
42
  - ext/db.i
42
43
  - ext/dbxml_ruby.i
43
- - test/test_rdbxml.rb
44
44
  - test/test_db.rb
45
+ - test/test_rdbxml.rb
45
46
  - test/test_dbxml.rb
46
47
  test_files:
47
- - test/test_rdbxml.rb
48
48
  - test/test_db.rb
49
+ - test/test_rdbxml.rb
49
50
  - test/test_dbxml.rb
50
51
  rdoc_options:
51
52
  - --line-numbers