aboutsummaryrefslogtreecommitdiff
path: root/libxsde/xsde/cxx/serializer
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-09-08 16:24:44 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-09-08 16:24:44 +0200
commitd6313f9155195b856ee8170efb6d67e4072e64bc (patch)
tree6471ff65c1afba82c182e92798a0018b9fbdb61f /libxsde/xsde/cxx/serializer
parentab27d628b1e1500a22597acad013c4b50e5474a9 (diff)
Handle NULL and empty namespace value in serializer
Diffstat (limited to 'libxsde/xsde/cxx/serializer')
-rw-r--r--libxsde/xsde/cxx/serializer/genx/document.cxx57
-rw-r--r--libxsde/xsde/cxx/serializer/genx/document.hxx4
2 files changed, 32 insertions, 29 deletions
diff --git a/libxsde/xsde/cxx/serializer/genx/document.cxx b/libxsde/xsde/cxx/serializer/genx/document.cxx
index 5514765..4c634a4 100644
--- a/libxsde/xsde/cxx/serializer/genx/document.cxx
+++ b/libxsde/xsde/cxx/serializer/genx/document.cxx
@@ -86,14 +86,7 @@ namespace xsde
#ifdef XSDE_POLYMORPHIC
root_static_type_ = st;
#endif
- // Leave root_ns_ uninitialized.
- //
-#ifdef XSDE_EXCEPTIONS
- root_name_.assign (name);
-#else
- if (root_name_.assign (name))
- error_ = error (sys_error::no_memory);
-#endif
+ init_root_name (0, name);
}
document_simpl::
@@ -113,13 +106,7 @@ namespace xsde
#ifdef XSDE_POLYMORPHIC
root_static_type_ = st;
#endif
-#ifdef XSDE_EXCEPTIONS
- root_ns_.assign (ns);
- root_name_.assign (name);
-#else
- if (root_ns_.assign (ns) || root_name_.assign (name))
- error_ = error (sys_error::no_memory);
-#endif
+ init_root_name (ns, name);
}
#ifdef XSDE_STL
@@ -137,14 +124,7 @@ namespace xsde
#ifdef XSDE_POLYMORPHIC
root_static_type_ = st;
#endif
- // Leave root_ns_ uninitialized.
- //
-#ifdef XSDE_EXCEPTIONS
- root_name_.assign (name.c_str (), name.size ());
-#else
- if (root_name_.assign (name.c_str (), name.size ()))
- error_ = error (sys_error::no_memory);
-#endif
+ init_root_name (0, name.c_str ());
}
document_simpl::
@@ -164,17 +144,36 @@ namespace xsde
#ifdef XSDE_POLYMORPHIC
root_static_type_ = st;
#endif
+ init_root_name (ns.c_str (), name.c_str ());
+ }
+#endif // XSDE_STL
+
+
+ void document_simpl::
+ init_root_name (const char* ns, const char* name)
+ {
+ // Leave root_ns_ uninitialized if ns is not specified.
+ //
+ if (ns != 0 && *ns != '\0')
+ {
+#ifdef XSDE_EXCEPTIONS
+ root_ns_.assign (ns);
+#else
+ if (root_ns_.assign (ns))
+ {
+ error_ = error (sys_error::no_memory);
+ return;
+ }
+#endif
+ }
+
#ifdef XSDE_EXCEPTIONS
- root_ns_.assign (ns.c_str (), ns.size ());
- root_name_.assign (name.c_str (), name.size ());
+ root_name_.assign (name);
#else
- if (root_ns_.assign (ns.c_str (), ns.size ()) ||
- root_name_.assign (name.c_str (), name.size ()))
+ if (root_name_.assign (name))
error_ = error (sys_error::no_memory);
#endif
}
-#endif // XSDE_STL
-
void document_simpl::
add_prefix (const char* p, const char* ns)
diff --git a/libxsde/xsde/cxx/serializer/genx/document.hxx b/libxsde/xsde/cxx/serializer/genx/document.hxx
index 2d7dd5c..10d82db 100644
--- a/libxsde/xsde/cxx/serializer/genx/document.hxx
+++ b/libxsde/xsde/cxx/serializer/genx/document.hxx
@@ -283,6 +283,10 @@ namespace xsde
#ifndef XSDE_EXCEPTIONS
error error_;
#endif
+
+ private:
+ void
+ init_root_name (const char* ns, const char* name);
};
}
}