diff options
Diffstat (limited to 'libxsde/xsde/cxx/hybrid/cdr')
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/date-time.cxx | 764 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/exceptions.cxx | 21 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/exceptions.hxx | 26 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/istream.cxx | 101 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/istream.hxx | 182 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/istream.ixx | 385 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/istream.txx | 184 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/ostream.cxx | 88 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/ostream.hxx | 182 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/ostream.ixx | 245 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/ostream.txx | 110 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/qname.cxx | 74 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/string-sequence.cxx | 107 |
13 files changed, 2469 insertions, 0 deletions
diff --git a/libxsde/xsde/cxx/hybrid/cdr/date-time.cxx b/libxsde/xsde/cxx/hybrid/cdr/date-time.cxx new file mode 100644 index 0000000..4feaa44 --- /dev/null +++ b/libxsde/xsde/cxx/hybrid/cdr/date-time.cxx @@ -0,0 +1,764 @@ +// file : xsde/cxx/hybrid/cdr/date-time.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> +#include <xsde/cxx/hybrid/cdr/ostream.hxx> + +namespace xsde +{ + namespace cxx + { + namespace hybrid + { +#ifdef XSDE_EXCEPTIONS + + // operator<< + // + + void + operator<< (ocdrstream& s, const time_zone& x) + { + s << x.zone_hours (); + s << x.zone_minutes (); + } + + void + operator<< (ocdrstream& s, const date& x) + { + s << x.year (); + s << x.month (); + s << x.day (); + bool zp = x.zone_present (); + s << zp; + + if (zp) + { + const time_zone& z = x; + s << z; + } + } + + void + operator<< (ocdrstream& s, const date_time& x) + { + s << x.year (); + s << x.month (); + s << x.day (); + s << x.hours (); + s << x.minutes (); + s << x.seconds (); + bool zp = x.zone_present (); + s << zp; + + if (zp) + { + const time_zone& z = x; + s << z; + } + } + + void + operator<< (ocdrstream& s, const duration& x) + { + s << x.negative (); + s << x.years (); + s << x.months (); + s << x.days (); + s << x.hours (); + s << x.minutes (); + s << x.seconds (); + } + + void + operator<< (ocdrstream& s, const gday& x) + { + s << x.day (); + bool zp = x.zone_present (); + s << zp; + + if (zp) + { + const time_zone& z = x; + s << z; + } + } + + void + operator<< (ocdrstream& s, const gmonth& x) + { + s << x.month (); + bool zp = x.zone_present (); + s << zp; + + if (zp) + { + const time_zone& z = x; + s << z; + } + } + + void + operator<< (ocdrstream& s, const gmonth_day& x) + { + s << x.month (); + s << x.day (); + bool zp = x.zone_present (); + s << zp; + + if (zp) + { + const time_zone& z = x; + s << z; + } + } + + void + operator<< (ocdrstream& s, const gyear& x) + { + s << x.year (); + bool zp = x.zone_present (); + s << zp; + + if (zp) + { + const time_zone& z = x; + s << z; + } + } + + void + operator<< (ocdrstream& s, const gyear_month& x) + { + s << x.year (); + s << x.month (); + bool zp = x.zone_present (); + s << zp; + + if (zp) + { + const time_zone& z = x; + s << z; + } + } + + void + operator<< (ocdrstream& s, const time& x) + { + s << x.hours (); + s << x.minutes (); + s << x.seconds (); + bool zp = x.zone_present (); + s << zp; + + if (zp) + { + const time_zone& z = x; + s << z; + } + } + + + // operator>> + // + + void + operator>> (icdrstream& s, time_zone& x) + { + short h, m; + s >> h; + s >> m; + + x.zone_hours (h); + x.zone_minutes (m); + } + + void + operator>> (icdrstream& s, date& x) + { + int y; + unsigned short m, d; + bool zp; + + s >> y; + s >> m; + s >> d; + s >> zp; + + x.year (y); + x.month (m); + x.day (d); + + if (zp) + { + time_zone& z = x; + s >> z; + } + } + + void + operator>> (icdrstream& s, date_time& x) + { + int y; + unsigned short m, d, h, mi; + double se; + bool zp; + + s >> y; + s >> m; + s >> d; + s >> h; + s >> mi; + s >> se; + s >> zp; + + x.year (y); + x.month (m); + x.day (d); + x.hours (h); + x.minutes (mi); + x.seconds (se); + + if (zp) + { + time_zone& z = x; + s >> z; + } + } + + void + operator>> (icdrstream& s, duration& x) + { + bool n; + unsigned int y, m, d, h, mi; + double se; + + s >> n; + s >> y; + s >> m; + s >> d; + s >> h; + s >> mi; + s >> se; + + x.negative (n); + x.years (y); + x.months (m); + x.days (d); + x.hours (h); + x.minutes (mi); + x.seconds (se); + } + + void + operator>> (icdrstream& s, gday& x) + { + unsigned short d; + bool zp; + + s >> d; + s >> zp; + + x.day (d); + + if (zp) + { + time_zone& z = x; + s >> z; + } + } + + void + operator>> (icdrstream& s, gmonth& x) + { + unsigned short m; + bool zp; + + s >> m; + s >> zp; + + x.month (m); + + if (zp) + { + time_zone& z = x; + s >> z; + } + } + + void + operator>> (icdrstream& s, gmonth_day& x) + { + unsigned short d, m; + bool zp; + + s >> d; + s >> m; + s >> zp; + + x.day (d); + x.month (m); + + if (zp) + { + time_zone& z = x; + s >> z; + } + } + + void + operator>> (icdrstream& s, gyear& x) + { + int y; + bool zp; + + s >> y; + s >> zp; + + x.year (y); + + if (zp) + { + time_zone& z = x; + s >> z; + } + } + + void + operator>> (icdrstream& s, gyear_month& x) + { + int y; + unsigned short m; + bool zp; + + s >> y; + s >> m; + s >> zp; + + x.year (y); + x.month (m); + + if (zp) + { + time_zone& z = x; + s >> z; + } + } + + void + operator>> (icdrstream& s, time& x) + { + unsigned short h, m; + double se; + bool zp; + + s >> h; + s >> m; + s >> se; + s >> zp; + + x.hours (h); + x.minutes (m); + x.seconds (se); + + if (zp) + { + time_zone& z = x; + s >> z; + } + } + +#else // XSDE_EXCEPTIONS + + // operator<< + // + + bool + operator<< (ocdrstream& s, const time_zone& x) + { + return s << x.zone_hours () && s << x.zone_minutes (); + } + + bool + operator<< (ocdrstream& s, const date& x) + { + bool zp = x.zone_present (); + + if (!(s << x.year ()) || + !(s << x.month ()) || + !(s << x.day ()) || + !(s << zp)) + return false; + + if (zp) + { + const time_zone& z = x; + return s << z; + } + + return true; + } + + bool + operator<< (ocdrstream& s, const date_time& x) + { + bool zp = x.zone_present (); + + if (!(s << x.year ()) || + !(s << x.month ()) || + !(s << x.day ()) || + !(s << x.hours ()) || + !(s << x.minutes ()) || + !(s << x.seconds ()) || + !(s << zp)) + return false; + + if (zp) + { + const time_zone& z = x; + return s << z; + } + + return true; + } + + bool + operator<< (ocdrstream& s, const duration& x) + { + return s << x.negative () && + s << x.years () && + s << x.months () && + s << x.days () && + s << x.hours () && + s << x.minutes () && + s << x.seconds (); + } + + bool + operator<< (ocdrstream& s, const gday& x) + { + bool zp = x.zone_present (); + + + if (!(s << x.day ()) || !(s << zp)) + return false; + + if (zp) + { + const time_zone& z = x; + return s << z; + } + + return true; + } + + bool + operator<< (ocdrstream& s, const gmonth& x) + { + bool zp = x.zone_present (); + + if (!(s << x.month ()) || !(s << zp)) + return false; + + if (zp) + { + const time_zone& z = x; + return s << z; + } + + return true; + } + + bool + operator<< (ocdrstream& s, const gmonth_day& x) + { + bool zp = x.zone_present (); + + if (!(s << x.month ()) || !(s << x.day ()) || !(s << zp)) + return false; + + if (zp) + { + const time_zone& z = x; + return s << z; + } + + return true; + } + + bool + operator<< (ocdrstream& s, const gyear& x) + { + bool zp = x.zone_present (); + + if (!(s << x.year ()) || !(s << zp)) + return false; + + if (zp) + { + const time_zone& z = x; + return s << z; + } + + return true; + } + + bool + operator<< (ocdrstream& s, const gyear_month& x) + { + bool zp = x.zone_present (); + + if (!(s << x.year ()) || !(s << x.month ()) || !(s << zp)) + return false; + + if (zp) + { + const time_zone& z = x; + return s << z; + } + + return true; + } + + bool + operator<< (ocdrstream& s, const time& x) + { + bool zp = x.zone_present (); + + if (!(s << x.hours ()) || + !(s << x.minutes ()) || + !(s << x.seconds ()) || + !(s << zp)) + return false; + + if (zp) + { + const time_zone& z = x; + return s << z; + } + + return true; + } + + + // operator>> + // + + bool + operator>> (icdrstream& s, time_zone& x) + { + short h, m; + + if (!(s >> h) || !(s >> m)) + return false; + + x.zone_hours (h); + x.zone_minutes (m); + + return true; + } + + bool + operator>> (icdrstream& s, date& x) + { + int y; + unsigned short m, d; + bool zp; + + if (!(s >> y) || !(s >> m) || !(s >> d) || !(s >> zp)) + return false; + + x.year (y); + x.month (m); + x.day (d); + + if (zp) + { + time_zone& z = x; + return s >> z; + } + + return true; + } + + bool + operator>> (icdrstream& s, date_time& x) + { + int y; + unsigned short m, d, h, mi; + double se; + bool zp; + + if (!(s >> y) || !(s >> m) || !(s >> d) || + !(s >> h) || !(s >> mi) || !(s >> se) || !(s >> zp)) + return false; + + x.year (y); + x.month (m); + x.day (d); + x.hours (h); + x.minutes (mi); + x.seconds (se); + + if (zp) + { + time_zone& z = x; + return s >> z; + } + + return true; + } + + bool + operator>> (icdrstream& s, duration& x) + { + bool n; + unsigned int y, m, d, h, mi; + double se; + + if (!(s >> n) || !(s >> y) || !(s >> m) || !(s >> d) || + !(s >> h) || !(s >> mi) || !(s >> se)) + return false; + + x.negative (n); + x.years (y); + x.months (m); + x.days (d); + x.hours (h); + x.minutes (mi); + x.seconds (se); + + return true; + } + + bool + operator>> (icdrstream& s, gday& x) + { + unsigned short d; + bool zp; + + if (!(s >> d) || !(s >> zp)) + return false; + + x.day (d); + + if (zp) + { + time_zone& z = x; + return s >> z; + } + + return true; + } + + bool + operator>> (icdrstream& s, gmonth& x) + { + unsigned short m; + bool zp; + + if (!(s >> m) || !(s >> zp)) + return false; + + x.month (m); + + if (zp) + { + time_zone& z = x; + return s >> z; + } + + return true; + } + + bool + operator>> (icdrstream& s, gmonth_day& x) + { + unsigned short d, m; + bool zp; + + if (!(s >> d) || !(s >> m) || !(s >> zp)) + return false; + + x.day (d); + x.month (m); + + if (zp) + { + time_zone& z = x; + return s >> z; + } + + return true; + } + + bool + operator>> (icdrstream& s, gyear& x) + { + int y; + bool zp; + + if (!(s >> y) || !(s >> zp)) + return false; + + x.year (y); + + if (zp) + { + time_zone& z = x; + return s >> z; + } + + return true; + } + + bool + operator>> (icdrstream& s, gyear_month& x) + { + int y; + unsigned short m; + bool zp; + + if (!(s >> y) || !(s >> m) || !(s >> zp)) + return false; + + x.year (y); + x.month (m); + + if (zp) + { + time_zone& z = x; + return s >> z; + } + + return true; + } + + bool + operator>> (icdrstream& s, time& x) + { + unsigned short h, m; + double se; + bool zp; + + if (!(s >> h) || !(s >> m) || !(s >> se) || !(s >> zp)) + return false; + + x.hours (h); + x.minutes (m); + x.seconds (se); + + if (zp) + { + time_zone& z = x; + return s >> z; + } + + return true; + } + +#endif // XSDE_EXCEPTIONS + } + } +} diff --git a/libxsde/xsde/cxx/hybrid/cdr/exceptions.cxx b/libxsde/xsde/cxx/hybrid/cdr/exceptions.cxx new file mode 100644 index 0000000..8b79805 --- /dev/null +++ b/libxsde/xsde/cxx/hybrid/cdr/exceptions.cxx @@ -0,0 +1,21 @@ +// file : xsde/cxx/hybrid/cdr/exceptions.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/exceptions.hxx> + +namespace xsde +{ + namespace cxx + { + namespace hybrid + { + const char* cdr_exception:: + what () const throw () + { + return "CDR stream operation failed"; + } + } + } +} diff --git a/libxsde/xsde/cxx/hybrid/cdr/exceptions.hxx b/libxsde/xsde/cxx/hybrid/cdr/exceptions.hxx new file mode 100644 index 0000000..bc0b861 --- /dev/null +++ b/libxsde/xsde/cxx/hybrid/cdr/exceptions.hxx @@ -0,0 +1,26 @@ +// file : xsde/cxx/hybrid/cdr/exceptions.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_HYBRID_CDR_EXCEPTIONS_HXX +#define XSDE_CXX_HYBRID_CDR_EXCEPTIONS_HXX + +#include <xsde/cxx/exceptions.hxx> + +namespace xsde +{ + namespace cxx + { + namespace hybrid + { + struct cdr_exception: xsde::cxx::exception + { + virtual const char* + what () const throw (); + }; + } + } +} + +#endif // XSDE_CXX_HYBRID_CDR_EXCEPTIONS_HXX 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 + + } + } +} diff --git a/libxsde/xsde/cxx/hybrid/cdr/istream.hxx b/libxsde/xsde/cxx/hybrid/cdr/istream.hxx new file mode 100644 index 0000000..484010b --- /dev/null +++ b/libxsde/xsde/cxx/hybrid/cdr/istream.hxx @@ -0,0 +1,182 @@ +// file : xsde/cxx/hybrid/cdr/istream.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_HYBRID_CDR_ISTREAM_HXX +#define XSDE_CXX_HYBRID_CDR_ISTREAM_HXX + +#include <xsde/cxx/config.hxx> + +#include <stddef.h> // size_t + +#ifdef XSDE_STL +# include <string> +#endif + +#include <ace/CDR_Stream.h> + +#include <xsde/cxx/buffer.hxx> +#include <xsde/cxx/date-time.hxx> + +#ifdef XSDE_STL +# include <xsde/cxx/qname-stl.hxx> +# include <xsde/cxx/string-sequence-stl.hxx> +#else +# include <xsde/cxx/qname.hxx> +# include <xsde/cxx/string-sequence.hxx> +#endif + +#include <xsde/cxx/hybrid/any-type.hxx> +#include <xsde/cxx/hybrid/sequence.hxx> + +#ifdef XSDE_EXCEPTIONS +# include <xsde/cxx/hybrid/cdr/exceptions.hxx> +#endif + +namespace xsde +{ + namespace cxx + { + namespace hybrid + { + class icdrstream + { + public: + explicit + icdrstream (ACE_InputCDR& cdr); + + ACE_InputCDR& + impl (); + + public: + struct as_size + { + explicit as_size (size_t& s) : s_ (s) {} + size_t& s_; + }; + + public: +#ifdef XSDE_EXCEPTIONS + + void operator>> (bool&); + void operator>> (signed char&); + void operator>> (unsigned char&); + void operator>> (short&); + void operator>> (unsigned short&); + void operator>> (int&); + void operator>> (unsigned int&); + void operator>> (long&); + void operator>> (unsigned long&); + +#ifdef XSDE_LONGLONG + void operator>> (long long&); + void operator>> (unsigned long long&); +#endif + void operator>> (as_size&); + void operator>> (float&); + void operator>> (double&); + +#ifdef XSDE_STL + void operator>> (std::string&); +#else + void operator>> (char*&); +#endif + void operator>> (buffer&); + +#else // XSDE_EXCEPTIONS + + bool operator>> (bool&); + bool operator>> (signed char&); + bool operator>> (unsigned char&); + bool operator>> (short&); + bool operator>> (unsigned short&); + bool operator>> (int&); + bool operator>> (unsigned int&); + bool operator>> (long&); + bool operator>> (unsigned long&); + +#ifdef XSDE_LONGLONG + bool operator>> (long long&); + bool operator>> (unsigned long long&); +#endif + bool operator>> (as_size&); + bool operator>> (float&); + bool operator>> (double&); + +#ifdef XSDE_STL + bool operator>> (std::string&); +#else + bool operator>> (char*&); +#endif + bool operator>> (buffer&); + +#endif // XSDE_EXCEPTIONS + + private: + icdrstream (const icdrstream&); + icdrstream& operator= (const icdrstream&); + + private: + ACE_InputCDR& cdr_; + }; + +#ifdef XSDE_EXCEPTIONS + void operator>> (icdrstream&, any_type&); + void operator>> (icdrstream&, any_simple_type&); + void operator>> (icdrstream&, qname&); + void operator>> (icdrstream&, string_sequence&); + void operator>> (icdrstream&, time_zone&); + void operator>> (icdrstream&, date&); + void operator>> (icdrstream&, date_time&); + void operator>> (icdrstream&, duration&); + void operator>> (icdrstream&, gday&); + void operator>> (icdrstream&, gmonth&); + void operator>> (icdrstream&, gmonth_day&); + void operator>> (icdrstream&, gyear&); + void operator>> (icdrstream&, gyear_month&); + void operator>> (icdrstream&, time&); +#else + bool operator>> (icdrstream&, any_type&); + bool operator>> (icdrstream&, any_simple_type&); + bool operator>> (icdrstream&, qname&); + bool operator>> (icdrstream&, string_sequence&); + bool operator>> (icdrstream&, time_zone&); + bool operator>> (icdrstream&, date&); + bool operator>> (icdrstream&, date_time&); + bool operator>> (icdrstream&, duration&); + bool operator>> (icdrstream&, gday&); + bool operator>> (icdrstream&, gmonth&); + bool operator>> (icdrstream&, gmonth_day&); + bool operator>> (icdrstream&, gyear&); + bool operator>> (icdrstream&, gyear_month&); + bool operator>> (icdrstream&, time&); +#endif + +#ifdef XSDE_EXCEPTIONS + template <typename T> + void operator>> (icdrstream&, pod_seq<T>&); + + template <typename T> + void operator>> (icdrstream&, fix_seq<T>&); + + template <typename T> + void operator>> (icdrstream&, var_seq<T>&); +#else + template <typename T> + bool operator>> (icdrstream&, pod_seq<T>&); + + template <typename T> + bool operator>> (icdrstream&, fix_seq<T>&); + + template <typename T> + bool operator>> (icdrstream&, var_seq<T>&); +#endif + } + } +} + +#include <xsde/cxx/hybrid/cdr/istream.ixx> +#include <xsde/cxx/hybrid/cdr/istream.txx> + +#endif // XSDE_CXX_HYBRID_CDR_ISTREAM_HXX diff --git a/libxsde/xsde/cxx/hybrid/cdr/istream.ixx b/libxsde/xsde/cxx/hybrid/cdr/istream.ixx new file mode 100644 index 0000000..36d67dd --- /dev/null +++ b/libxsde/xsde/cxx/hybrid/cdr/istream.ixx @@ -0,0 +1,385 @@ +// file : xsde/cxx/hybrid/cdr/istream.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace hybrid + { + inline icdrstream:: + icdrstream (ACE_InputCDR& cdr) + : cdr_ (cdr) + { + } + + inline ACE_InputCDR& icdrstream:: + impl () + { + return cdr_; + } + +#ifdef XSDE_EXCEPTIONS + + inline void icdrstream:: + operator>> (bool& x) + { + ACE_CDR::Boolean v; + + if (!cdr_.read_boolean (v)) + throw cdr_exception (); + + x = static_cast<bool> (v); + } + + inline void icdrstream:: + operator>> (signed char& x) + { + ACE_CDR::Octet v; + + if (!cdr_.read_octet (v)) + throw cdr_exception (); + + x = static_cast<signed char> (v); + } + + + inline void icdrstream:: + operator>> (unsigned char& x) + { + ACE_CDR::Octet v; + + if (!cdr_.read_octet (v)) + throw cdr_exception (); + + x = static_cast<unsigned char> (v); + } + + inline void icdrstream:: + operator>> (short& x) + { + ACE_CDR::Short v; + + if (!cdr_.read_short (v)) + throw cdr_exception (); + + x = static_cast<short> (v); + } + + inline void icdrstream:: + operator>> (unsigned short& x) + { + ACE_CDR::UShort v; + + if (!cdr_.read_ushort (v)) + throw cdr_exception (); + + x = static_cast<unsigned short> (v); + } + + inline void icdrstream:: + operator>> (int& x) + { + ACE_CDR::Long v; + + if (!cdr_.read_long (v)) + throw cdr_exception (); + + x = static_cast<int> (v); + } + + inline void icdrstream:: + operator>> (unsigned int& x) + { + ACE_CDR::ULong v; + + if (!cdr_.read_ulong (v)) + throw cdr_exception (); + + x = static_cast<unsigned int> (v); + } + + inline void icdrstream:: + operator>> (long& x) + { + ACE_CDR::Long v; + + if (!cdr_.read_long (v)) + throw cdr_exception (); + + x = static_cast<long> (v); + } + + inline void icdrstream:: + operator>> (unsigned long& x) + { + ACE_CDR::ULong v; + + if (!cdr_.read_ulong (v)) + throw cdr_exception (); + + x = static_cast<unsigned long> (v); + } + +#ifdef XSDE_LONGLONG + inline void icdrstream:: + operator>> (long long& x) + { + ACE_CDR::LongLong v; + + if (!cdr_.read_longlong (v)) + throw cdr_exception (); + + x = static_cast<long long> (v); + } + + inline void icdrstream:: + operator>> (unsigned long long& x) + { + ACE_CDR::ULongLong v; + + if (!cdr_.read_ulonglong (v)) + throw cdr_exception (); + + x = static_cast<unsigned long long> (v); + } +#endif + + inline void icdrstream:: + operator>> (as_size& x) + { + // Assume size is 32-bit. + // + ACE_CDR::ULong v; + + if (!cdr_.read_ulong (v)) + throw cdr_exception (); + + x.s_ = static_cast<size_t> (v); + } + + inline void icdrstream:: + operator>> (float& x) + { + ACE_CDR::Float v; + + if (!cdr_.read_float (v)) + throw cdr_exception (); + + x = static_cast<float> (v); + } + + inline void icdrstream:: + operator>> (double& x) + { + ACE_CDR::Double v; + + if (!cdr_.read_double (v)) + throw cdr_exception (); + + x = static_cast<double> (v); + } + + inline void + operator>> (icdrstream&, any_type&) + { + } + + inline void + operator>> (icdrstream&, any_simple_type&) + { + } + +#else // XSDE_EXCEPTIONS + + inline bool icdrstream:: + operator>> (bool& x) + { + ACE_CDR::Boolean v; + + if (!cdr_.read_boolean (v)) + return false; + + x = static_cast<bool> (v); + return true; + } + + inline bool icdrstream:: + operator>> (signed char& x) + { + ACE_CDR::Octet v; + + if (!cdr_.read_octet (v)) + return false; + + x = static_cast<signed char> (v); + return true; + } + + + inline bool icdrstream:: + operator>> (unsigned char& x) + { + ACE_CDR::Octet v; + + if (!cdr_.read_octet (v)) + return false; + + x = static_cast<unsigned char> (v); + return true; + } + + inline bool icdrstream:: + operator>> (short& x) + { + ACE_CDR::Short v; + + if (!cdr_.read_short (v)) + return false; + + x = static_cast<short> (v); + return true; + } + + inline bool icdrstream:: + operator>> (unsigned short& x) + { + ACE_CDR::UShort v; + + if (!cdr_.read_ushort (v)) + return false; + + x = static_cast<unsigned short> (v); + return true; + } + + inline bool icdrstream:: + operator>> (int& x) + { + ACE_CDR::Long v; + + if (!cdr_.read_long (v)) + return false; + + x = static_cast<int> (v); + return true; + } + + inline bool icdrstream:: + operator>> (unsigned int& x) + { + ACE_CDR::ULong v; + + if (!cdr_.read_ulong (v)) + return false; + + x = static_cast<unsigned int> (v); + return true; + } + + inline bool icdrstream:: + operator>> (long& x) + { + ACE_CDR::Long v; + + if (!cdr_.read_long (v)) + return false; + + x = static_cast<long> (v); + return true; + } + + inline bool icdrstream:: + operator>> (unsigned long& x) + { + ACE_CDR::ULong v; + + if (!cdr_.read_ulong (v)) + return false; + + x = static_cast<unsigned long> (v); + return true; + } + +#ifdef XSDE_LONGLONG + inline bool icdrstream:: + operator>> (long long& x) + { + ACE_CDR::LongLong v; + + if (!cdr_.read_longlong (v)) + return false; + + x = static_cast<long long> (v); + return true; + } + + inline bool icdrstream:: + operator>> (unsigned long long& x) + { + ACE_CDR::ULongLong v; + + if (!cdr_.read_ulonglong (v)) + return false; + + x = static_cast<unsigned long long> (v); + return true; + } +#endif + + inline bool icdrstream:: + operator>> (as_size& x) + { + // Assume size is 32-bit. + // + ACE_CDR::ULong v; + + if (!cdr_.read_ulong (v)) + return false; + + x.s_ = static_cast<size_t> (v); + return true; + } + + inline bool icdrstream:: + operator>> (float& x) + { + ACE_CDR::Float v; + + if (!cdr_.read_float (v)) + return false; + + x = static_cast<float> (v); + return true; + } + + inline bool icdrstream:: + operator>> (double& x) + { + ACE_CDR::Double v; + + if (!cdr_.read_double (v)) + return false; + + x = static_cast<double> (v); + return true; + } + + inline bool + operator>> (icdrstream&, any_type&) + { + return true; + } + + inline bool + operator>> (icdrstream&, any_simple_type&) + { + return true; + } + +#endif // XSDE_EXCEPTIONS + } + } +} diff --git a/libxsde/xsde/cxx/hybrid/cdr/istream.txx b/libxsde/xsde/cxx/hybrid/cdr/istream.txx new file mode 100644 index 0000000..9afc5f5 --- /dev/null +++ b/libxsde/xsde/cxx/hybrid/cdr/istream.txx @@ -0,0 +1,184 @@ +// file : xsde/cxx/hybrid/cdr/istream.txx +// author : Boris Kolpackov <boris@codesynthesis.com> +// 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 <typename T> + void + operator>> (icdrstream& s, pod_seq<T>& x) + { + size_t n; + icdrstream::as_size as_size (n); + s >> as_size; + + x.clear (); + + if (n > 0) + { + x.reserve (n); + + T i; + while (n--) + { + s >> i; + x.push_back (i); + } + } + } + + template <typename T> + void + operator>> (icdrstream& s, fix_seq<T>& x) + { + size_t n; + icdrstream::as_size as_size (n); + s >> as_size; + + x.clear (); + + if (n > 0) + { + x.reserve (n); + + while (n--) + { + T i; + s >> i; + x.push_back (i); + } + } + } + + template <typename T> + void + operator>> (icdrstream& s, var_seq<T>& x) + { + size_t n; + icdrstream::as_size as_size (n); + s >> as_size; + + x.clear (); + + if (n > 0) + { + x.reserve (n); + + while (n--) + { + T* p = new T; + typename var_seq<T>::guard g (p); + s >> *p; + g.release (); + x.push_back (p); + } + } + } + +#else // XSDE_EXCEPTIONS + + template <typename T> + bool + operator>> (icdrstream& s, pod_seq<T>& x) + { + size_t n; + icdrstream::as_size as_size (n); + + if (!(s >> as_size)) + return false; + + x.clear (); + + if (n > 0) + { + if (x.reserve (n)) + return false; + + T i; + while (n--) + { + if (!(s >> i) || x.push_back (i)) + return false; + } + } + + return true; + } + + template <typename T> + bool + operator>> (icdrstream& s, fix_seq<T>& x) + { + size_t n; + icdrstream::as_size as_size (n); + + if (!(s >> as_size)) + return false; + + x.clear (); + + if (n > 0) + { + if (x.reserve (n)) + return false; + + while (n--) + { + T i; + if (!(s >> i) || x.push_back (i)) + return false; + } + } + + return true; + } + + template <typename T> + bool + operator>> (icdrstream& s, var_seq<T>& x) + { + size_t n; + icdrstream::as_size as_size (n); + + if (!(s >> as_size)) + return false; + + x.clear (); + + if (n > 0) + { + if (x.reserve (n)) + return false; + + while (n--) + { + T* p = new T; + + if (p == 0) + return false; + + if (!(s >> *p)) + { + delete p; + return false; + } + + if (x.push_back (p)) + return false; + } + } + + return true; + } + +#endif // XSDE_EXCEPTIONS + } + } +} diff --git a/libxsde/xsde/cxx/hybrid/cdr/ostream.cxx b/libxsde/xsde/cxx/hybrid/cdr/ostream.cxx new file mode 100644 index 0000000..e72e5fd --- /dev/null +++ b/libxsde/xsde/cxx/hybrid/cdr/ostream.cxx @@ -0,0 +1,88 @@ +// file : xsde/cxx/hybrid/cdr/ostream.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/config.hxx> + +#ifndef XSDE_STL +# include <string.h> +#endif + +#include <xsde/cxx/hybrid/cdr/ostream.hxx> + +namespace xsde +{ + namespace cxx + { + namespace hybrid + { +#ifdef XSDE_EXCEPTIONS + + // CDR strings always use 32-bit length. + // +#ifdef XSDE_STL + void ocdrstream:: + operator<< (const std::string& x) + { + if (!cdr_.write_string ( + static_cast<ACE_CDR::ULong> (x.length ()), x.c_str ())) + throw cdr_exception (); + } +#else + void ocdrstream:: + operator<< (const char* x) + { + if (!cdr_.write_string (static_cast<ACE_CDR::ULong> (strlen (x)), x)) + throw cdr_exception (); + } +#endif + + void ocdrstream:: + operator<< (const buffer& x) + { + // CDR arrays are limited to 32-bit size. + // + size_t n = x.size (); + + if (!cdr_.write_ulong (static_cast<ACE_CDR::ULong> (n)) || + !cdr_.write_octet_array ( + reinterpret_cast<const ACE_CDR::Octet*> (x.data ()), n)) + throw cdr_exception (); + } + +#else // XSDE_EXCEPTIONS + +#ifdef XSDE_STL + bool ocdrstream:: + operator<< (const std::string& x) + { + return cdr_.write_string ( + static_cast<ACE_CDR::ULong> (x.length ()), x.c_str ()); + } +#else + bool ocdrstream:: + operator<< (const char* x) + { + return cdr_.write_string ( + static_cast<ACE_CDR::ULong> (strlen (x)), x); + } +#endif + + bool ocdrstream:: + operator<< (const buffer& x) + { + // CDR arrays are limited to 32-bit size. + // + size_t n = x.size (); + + return cdr_.write_ulong (static_cast<ACE_CDR::ULong> (n)) && + cdr_.write_octet_array ( + reinterpret_cast<const ACE_CDR::Octet*> (x.data ()), n); + } + +#endif // XSDE_EXCEPTIONS + + } + } +} diff --git a/libxsde/xsde/cxx/hybrid/cdr/ostream.hxx b/libxsde/xsde/cxx/hybrid/cdr/ostream.hxx new file mode 100644 index 0000000..6b33fe0 --- /dev/null +++ b/libxsde/xsde/cxx/hybrid/cdr/ostream.hxx @@ -0,0 +1,182 @@ +// file : xsde/cxx/hybrid/cdr/ostream.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_HYBRID_CDR_OSTREAM_HXX +#define XSDE_CXX_HYBRID_CDR_OSTREAM_HXX + +#include <xsde/cxx/config.hxx> + +#include <stddef.h> // size_t + +#ifdef XSDE_STL +# include <string> +#endif + +#include <ace/CDR_Stream.h> + +#include <xsde/cxx/buffer.hxx> +#include <xsde/cxx/date-time.hxx> + +#ifdef XSDE_STL +# include <xsde/cxx/qname-stl.hxx> +# include <xsde/cxx/string-sequence-stl.hxx> +#else +# include <xsde/cxx/qname.hxx> +# include <xsde/cxx/string-sequence.hxx> +#endif + +#include <xsde/cxx/hybrid/any-type.hxx> +#include <xsde/cxx/hybrid/sequence.hxx> + +#ifdef XSDE_EXCEPTIONS +# include <xsde/cxx/hybrid/cdr/exceptions.hxx> +#endif + +namespace xsde +{ + namespace cxx + { + namespace hybrid + { + class ocdrstream + { + public: + explicit + ocdrstream (ACE_OutputCDR& cdr); + + ACE_OutputCDR& + impl (); + + public: + struct as_size + { + explicit as_size (size_t s) : s_ (s) {} + size_t s_; + }; + + public: +#ifdef XSDE_EXCEPTIONS + + void operator<< (bool); + void operator<< (signed char); + void operator<< (unsigned char); + void operator<< (short); + void operator<< (unsigned short); + void operator<< (int); + void operator<< (unsigned int); + void operator<< (long); + void operator<< (unsigned long); + +#ifdef XSDE_LONGLONG + void operator<< (long long); + void operator<< (unsigned long long); +#endif + void operator<< (as_size); + void operator<< (float); + void operator<< (double); + +#ifdef XSDE_STL + void operator<< (const std::string&); +#else + void operator<< (const char*); +#endif + void operator<< (const buffer&); + +#else // XSDE_EXCEPTIONS + + bool operator<< (bool); + bool operator<< (signed char); + bool operator<< (unsigned char); + bool operator<< (short); + bool operator<< (unsigned short); + bool operator<< (int); + bool operator<< (unsigned int); + bool operator<< (long); + bool operator<< (unsigned long); + +#ifdef XSDE_LONGLONG + bool operator<< (long long); + bool operator<< (unsigned long long); +#endif + bool operator<< (as_size); + bool operator<< (float); + bool operator<< (double); + +#ifdef XSDE_STL + bool operator<< (const std::string&); +#else + bool operator<< (const char*); +#endif + bool operator<< (const buffer&); + +#endif // XSDE_EXCEPTIONS + + private: + ocdrstream (const ocdrstream&); + ocdrstream& operator= (const ocdrstream&); + + private: + ACE_OutputCDR& cdr_; + }; + +#ifdef XSDE_EXCEPTIONS + void operator<< (ocdrstream&, const any_type&); + void operator<< (ocdrstream&, const any_simple_type&); + void operator<< (ocdrstream&, const qname&); + void operator<< (ocdrstream&, const string_sequence&); + void operator<< (ocdrstream&, const time_zone&); + void operator<< (ocdrstream&, const date&); + void operator<< (ocdrstream&, const date_time&); + void operator<< (ocdrstream&, const duration&); + void operator<< (ocdrstream&, const gday&); + void operator<< (ocdrstream&, const gmonth&); + void operator<< (ocdrstream&, const gmonth_day&); + void operator<< (ocdrstream&, const gyear&); + void operator<< (ocdrstream&, const gyear_month&); + void operator<< (ocdrstream&, const time&); +#else + bool operator<< (ocdrstream&, const any_type&); + bool operator<< (ocdrstream&, const any_simple_type&); + bool operator<< (ocdrstream&, const qname&); + bool operator<< (ocdrstream&, const string_sequence&); + bool operator<< (ocdrstream&, const time_zone&); + bool operator<< (ocdrstream&, const date&); + bool operator<< (ocdrstream&, const date_time&); + bool operator<< (ocdrstream&, const duration&); + bool operator<< (ocdrstream&, const gday&); + bool operator<< (ocdrstream&, const gmonth&); + bool operator<< (ocdrstream&, const gmonth_day&); + bool operator<< (ocdrstream&, const gyear&); + bool operator<< (ocdrstream&, const gyear_month&); + bool operator<< (ocdrstream&, const time&); +#endif + +#ifdef XSDE_EXCEPTIONS + template <typename T> + void operator<< (ocdrstream&, const pod_seq<T>&); + + template <typename T> + void operator<< (ocdrstream&, const fix_seq<T>&); + + template <typename T> + void operator<< (ocdrstream&, const var_seq<T>&); +#else + template <typename T> + bool operator<< (ocdrstream&, const pod_seq<T>&); + + template <typename T> + bool operator<< (ocdrstream&, const fix_seq<T>&); + + template <typename T> + bool operator<< (ocdrstream&, const var_seq<T>&); +#endif + } + } +} + +#include <xsde/cxx/hybrid/cdr/ostream.ixx> +#include <xsde/cxx/hybrid/cdr/ostream.txx> + +#endif // XSDE_CXX_HYBRID_CDR_OSTREAM_HXX diff --git a/libxsde/xsde/cxx/hybrid/cdr/ostream.ixx b/libxsde/xsde/cxx/hybrid/cdr/ostream.ixx new file mode 100644 index 0000000..272c5dd --- /dev/null +++ b/libxsde/xsde/cxx/hybrid/cdr/ostream.ixx @@ -0,0 +1,245 @@ +// file : xsde/cxx/hybrid/cdr/ostream.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace hybrid + { + inline ocdrstream:: + ocdrstream (ACE_OutputCDR& cdr) + : cdr_ (cdr) + { + } + + inline ACE_OutputCDR& ocdrstream:: + impl () + { + return cdr_; + } + +#ifdef XSDE_EXCEPTIONS + + inline void ocdrstream:: + operator<< (bool x) + { + if (!cdr_.write_boolean (static_cast<ACE_CDR::Boolean> (x))) + throw cdr_exception (); + } + + inline void ocdrstream:: + operator<< (signed char x) + { + if (!cdr_.write_octet (static_cast<ACE_CDR::Octet> (x))) + throw cdr_exception (); + } + + + inline void ocdrstream:: + operator<< (unsigned char x) + { + if (!cdr_.write_octet (static_cast<ACE_CDR::Octet> (x))) + throw cdr_exception (); + } + + inline void ocdrstream:: + operator<< (short x) + { + if (!cdr_.write_short (static_cast<ACE_CDR::Short> (x))) + throw cdr_exception (); + } + + inline void ocdrstream:: + operator<< (unsigned short x) + { + if (!cdr_.write_ushort (static_cast<ACE_CDR::UShort> (x))) + throw cdr_exception (); + } + + inline void ocdrstream:: + operator<< (int x) + { + if (!cdr_.write_long (static_cast<ACE_CDR::Long> (x))) + throw cdr_exception (); + } + + inline void ocdrstream:: + operator<< (unsigned int x) + { + if (!cdr_.write_ulong (static_cast<ACE_CDR::ULong> (x))) + throw cdr_exception (); + } + + inline void ocdrstream:: + operator<< (long x) + { + if (!cdr_.write_long (static_cast<ACE_CDR::Long> (x))) + throw cdr_exception (); + } + + inline void ocdrstream:: + operator<< (unsigned long x) + { + if (!cdr_.write_ulong (static_cast<ACE_CDR::ULong> (x))) + throw cdr_exception (); + } + +#ifdef XSDE_LONGLONG + inline void ocdrstream:: + operator<< (long long x) + { + if (!cdr_.write_longlong (static_cast<ACE_CDR::LongLong> (x))) + throw cdr_exception (); + } + + inline void ocdrstream:: + operator<< (unsigned long long x) + { + if (!cdr_.write_ulonglong (static_cast<ACE_CDR::ULongLong> (x))) + throw cdr_exception (); + } +#endif + + inline void ocdrstream:: + operator<< (as_size x) + { + // Assume size is 32-bit. + // + if (!cdr_.write_ulong (static_cast<ACE_CDR::ULong> (x.s_))) + throw cdr_exception (); + } + + inline void ocdrstream:: + operator<< (float x) + { + if (!cdr_.write_float (static_cast<ACE_CDR::Float> (x))) + throw cdr_exception (); + } + + inline void ocdrstream:: + operator<< (double x) + { + if (!cdr_.write_double (static_cast<ACE_CDR::Double> (x))) + throw cdr_exception (); + } + + inline void + operator<< (ocdrstream&, const any_type&) + { + } + + inline void + operator<< (ocdrstream&, const any_simple_type&) + { + } + +#else // XSDE_EXCEPTIONS + + inline bool ocdrstream:: + operator<< (bool x) + { + return cdr_.write_boolean (static_cast<ACE_CDR::Boolean> (x)); + } + + inline bool ocdrstream:: + operator<< (signed char x) + { + return cdr_.write_octet (static_cast<ACE_CDR::Octet> (x)); + } + + + inline bool ocdrstream:: + operator<< (unsigned char x) + { + return cdr_.write_octet (static_cast<ACE_CDR::Octet> (x)); + } + + inline bool ocdrstream:: + operator<< (short x) + { + return cdr_.write_short (static_cast<ACE_CDR::Short> (x)); + } + + inline bool ocdrstream:: + operator<< (unsigned short x) + { + return cdr_.write_ushort (static_cast<ACE_CDR::UShort> (x)); + } + + inline bool ocdrstream:: + operator<< (int x) + { + return cdr_.write_long (static_cast<ACE_CDR::Long> (x)); + } + + inline bool ocdrstream:: + operator<< (unsigned int x) + { + return cdr_.write_ulong (static_cast<ACE_CDR::ULong> (x)); + } + + inline bool ocdrstream:: + operator<< (long x) + { + return cdr_.write_long (static_cast<ACE_CDR::Long> (x)); + } + + inline bool ocdrstream:: + operator<< (unsigned long x) + { + return cdr_.write_ulong (static_cast<ACE_CDR::ULong> (x)); + } + +#ifdef XSDE_LONGLONG + inline bool ocdrstream:: + operator<< (long long x) + { + return cdr_.write_longlong (static_cast<ACE_CDR::LongLong> (x)); + } + + inline bool ocdrstream:: + operator<< (unsigned long long x) + { + return cdr_.write_ulonglong (static_cast<ACE_CDR::ULongLong> (x)); + } +#endif + + inline bool ocdrstream:: + operator<< (as_size x) + { + // Assume size is 32-bit. + // + return cdr_.write_ulong (static_cast<ACE_CDR::ULong> (x.s_)); + } + + inline bool ocdrstream:: + operator<< (float x) + { + return cdr_.write_float (static_cast<ACE_CDR::Float> (x)); + } + + inline bool ocdrstream:: + operator<< (double x) + { + return cdr_.write_double (static_cast<ACE_CDR::Double> (x)); + } + + inline bool + operator<< (ocdrstream&, const any_type&) + { + return true; + } + + inline bool + operator<< (ocdrstream&, const any_simple_type&) + { + return true; + } + +#endif // XSDE_EXCEPTIONS + } + } +} diff --git a/libxsde/xsde/cxx/hybrid/cdr/ostream.txx b/libxsde/xsde/cxx/hybrid/cdr/ostream.txx new file mode 100644 index 0000000..1dd40df --- /dev/null +++ b/libxsde/xsde/cxx/hybrid/cdr/ostream.txx @@ -0,0 +1,110 @@ +// file : xsde/cxx/hybrid/cdr/ostream.txx +// author : Boris Kolpackov <boris@codesynthesis.com> +// 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 <typename T> + void + operator<< (ocdrstream& s, const pod_seq<T>& x) + { + s << ocdrstream::as_size (x.size ()); + + for (typename pod_seq<T>::const_iterator i = x.begin (); + i != x.end (); ++i) + { + s << *i; + } + } + + template <typename T> + void + operator<< (ocdrstream& s, const fix_seq<T>& x) + { + s << ocdrstream::as_size (x.size ()); + + for (typename fix_seq<T>::const_iterator i = x.begin (); + i != x.end (); ++i) + { + s << *i; + } + } + + template <typename T> + void + operator<< (ocdrstream& s, const var_seq<T>& x) + { + s << ocdrstream::as_size (x.size ()); + + for (typename var_seq<T>::const_iterator i = x.begin (); + i != x.end (); ++i) + { + s << *i; + } + } + +#else // XSDE_EXCEPTIONS + + template <typename T> + bool + operator<< (ocdrstream& s, const pod_seq<T>& x) + { + if (!(s << ocdrstream::as_size (x.size ()))) + return false; + + for (typename pod_seq<T>::const_iterator i = x.begin (); + i != x.end (); ++i) + { + if (!(s << *i)) + return false; + } + + return true; + } + + template <typename T> + bool + operator<< (ocdrstream& s, const fix_seq<T>& x) + { + if (!(s << ocdrstream::as_size (x.size ()))) + return false; + + for (typename fix_seq<T>::const_iterator i = x.begin (); + i != x.end (); ++i) + { + if (!(s << *i)) + return false; + } + + return true; + } + + template <typename T> + bool + operator<< (ocdrstream& s, const var_seq<T>& x) + { + if (!(s << ocdrstream::as_size (x.size ()))) + return false; + + for (typename var_seq<T>::const_iterator i = x.begin (); + i != x.end (); ++i) + { + if (!(s << *i)) + return false; + } + + return true; + } + +#endif // XSDE_EXCEPTIONS + } + } +} diff --git a/libxsde/xsde/cxx/hybrid/cdr/qname.cxx b/libxsde/xsde/cxx/hybrid/cdr/qname.cxx new file mode 100644 index 0000000..396d70b --- /dev/null +++ b/libxsde/xsde/cxx/hybrid/cdr/qname.cxx @@ -0,0 +1,74 @@ +// file : xsde/cxx/hybrid/cdr/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/cdr/istream.hxx> +#include <xsde/cxx/hybrid/cdr/ostream.hxx> + +namespace xsde +{ + namespace cxx + { + namespace hybrid + { +#ifdef XSDE_EXCEPTIONS + + void + operator<< (ocdrstream& s, const qname& x) + { + s << x.prefix (); + s << x.name (); + } + + void + operator>> (icdrstream& 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<< (ocdrstream& s, const qname& x) + { + return s << x.prefix () && s << x.name (); + } + + bool + operator>> (icdrstream& 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 + } + } +} diff --git a/libxsde/xsde/cxx/hybrid/cdr/string-sequence.cxx b/libxsde/xsde/cxx/hybrid/cdr/string-sequence.cxx new file mode 100644 index 0000000..5ba29f2 --- /dev/null +++ b/libxsde/xsde/cxx/hybrid/cdr/string-sequence.cxx @@ -0,0 +1,107 @@ +// file : xsde/cxx/hybrid/cdr/string-sequence.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> +#include <xsde/cxx/hybrid/cdr/ostream.hxx> + +namespace xsde +{ + namespace cxx + { + namespace hybrid + { +#ifdef XSDE_EXCEPTIONS + + void + operator<< (ocdrstream& s, const string_sequence& x) + { + s << ocdrstream::as_size (x.size ()); + + for (string_sequence::const_iterator i = x.begin (); + i != x.end (); ++i) + { + s << *i; + } + } + + void + operator>> (icdrstream& s, string_sequence& x) + { + size_t n; + icdrstream::as_size as_size (n); + s >> as_size; + + x.clear (); + + if (n > 0) + { + x.reserve (n); + +#ifdef XSDE_STL + std::string i; +#else + char* i; +#endif + while (n--) + { + s >> i; + x.push_back (i); + } + } + } + +#else // XSDE_EXCEPTIONS + + bool + operator<< (ocdrstream& s, const string_sequence& x) + { + if (!(s << ocdrstream::as_size (x.size ()))) + return false; + + for (string_sequence::const_iterator i = x.begin (); + i != x.end (); ++i) + { + if (!(s << *i)) + return false; + } + + return true; + } + + bool + operator>> (icdrstream& s, string_sequence& x) + { + size_t n; + icdrstream::as_size as_size (n); + + if (!(s >> as_size)) + return false; + + x.clear (); + + if (n > 0) + { + if (x.reserve (n)) + return false; + +#ifdef XSDE_STL + std::string i; +#else + char* i; +#endif + while (n--) + { + if (!(s >> i) || x.push_back (i)) + return false; + } + } + + return true; + } + +#endif // XSDE_EXCEPTIONS + } + } +} |