aboutsummaryrefslogtreecommitdiff
path: root/libxsde/xsde/cxx/parser/substitution-map.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-10-18 11:17:51 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-10-18 11:17:51 +0200
commitd80d096ee8743fd6f7382d274272b0b6d7faf9bf (patch)
treed0f0bee1e645cb2b86b6837ac0db8a7d2821e533 /libxsde/xsde/cxx/parser/substitution-map.cxx
parent0e4637025fa8d1b4234b0512561d31f0dd023843 (diff)
Support for schema evolution using substitution groups
New examples: hybrid/evolution/ignore and hybrid/evolution/passthrough.
Diffstat (limited to 'libxsde/xsde/cxx/parser/substitution-map.cxx')
-rw-r--r--libxsde/xsde/cxx/parser/substitution-map.cxx47
1 files changed, 46 insertions, 1 deletions
diff --git a/libxsde/xsde/cxx/parser/substitution-map.cxx b/libxsde/xsde/cxx/parser/substitution-map.cxx
index 5cbe4a1..d58ac84 100644
--- a/libxsde/xsde/cxx/parser/substitution-map.cxx
+++ b/libxsde/xsde/cxx/parser/substitution-map.cxx
@@ -5,7 +5,7 @@
#include <xsde/cxx/config.hxx>
-#include <string.h> // strlen, strcmp, strncmp
+#include <string.h> // strlen, strcmp, strncmp, strchr
#ifndef XSDE_EXCEPTIONS
# include <assert.h> // assert
@@ -17,6 +17,7 @@
#endif
#include <xsde/cxx/parser/substitution-map.hxx>
+#include <xsde/cxx/parser/substitution-map-callback.hxx>
#include <xsde/cxx/parser/substitution-map-load.hxx>
namespace xsde
@@ -47,6 +48,22 @@ namespace xsde
*type = v->type_;
}
+ // Call the callback.
+ //
+ if (!r && callback_ != 0)
+ {
+ const char* t;
+ const char* p = strchr (root, ' ');
+
+ ro_string rname (p ? root : 0, p ? p - root : 0);
+ ro_string rns (p ? p + 1 : root);
+
+ r = callback_ (rns, rname, ns, name, t);
+
+ if (r && type != 0 && *type == 0)
+ *type = t;
+ }
+
return r;
}
@@ -78,6 +95,20 @@ namespace xsde
*type = v->type_;
}
+ // Call the callback.
+ //
+ if (!r && callback_ != 0)
+ {
+ const char* t;
+ ro_string rns (root_ns);
+ ro_string rname (root_name);
+
+ r = callback_ (rns, rname, ns, name, t);
+
+ if (r && type != 0 && *type == 0)
+ *type = t;
+ }
+
return r;
}
@@ -249,7 +280,21 @@ namespace xsde
#endif
}
+ // Callback.
//
+ void
+ parser_smap_callback (
+ bool (*callback) (
+ const ro_string& root_ns,
+ const ro_string& root_name,
+ const ro_string& member_ns,
+ const ro_string& member_name,
+ const char*& type))
+ {
+ substitution_map_instance ().callback (callback);
+ }
+
+ // Load.
//
size_t
parser_smap_elements ()