From 0bce70a0e483294b83b8bf9d5468838a63405612 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 8 Mar 2009 17:23:30 +0200 Subject: Add support for binary representations xsde/cxx/hybrid/insertion-*: insertion operators generator xsde/cxx/hybrid/extraction-*: extraction operators generator libxsde/xsde/cxx/hybrid/cdr/: CDR support code libxsde/xsde/cxx/hybrid/xdr/: XDR support code tests/cxx/hybrid/binary/: new tests examples/cxx/hybrid/binary/: new examples documentation/cxx/hybrid/guide/: new chapter --- libxsde/xsde/cxx/hybrid/xdr/ostream.txx | 110 ++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 libxsde/xsde/cxx/hybrid/xdr/ostream.txx (limited to 'libxsde/xsde/cxx/hybrid/xdr/ostream.txx') diff --git a/libxsde/xsde/cxx/hybrid/xdr/ostream.txx b/libxsde/xsde/cxx/hybrid/xdr/ostream.txx new file mode 100644 index 0000000..5211b80 --- /dev/null +++ b/libxsde/xsde/cxx/hybrid/xdr/ostream.txx @@ -0,0 +1,110 @@ +// file : xsde/cxx/hybrid/xdr/ostream.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace hybrid + { + +#ifdef XSDE_EXCEPTIONS + + template + void + operator<< (oxdrstream& s, const pod_seq& x) + { + s << oxdrstream::as_size (x.size ()); + + for (typename pod_seq::const_iterator i = x.begin (); + i != x.end (); ++i) + { + s << *i; + } + } + + template + void + operator<< (oxdrstream& s, const fix_seq& x) + { + s << oxdrstream::as_size (x.size ()); + + for (typename fix_seq::const_iterator i = x.begin (); + i != x.end (); ++i) + { + s << *i; + } + } + + template + void + operator<< (oxdrstream& s, const var_seq& x) + { + s << oxdrstream::as_size (x.size ()); + + for (typename var_seq::const_iterator i = x.begin (); + i != x.end (); ++i) + { + s << *i; + } + } + +#else // XSDE_EXCEPTIONS + + template + bool + operator<< (oxdrstream& s, const pod_seq& x) + { + if (!(s << oxdrstream::as_size (x.size ()))) + return false; + + for (typename pod_seq::const_iterator i = x.begin (); + i != x.end (); ++i) + { + if (!(s << *i)) + return false; + } + + return true; + } + + template + bool + operator<< (oxdrstream& s, const fix_seq& x) + { + if (!(s << oxdrstream::as_size (x.size ()))) + return false; + + for (typename fix_seq::const_iterator i = x.begin (); + i != x.end (); ++i) + { + if (!(s << *i)) + return false; + } + + return true; + } + + template + bool + operator<< (oxdrstream& s, const var_seq& x) + { + if (!(s << oxdrstream::as_size (x.size ()))) + return false; + + for (typename var_seq::const_iterator i = x.begin (); + i != x.end (); ++i) + { + if (!(s << *i)) + return false; + } + + return true; + } + +#endif // XSDE_EXCEPTIONS + } + } +} -- cgit v1.1