summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-06-28 18:10:50 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-06-28 18:10:50 +0000
commit7050ef274dbd61412f86491b5fcd0f44a7c7c60f (patch)
tree5402dcbfb7325fcae1317345bae11c5787fa640d
parent379aad0a9a32ca4198d1075b2383589cde30b9ad (diff)
downloadATCD-7050ef274dbd61412f86491b5fcd0f44a7c7c60f.tar.gz
ChangeLogTag: Thu Jun 28 13:05:12 2001 Jeff Parsons <parsons@cs.wustl.edu>
-rw-r--r--ace/CDR_Stream.cpp43
-rw-r--r--ace/CDR_Stream.h24
-rw-r--r--ace/CDR_Stream.i40
3 files changed, 88 insertions, 19 deletions
diff --git a/ace/CDR_Stream.cpp b/ace/CDR_Stream.cpp
index 6c945607c63..5bb165a0237 100644
--- a/ace/CDR_Stream.cpp
+++ b/ace/CDR_Stream.cpp
@@ -775,16 +775,27 @@ ACE_InputCDR::read_wchar (ACE_CDR::WChar& x)
{
if (ACE_static_cast (ACE_CDR::Short, major_version_) == 1
&& ACE_static_cast (ACE_CDR::Short, minor_version_) == 2)
- {
- ACE_CDR::Octet len;
- if (this->read_1 (&len))
- return this->read_octet_array(ACE_reinterpret_cast (ACE_CDR::Octet*, &x),
- ACE_static_cast (ACE_CDR::ULong, len));
- }
- else
- if (this->wchar_translator_ == 0)
- return this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort*,&x));
- return this->wchar_translator_->read_wchar (*this, x);
+ {
+ ACE_CDR::Octet len;
+
+ if (this->read_1 (&len))
+ {
+ return this->read_octet_array (
+ ACE_reinterpret_cast (ACE_CDR::Octet*,
+ &x),
+ ACE_static_cast (ACE_CDR::ULong,
+ len)
+ );
+ }
+ }
+ else if (this->wchar_translator_ == 0)
+ {
+ return this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort*,
+ &x));
+ }
+
+ return this->wchar_translator_->read_wchar (*this,
+ x);
}
ACE_CDR::Boolean
@@ -794,7 +805,10 @@ ACE_InputCDR::read_string (char *&x)
// i.e. normally the translator will be 0, but OTOH the code is
// smaller and should be better for the cache ;-) ;-)
if (this->char_translator_ != 0)
- return this->char_translator_->read_string (*this, x);
+ {
+ return this->char_translator_->read_string (*this,
+ x);
+ }
ACE_CDR::ULong len;
@@ -808,7 +822,10 @@ ACE_InputCDR::read_string (char *&x)
ACE_CDR::Char[len],
0);
if (this->read_char_array (x, len))
- return 1;
+ {
+ return 1;
+ }
+
delete [] x;
}
else if (len == 0)
@@ -818,7 +835,7 @@ ACE_InputCDR::read_string (char *&x)
ACE_NEW_RETURN (x,
ACE_CDR::Char[1],
0);
- ACE_OS::strcpy(x, "");
+ ACE_OS::strcpy (ACE_const_cast (char *&, x), "");
return 1;
}
diff --git a/ace/CDR_Stream.h b/ace/CDR_Stream.h
index c6f4a89c8cb..89a1984e949 100644
--- a/ace/CDR_Stream.h
+++ b/ace/CDR_Stream.h
@@ -152,6 +152,9 @@ public:
from_string (ACE_CDR::Char* s,
ACE_CDR::ULong b,
ACE_CDR::Boolean nocopy = 0);
+ from_string (const ACE_CDR::Char* s,
+ ACE_CDR::ULong b,
+ ACE_CDR::Boolean nocopy = 0);
ACE_CDR::Char *val_;
ACE_CDR::ULong bound_;
ACE_CDR::Boolean nocopy_;
@@ -162,6 +165,9 @@ public:
from_wstring (ACE_CDR::WChar* ws,
ACE_CDR::ULong b,
ACE_CDR::Boolean nocopy = 0);
+ from_wstring (const ACE_CDR::WChar* ws,
+ ACE_CDR::ULong b,
+ ACE_CDR::Boolean nocopy = 0);
ACE_CDR::WChar *val_;
ACE_CDR::ULong bound_;
ACE_CDR::Boolean nocopy_;
@@ -577,17 +583,27 @@ public:
struct ACE_Export to_string
{
+ /// The constructor taking a non-const string is
+ /// now deprecated (C++ mapping 00-01-02), but we
+ /// keep it around for backward compatibility.
to_string (ACE_CDR::Char *&s,
ACE_CDR::ULong b);
- ACE_CDR::Char *&val_;
+ to_string (const ACE_CDR::Char *&s,
+ ACE_CDR::ULong b);
+ const ACE_CDR::Char *&val_;
ACE_CDR::ULong bound_;
};
struct ACE_Export to_wstring
{
+ /// The constructor taking a non-const wstring is
+ /// now deprecated (C++ mapping 00-01-02), but we
+ /// keep it around for backward compatibility.
to_wstring (ACE_CDR::WChar *&ws,
ACE_CDR::ULong b);
- ACE_CDR::WChar *&val_;
+ to_wstring (const ACE_CDR::WChar *&ws,
+ ACE_CDR::ULong b);
+ const ACE_CDR::WChar *&val_;
ACE_CDR::ULong bound_;
};
//@}
@@ -860,7 +876,7 @@ public:
/// Read an array of characters from the stream, converting the
/// characters from the stream codeset to the native codeset.
virtual ACE_CDR::Boolean read_char_array (ACE_InputCDR&,
- ACE_CDR::Char*,
+ const ACE_CDR::Char*,
ACE_CDR::ULong) = 0;
/// Write a single character to the stream, converting from the
@@ -944,7 +960,7 @@ public:
virtual ACE_CDR::Boolean read_wstring (ACE_InputCDR&,
ACE_CDR::WChar *&) = 0;
virtual ACE_CDR::Boolean read_wchar_array (ACE_InputCDR&,
- ACE_CDR::WChar*,
+ const ACE_CDR::WChar*,
ACE_CDR::ULong) = 0;
virtual ACE_CDR::Boolean write_wchar (ACE_OutputCDR&,
ACE_CDR::WChar) = 0;
diff --git a/ace/CDR_Stream.i b/ace/CDR_Stream.i
index dbd6b1621b1..80bf3ce7fd7 100644
--- a/ace/CDR_Stream.i
+++ b/ace/CDR_Stream.i
@@ -64,8 +64,26 @@ ACE_OutputCDR::from_string::from_string (ACE_CDR::Char *s,
}
ACE_INLINE
+ACE_OutputCDR::from_string::from_string (const ACE_CDR::Char *s,
+ ACE_CDR::ULong b,
+ ACE_CDR::Boolean nocopy)
+ : val_ (ACE_const_cast (ACE_CDR::Char *, s)),
+ bound_ (b),
+ nocopy_ (nocopy)
+{
+}
+
+ACE_INLINE
ACE_InputCDR::to_string::to_string (ACE_CDR::Char *&s,
ACE_CDR::ULong b)
+ : val_ (ACE_const_cast (const ACE_CDR::Char *&, s)),
+ bound_ (b)
+{
+}
+
+ACE_INLINE
+ACE_InputCDR::to_string::to_string (const ACE_CDR::Char *&s,
+ ACE_CDR::ULong b)
: val_ (s),
bound_ (b)
{
@@ -82,8 +100,26 @@ ACE_OutputCDR::from_wstring::from_wstring (ACE_CDR::WChar *ws,
}
ACE_INLINE
+ACE_OutputCDR::from_wstring::from_wstring (const ACE_CDR::WChar *ws,
+ ACE_CDR::ULong b,
+ ACE_CDR::Boolean nocopy)
+ : val_ (ACE_const_cast (ACE_CDR::WChar *, ws)),
+ bound_ (b),
+ nocopy_ (nocopy)
+{
+}
+
+ACE_INLINE
ACE_InputCDR::to_wstring::to_wstring (ACE_CDR::WChar *&ws,
ACE_CDR::ULong b)
+ : val_ (ACE_const_cast (const ACE_CDR::WChar *&, ws)),
+ bound_ (b)
+{
+}
+
+ACE_INLINE
+ACE_InputCDR::to_wstring::to_wstring (const ACE_CDR::WChar *&ws,
+ ACE_CDR::ULong b)
: val_ (ws),
bound_ (b)
{
@@ -1135,7 +1171,7 @@ operator>> (ACE_InputCDR &is, ACE_InputCDR::to_octet x)
ACE_INLINE ACE_CDR::Boolean
operator>> (ACE_InputCDR &is, ACE_InputCDR::to_string x)
{
- is.read_string (x.val_);
+ is.read_string (ACE_const_cast (char *&, x.val_));
// check if the bounds are satisfied
return (is.good_bit () &&
(ACE_OS::strlen (x.val_) <= x.bound_));
@@ -1144,7 +1180,7 @@ operator>> (ACE_InputCDR &is, ACE_InputCDR::to_string x)
ACE_INLINE ACE_CDR::Boolean
operator>> (ACE_InputCDR &is, ACE_InputCDR::to_wstring x)
{
- is.read_wstring (x.val_);
+ is.read_wstring (ACE_const_cast (ACE_CDR::WChar *&, x.val_));
// check if the bounds are satisfied
return (is.good_bit () &&
(ACE_OS::wslen (x.val_) <= x.bound_));