summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormcorino <mcorino@users.noreply.github.com>2011-06-27 10:31:04 +0000
committermcorino <mcorino@users.noreply.github.com>2011-06-27 10:31:04 +0000
commitfc6123297519f49d233c9bf1377f4837dafb20ec (patch)
treec713a1fd3ec2603fd230c5ae4221032ec3e326a6
parent4829886a7fea4474ffe75c707077486e6d5922c3 (diff)
downloadATCD-fc6123297519f49d233c9bf1377f4837dafb20ec.tar.gz
ChangeLogTag: Mon Jun 27 10:28:15 UTC 2011 Martin Corino <mcorino@remedy.nl>
-rw-r--r--TAO/ChangeLog7
-rw-r--r--TAO/tao/CDR.h31
-rw-r--r--TAO/tao/CDR.inl61
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