diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-09-16 17:51:08 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-09-16 17:51:08 +0000 |
commit | 0c937a6a632380459e0e0a274b02201830dbd26b (patch) | |
tree | 12b77082d9f1bf4da9b41f758e48b44a4a1d21d7 /TAO | |
parent | 20b8e488b8d015cc2a51e349ccfa4cb0b6476a82 (diff) | |
download | ATCD-0c937a6a632380459e0e0a274b02201830dbd26b.tar.gz |
iostream operators for (W)String_var and (W)String_out, and more
attempts to please SunCC.
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/tao/ORB.cpp | 91 | ||||
-rw-r--r-- | TAO/tao/ORB.h | 21 | ||||
-rw-r--r-- | TAO/tao/Sequence_T.cpp | 24 |
3 files changed, 120 insertions, 16 deletions
diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp index 7a96ad48d3c..0e784b49941 100644 --- a/TAO/tao/ORB.cpp +++ b/TAO/tao/ORB.cpp @@ -2608,6 +2608,97 @@ CORBA_ORB::lookup_value_factory (const char *repository_id, #endif /* TAO_HAS_VALUETYPE */ +// ************************************************************* +// C++ iostream operators for (W)String_var and (W)String_out +// ************************************************************* + +ostream & +operator<< (ostream &os, const CORBA::String_var &sv) +{ + os << sv.in (); + return os; +} + +istream & +operator>> (istream &is, CORBA::String_var &sv) +{ + is >> sv.inout (); + return is; +} + +ostream & +operator<< (ostream &os, CORBA::String_out &so) +{ + os << so.ptr (); + return os; +} + +istream & +operator>> (istream &is, CORBA::String_out &so) +{ + is >> so.ptr (); + return is; +} + +// Until we implement WString support for platforms with a +// 4-byte wchar_t, we just define the following to emit +// the CORBA::WChars one by one. + +ostream & +operator<< (ostream &os, const CORBA::WString_var &wsv) +{ + CORBA::ULong len = ACE_OS::wslen (wsv.in ()); + for (CORBA::ULong i = 0; i < len; i++) + { + os << wsv[i]; + } + return os; +} + +istream & +operator>> (istream &is, CORBA::WString_var &wsv) +{ + CORBA::ULong i = 0; + CORBA::WChar wc; + is >> wc; + while (wc) + { + wsv[i] = wc; + i++; + is >> wc; + } + wsv[i] = 0; + return is; +} + +ostream & +operator<< (ostream &os, CORBA::WString_out &wso) +{ + CORBA::WChar *tmp = wso.ptr (); + CORBA::ULong len = ACE_OS::wslen (tmp); + for (CORBA::ULong i = 0; i < len; i++) + { + os << tmp[i]; + } + return os; +} + +istream & +operator>> (istream &is, CORBA::WString_out &wso) +{ + CORBA::ULong i = 0; + CORBA::WChar wc; + is >> wc; + while (wc) + { + wso.ptr ()[i] = wc; + i++; + is >> wc; + } + wso.ptr ()[i] = 0; + return is; +} + // **************************************************************** #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) diff --git a/TAO/tao/ORB.h b/TAO/tao/ORB.h index 66a3e10e74f..1ab811e838c 100644 --- a/TAO/tao/ORB.h +++ b/TAO/tao/ORB.h @@ -856,6 +856,27 @@ operator<< (TAO_OutputCDR &, const CORBA::ORB::InvalidName &); extern TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &, CORBA::ORB::InvalidName &); +# if !defined (ACE_LACKS_IOSTREAM_TOTALLY) + +extern TAO_Export ostream & +operator<< (ostream &, const CORBA::String_var &); +extern TAO_Export istream & +operator>> (istream &, CORBA::String_var &); +extern TAO_Export ostream & +operator<< (ostream &, CORBA::String_out &); +extern TAO_Export istream & +operator>> (istream &, CORBA::String_out &); +extern TAO_Export ostream & +operator<< (ostream &, const CORBA::WString_var &); +extern TAO_Export istream & +operator>> (istream &, CORBA::WString_var &); +extern TAO_Export ostream & +operator<< (ostream &, CORBA::WString_out &); +extern TAO_Export istream & +operator>> (istream &, CORBA::WString_out &); + +# endif /* ACE_LACKS_IOSTREAM_TOTALLY */ + #if defined (__ACE_INLINE__) # include "tao/ORB.i" #endif /* __ACE_INLINE__ */ diff --git a/TAO/tao/Sequence_T.cpp b/TAO/tao/Sequence_T.cpp index 700388f132e..87472b2489e 100644 --- a/TAO/tao/Sequence_T.cpp +++ b/TAO/tao/Sequence_T.cpp @@ -1068,15 +1068,12 @@ operator= (const TAO_Unbounded_Array_Sequence<T, T_var> &rhs) TAO_Unbounded_Base_Sequence::operator= (rhs); - T *tmp1 = ACE_reinterpret_cast (T *, - this->buffer_); - - const T *tmp2 = ACE_reinterpret_cast (const T *, - rhs.buffer_); - for (CORBA::ULong i = 0; i < rhs.length_; ++i) { - T_var::copy (tmp1[i], tmp2[i]); + T_var::copy (ACE_reinterpret_cast (T *, + this->buffer_)[i], + ACE_reinterpret_cast (const T *, + rhs.buffer_)[i]); } return *this; @@ -1176,17 +1173,12 @@ TAO_Bounded_Array_Sequence<T, T_var, MAX>::operator= TAO_Bounded_Array_Sequence<T, T_var, MAX>::allocbuf (rhs.maximum_); } - TAO_Bounded_Base_Sequence::operator= (rhs); - - T *tmp1 = ACE_reinterpret_cast (T *, - this->buffer_); - - const T *tmp2 = ACE_reinterpret_cast (const T *, - rhs.buffer_); - for (CORBA::ULong i = 0; i < rhs.length_; ++i) { - T_var::copy (tmp1[i], tmp2[i]); + T_var::copy (ACE_reinterpret_cast (T *, + this->buffer_)[i], + ACE_reinterpret_cast (const T *, + rhs.buffer_)[i]); } return *this; |