diff options
author | Martin Corino <mcorino@remedy.nl> | 2018-08-03 14:15:38 +0200 |
---|---|---|
committer | Martin Corino <mcorino@remedy.nl> | 2018-08-04 13:56:37 +0200 |
commit | 4a09b0b10cbea1fdcb16161583ee22f7d151784b (patch) | |
tree | 3a69f80021bf06e96197cd5bae164d8ebff657f3 /ACE/ace/CDR_Size.inl | |
parent | 81d3d81c4cf0904cd8d5b4c0872cd1821b5d874e (diff) | |
download | ATCD-4a09b0b10cbea1fdcb16161583ee22f7d151784b.tar.gz |
add full support for streaming std::(w)string
(optimized for C++11 and onwards)
added tests for optimized std::(w)string support
extend character translators with std::(w)string support also
Diffstat (limited to 'ACE/ace/CDR_Size.inl')
-rw-r--r-- | ACE/ace/CDR_Size.inl | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ACE/ace/CDR_Size.inl b/ACE/ace/CDR_Size.inl index 9b83b6f72e0..d138b3de13b 100644 --- a/ACE/ace/CDR_Size.inl +++ b/ACE/ace/CDR_Size.inl @@ -144,6 +144,26 @@ ACE_SizeCDR::write_wstring (const ACE_CDR::WChar *x) } ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_string (const std::string &x) +{ + ACE_CDR::ULong len = + static_cast<ACE_CDR::ULong> (x.size ()); + return this->write_string (len, + x.empty () ? 0 : x.c_str ()); +} + +#if !defined(ACE_LACKS_STD_WSTRING) +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_wstring (const std::wstring &x) +{ + ACE_CDR::ULong len = + static_cast<ACE_CDR::ULong> (x.size ()); + return this->write_wstring (len, + x.empty () ? 0 : x.c_str ()); +} +#endif + +ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_char_array (const ACE_CDR::Char *x, ACE_CDR::ULong length) { @@ -372,6 +392,22 @@ operator<< (ACE_SizeCDR &ss, const ACE_CDR::WChar *x) return (ACE_CDR::Boolean) ss.good_bit (); } +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, const std::string& x) +{ + ss.write_string (x); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +#if !defined(ACE_LACKS_STD_WSTRING) +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, const std::wstring& x) +{ + ss.write_wstring (x); + return (ACE_CDR::Boolean) ss.good_bit (); +} +#endif + // The following use the helper classes ACE_INLINE ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_boolean x) |