aboutsummaryrefslogtreecommitdiff
path: root/libxsde/xsde/cxx/hybrid/cdr/istream.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-03-08 17:23:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-03-08 17:23:30 +0200
commit0bce70a0e483294b83b8bf9d5468838a63405612 (patch)
treed11afb4998d6980435c15c4df6e40b1979531672 /libxsde/xsde/cxx/hybrid/cdr/istream.cxx
parent6c63b913179127e09ed7d9da8920493ccceec6ce (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/cdr/istream.cxx')
-rw-r--r--libxsde/xsde/cxx/hybrid/cdr/istream.cxx101
1 files changed, 101 insertions, 0 deletions
diff --git a/libxsde/xsde/cxx/hybrid/cdr/istream.cxx b/libxsde/xsde/cxx/hybrid/cdr/istream.cxx
new file mode 100644
index 0000000..111e668
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/cdr/istream.cxx
@@ -0,0 +1,101 @@
+// file : xsde/cxx/hybrid/cdr/istream.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/cdr/istream.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_EXCEPTIONS
+
+#ifdef XSDE_STL
+ struct str_guard
+ {
+ str_guard (char* s) : s_ (s) {}
+ ~str_guard () {delete[] s_;}
+
+ private:
+ char* s_;
+ };
+
+ void icdrstream::
+ operator>> (std::string& x)
+ {
+ char* v;
+
+ if (!cdr_.read_string (v))
+ throw cdr_exception ();
+
+ str_guard g (v);
+ x = v;
+ }
+#else
+ void icdrstream::
+ operator>> (char*& x)
+ {
+ if (!cdr_.read_string (x))
+ throw cdr_exception ();
+ }
+#endif
+
+ void icdrstream::
+ operator>> (buffer& x)
+ {
+ ACE_CDR::ULong n;
+
+ if (!cdr_.read_ulong (n))
+ throw cdr_exception ();
+
+ x.size (n);
+
+ if (!cdr_.read_octet_array (
+ reinterpret_cast<ACE_CDR::Octet*> (x.data ()), n))
+ throw cdr_exception ();
+ }
+
+#else // XSDE_EXCEPTIONS
+
+#ifdef XSDE_STL
+ bool icdrstream::
+ operator>> (std::string& x)
+ {
+ char* v;
+
+ if (!cdr_.read_string (v))
+ return false;
+
+ x = v;
+ delete[] v;
+ return true;
+ }
+#else
+ bool icdrstream::
+ operator>> (char*& x)
+ {
+ return cdr_.read_string (x);
+ }
+#endif
+
+ bool icdrstream::
+ operator>> (buffer& x)
+ {
+ ACE_CDR::ULong n;
+
+ if (!cdr_.read_ulong (n))
+ return false;
+
+ x.size (n);
+ return cdr_.read_octet_array (
+ reinterpret_cast<ACE_CDR::Octet*> (x.data ()), n);
+ }
+
+#endif // XSDE_EXCEPTIONS
+
+ }
+ }
+}