diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-03-08 17:23:30 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-03-08 17:23:30 +0200 |
commit | 0bce70a0e483294b83b8bf9d5468838a63405612 (patch) | |
tree | d11afb4998d6980435c15c4df6e40b1979531672 /libxsde/xsde/cxx/hybrid/xdr/qname.cxx | |
parent | 6c63b913179127e09ed7d9da8920493ccceec6ce (diff) |
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
Diffstat (limited to 'libxsde/xsde/cxx/hybrid/xdr/qname.cxx')
-rw-r--r-- | libxsde/xsde/cxx/hybrid/xdr/qname.cxx | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/libxsde/xsde/cxx/hybrid/xdr/qname.cxx b/libxsde/xsde/cxx/hybrid/xdr/qname.cxx new file mode 100644 index 0000000..47a6287 --- /dev/null +++ b/libxsde/xsde/cxx/hybrid/xdr/qname.cxx @@ -0,0 +1,74 @@ +// file : xsde/cxx/hybrid/xdr/qname.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/hybrid/xdr/istream.hxx> +#include <xsde/cxx/hybrid/xdr/ostream.hxx> + +namespace xsde +{ + namespace cxx + { + namespace hybrid + { +#ifdef XSDE_EXCEPTIONS + + void + operator<< (oxdrstream& s, const qname& x) + { + s << x.prefix (); + s << x.name (); + } + + void + operator>> (ixdrstream& s, qname& x) + { + +#ifdef XSDE_STL + std::string p, n; +#else + char* p; + char* n; +#endif + s >> p; + x.prefix (p); + + s >> n; // x will free p in case extraction fails + x.name (n); + } + +#else // XSDE_EXCEPTIONS + + bool + operator<< (oxdrstream& s, const qname& x) + { + return s << x.prefix () && s << x.name (); + } + + bool + operator>> (ixdrstream& s, qname& x) + { + +#ifdef XSDE_STL + std::string p, n; +#else + char* p; + char* n; +#endif + if (!(s >> p)) + return false; + + x.prefix (p); + + if (!(s >> n)) + return false; // x will free p + + x.name (n); + return true; + } + +#endif // XSDE_EXCEPTIONS + } + } +} |