// file : xsde/cxx/hybrid/cdr/ostream.cxx // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include #ifndef XSDE_STL # include #endif #include 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 (x.length ()), x.c_str ())) throw cdr_exception (); } #else void ocdrstream:: operator<< (const char* x) { if (!cdr_.write_string (static_cast (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 (n)) || !cdr_.write_octet_array ( reinterpret_cast (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 (x.length ()), x.c_str ()); } #else bool ocdrstream:: operator<< (const char* x) { return cdr_.write_string ( static_cast (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 (n)) && cdr_.write_octet_array ( reinterpret_cast (x.data ()), n); } #endif // XSDE_EXCEPTIONS } } }