aboutsummaryrefslogtreecommitdiff
path: root/examples/cxx/hybrid/binary/custom/orawstream.txx
diff options
context:
space:
mode:
Diffstat (limited to 'examples/cxx/hybrid/binary/custom/orawstream.txx')
-rw-r--r--examples/cxx/hybrid/binary/custom/orawstream.txx47
1 files changed, 47 insertions, 0 deletions
diff --git a/examples/cxx/hybrid/binary/custom/orawstream.txx b/examples/cxx/hybrid/binary/custom/orawstream.txx
new file mode 100644
index 0000000..46c5b71
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/orawstream.txx
@@ -0,0 +1,47 @@
+// file : examples/cxx/hybrid/binary/custom/orawostream.txx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+#include <string.h> // memcpy
+
+template <typename T>
+void
+operator<< (orawstream& s, const xml_schema::pod_seq<T>& x)
+{
+ size_t n = x.size ();
+
+ s << orawstream::as_size (x.size ());
+
+ if (n != 0)
+ {
+ size_t mn = sizeof (T) * n;
+ char* p = s.align (sizeof (T), mn);
+ memcpy (p, x.begin (), mn);
+ }
+}
+
+template <typename T>
+void
+operator<< (orawstream& s, const xml_schema::fix_seq<T>& x)
+{
+ s << orawstream::as_size (x.size ());
+
+ for (typename xml_schema::fix_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ s << *i;
+ }
+}
+
+template <typename T>
+void
+operator<< (orawstream& s, const xml_schema::var_seq<T>& x)
+{
+ s << orawstream::as_size (x.size ());
+
+ for (typename xml_schema::var_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ s << *i;
+ }
+}