diff options
author | mcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2011-06-27 10:31:04 +0000 |
---|---|---|
committer | mcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2011-06-27 10:31:04 +0000 |
commit | ef95e6e22027b19d9f620588fc4f37508436d280 (patch) | |
tree | c713a1fd3ec2603fd230c5ae4221032ec3e326a6 | |
parent | b8bce995b418b0072fe82316ea1aba1ed3d8d84a (diff) | |
download | ATCD-ef95e6e22027b19d9f620588fc4f37508436d280.tar.gz |
ChangeLogTag: Mon Jun 27 10:28:15 UTC 2011 Martin Corino <mcorino@remedy.nl>
-rw-r--r-- | TAO/ChangeLog | 7 | ||||
-rw-r--r-- | TAO/tao/CDR.h | 31 | ||||
-rw-r--r-- | TAO/tao/CDR.inl | 61 |
3 files changed, 99 insertions, 0 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index c8b923c3e6b..51df4878ea4 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,10 @@ +Mon Jun 27 10:28:15 UTC 2011 Martin Corino <mcorino@remedy.nl> + + * tao/CDR.h: + * tao/CDR.inl: + Added CDR streaming ops for std::wstring and helper classes + and streaming ops to extract bounded strings into std strings. + Thu Jun 23 12:39:08 CEST 2011 Johnny Willemsen <jwillemsen@remedy.nl> * etc/*.doxygen: diff --git a/TAO/tao/CDR.h b/TAO/tao/CDR.h index 60bb7e6eb45..d8a7f7fabe8 100644 --- a/TAO/tao/CDR.h +++ b/TAO/tao/CDR.h @@ -445,6 +445,25 @@ public: /// Called after demarshalling. void reset_vt_indirect_maps (); + /// Helper classes for extracting bounded strings into std::string/wstring. + struct TAO_Export to_std_string + { + to_std_string (std::string &s, + ACE_CDR::ULong b); + std::string &val_; + ACE_CDR::ULong bound_; + }; + +#if !defined(ACE_LACKS_STD_WSTRING) + struct TAO_Export to_std_wstring + { + to_std_wstring (std::wstring &ws, + ACE_CDR::ULong b); + std::wstring &val_; + ACE_CDR::ULong bound_; + }; +#endif /* ACE_LACKS_STD_WSTRING */ + private: /// The ORB_Core, required to extract object references. TAO_ORB_Core* orb_core_; @@ -493,6 +512,10 @@ TAO_Export CORBA::Boolean operator<< (TAO_OutputCDR &os, ACE_OutputCDR::from_wstring x); TAO_Export CORBA::Boolean operator<< (TAO_OutputCDR &os, const std::string &x); +#if !defined(ACE_LACKS_STD_WSTRING) +TAO_Export CORBA::Boolean operator<< (TAO_OutputCDR &os, + const std::wstring &x); +#endif /* ACE_LACKS_STD_WSTRING */ // CDR input operators for CORBA types @@ -524,6 +547,14 @@ TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &os, ACE_InputCDR::to_wstring x); TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &os, std::string &x); +TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &os, + TAO_InputCDR::to_std_string x); +#if !defined(ACE_LACKS_STD_WSTRING) +TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &os, + std::wstring &x); +TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &os, + TAO_InputCDR::to_std_wstring x); +#endif /* ACE_LACKS_STD_WSTRING */ TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/CDR.inl b/TAO/tao/CDR.inl index 13ec26dc110..1d22b697b14 100644 --- a/TAO/tao/CDR.inl +++ b/TAO/tao/CDR.inl @@ -329,6 +329,23 @@ TAO_InputCDR::reset_vt_indirect_maps () } } +ACE_INLINE +TAO_InputCDR::to_std_string::to_std_string (std::string &s, + ACE_CDR::ULong b) + : val_ (s), + bound_ (b) +{ +} + +#if !defined(ACE_LACKS_STD_WSTRING) +ACE_INLINE +TAO_InputCDR::to_std_wstring::to_std_wstring (std::wstring &s, + ACE_CDR::ULong b) + : val_ (s), + bound_ (b) +{ +} +#endif /* ACE_LACKS_STD_WSTRING */ // **************************************************************** @@ -461,6 +478,14 @@ ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os, return os << x.c_str (); } +#if !defined(ACE_LACKS_STD_WSTRING) +ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os, + const std::wstring &x) +{ + return os << x.c_str (); +} +#endif /* ACE_LACKS_STD_WSTRING */ + // **************************************************************** ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is, @@ -565,4 +590,40 @@ ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is, return marshal_flag; } +ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is, + TAO_InputCDR::to_std_string x) +{ + CORBA::Boolean const marshal_flag = + is >> x.val_; + if (marshal_flag && x.bound_ != 0 && x.val_.size () > x.bound_) + { + throw ::CORBA::BAD_PARAM (); + } + return marshal_flag; +} + +#if !defined(ACE_LACKS_STD_WSTRING) +ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is, + std::wstring &x) +{ + CORBA::WChar *buf = 0; + CORBA::Boolean const marshal_flag = is >> buf; + x.assign (buf); + ACE::strdelete (buf); + return marshal_flag; +} + +ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is, + TAO_InputCDR::to_std_wstring x) +{ + CORBA::Boolean const marshal_flag = + is >> x.val_; + if (marshal_flag && x.bound_ != 0 && x.val_.size () > x.bound_) + { + throw ::CORBA::BAD_PARAM (); + } + return marshal_flag; +} +#endif /* ACE_LACKS_STD_WSTRING */ + TAO_END_VERSIONED_NAMESPACE_DECL |