summaryrefslogtreecommitdiff
path: root/ace/CDR_Stream.inl
diff options
context:
space:
mode:
Diffstat (limited to 'ace/CDR_Stream.inl')
-rw-r--r--ace/CDR_Stream.inl146
1 files changed, 43 insertions, 103 deletions
diff --git a/ace/CDR_Stream.inl b/ace/CDR_Stream.inl
index cbcb6638bf1..6d68e938d15 100644
--- a/ace/CDR_Stream.inl
+++ b/ace/CDR_Stream.inl
@@ -7,8 +7,6 @@
// ****************************************************************
-ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-
// implementing the special types
ACE_INLINE
ACE_OutputCDR::from_boolean::from_boolean (ACE_CDR::Boolean b)
@@ -155,10 +153,7 @@ ACE_OutputCDR::reset (void)
this->current_ = &this->start_;
this->current_is_writable_ = true;
ACE_CDR::mb_align (&this->start_);
-
-#if !defined (ACE_LACKS_CDR_ALIGNMENT)
this->current_alignment_ = 0;
-#endif /* ACE_LACKS_CDR_ALIGNMENT */
// It is tempting not to remove the memory, but we need to do so to
// release any potential user buffers chained in the continuation
@@ -170,6 +165,7 @@ ACE_OutputCDR::reset (void)
ACE_Message_Block::release (cont);
this->start_.cont (0);
}
+
}
// Encode the CDR stream.
@@ -177,8 +173,7 @@ ACE_OutputCDR::reset (void)
ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_octet (ACE_CDR::Octet x)
{
- const void *temp = &x;
- return this->write_1 (reinterpret_cast<const ACE_CDR::Octet *> (temp));
+ return this->write_1 (reinterpret_cast<const ACE_CDR::Octet *> (&x));
}
ACE_INLINE ACE_CDR::Boolean
@@ -191,74 +186,62 @@ ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_char (ACE_CDR::Char x)
{
if (this->char_translator_ == 0)
- {
- const void *temp = &x;
- return this->write_1 (reinterpret_cast<const ACE_CDR::Octet*> (temp));
- }
+ return this->write_1 (reinterpret_cast<const ACE_CDR::Octet*> (&x));
return this->char_translator_->write_char (*this, x);
}
ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_short (ACE_CDR::Short x)
{
- const void *temp = &x;
- return this->write_2 (reinterpret_cast<const ACE_CDR::UShort*> (temp));
+ return this->write_2 (reinterpret_cast<const ACE_CDR::UShort*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_ushort (ACE_CDR::UShort x)
{
- const void *temp = &x;
- return this->write_2 (reinterpret_cast<const ACE_CDR::UShort*> (temp));
+ return this->write_2 (reinterpret_cast<const ACE_CDR::UShort*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_long (ACE_CDR::Long x)
{
- const void *temp = &x;
- return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (temp));
+ return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_ulong (ACE_CDR::ULong x)
{
- const void *temp = &x;
- return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (temp));
+ return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_longlong (const ACE_CDR::LongLong &x)
{
- const void *temp = &x;
- return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (temp));
+ return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_ulonglong (const ACE_CDR::ULongLong &x)
{
- const void *temp = &x;
- return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (temp));
+ return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_float (ACE_CDR::Float x)
{
- const void *temp = &x;
- return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (temp));
+ return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_double (const ACE_CDR::Double &x)
{
- const void *temp = &x;
- return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (temp));
+ return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_longdouble (const ACE_CDR::LongDouble &x)
{
- const void *temp = &x;
- return this->write_16 (reinterpret_cast<const ACE_CDR::LongDouble*> (temp));
+ return this->write_16 (reinterpret_cast<const ACE_CDR::LongDouble*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
@@ -433,24 +416,17 @@ ACE_OutputCDR::adjust (size_t size,
if (!this->current_is_writable_)
return this->grow_and_adjust (size, align, buf);
-#if !defined (ACE_LACKS_CDR_ALIGNMENT)
const size_t offset =
ACE_align_binary (this->current_alignment_, align)
- this->current_alignment_;
buf = this->current_->wr_ptr () + offset;
-#else
- buf = this->current_->wr_ptr ();
-#endif /* ACE_LACKS_CDR_ALIGNMENT */
-
char *end = buf + size;
if (end <= this->current_->end () &&
end >= buf)
{
-#if !defined (ACE_LACKS_CDR_ALIGNMENT)
this->current_alignment_ += offset + size;
-#endif /* ACE_LACKS_CDR_ALIGNMENT */
this->current_->wr_ptr (end);
return 0;
}
@@ -542,26 +518,14 @@ ACE_OutputCDR::reset_byte_order (int byte_order)
ACE_INLINE size_t
ACE_OutputCDR::current_alignment (void) const
{
-#if !defined (ACE_LACKS_CDR_ALIGNMENT)
return this->current_alignment_;
-#else
- // Default value set to 0
- return 0;
-#endif /* ACE_LACKS_CDR_ALIGNMENT */
}
ACE_INLINE int
ACE_OutputCDR::align_write_ptr (size_t alignment)
{
-#if !defined (ACE_LACKS_CDR_ALIGNMENT)
char *dummy;
return this->adjust (0, alignment, dummy);
-#else
- ACE_UNUSED_ARG (alignment);
- // A return value of -1 from this function is used
- // to indicate failure, returning 0
- return 0;
-#endif /* ACE_LACKS_CDR_ALIGNMENT */
}
ACE_INLINE ACE_Char_Codeset_Translator *
@@ -614,10 +578,7 @@ ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::read_char (ACE_CDR::Char &x)
{
if (this->char_translator_ == 0)
- {
- void *temp = &x;
- return this->read_1 (reinterpret_cast<ACE_CDR::Octet*> (temp));
- }
+ return this->read_1 (reinterpret_cast<ACE_CDR::Octet*> (&x));
return this->char_translator_->read_char (*this, x);
}
@@ -625,67 +586,58 @@ ACE_InputCDR::read_char (ACE_CDR::Char &x)
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::read_short (ACE_CDR::Short &x)
{
- void *temp = &x;
- return this->read_2 (reinterpret_cast<ACE_CDR::UShort*> (temp));
+ return this->read_2 (reinterpret_cast<ACE_CDR::UShort*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::read_ushort (ACE_CDR::UShort &x)
{
- void *temp = &x;
- return this->read_2 (reinterpret_cast<ACE_CDR::UShort*> (temp));
+ return this->read_2 (reinterpret_cast<ACE_CDR::UShort*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::read_long (ACE_CDR::Long &x)
{
- void *temp = &x;
- return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp));
+ return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::read_ulong (ACE_CDR::ULong &x)
{
- void *temp = &x;
- return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp));
+ return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::read_longlong (ACE_CDR::LongLong &x)
{
- void *temp = &x;
- return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp));
+ return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::read_ulonglong (ACE_CDR::ULongLong &x)
{
- void *temp = &x;
- return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp));
+ return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::read_float (ACE_CDR::Float &x)
{
- void *temp = &x;
- return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp));
+ return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::read_double (ACE_CDR::Double &x)
{
- void *temp = &x;
- return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp));
+ return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::read_longdouble (ACE_CDR::LongDouble &x)
{
- void *temp = &x;
- return this->read_16 (reinterpret_cast<ACE_CDR::LongDouble*> (temp));
+ return this->read_16 (reinterpret_cast<ACE_CDR::LongDouble*> (&x));
}
ACE_INLINE size_t
@@ -922,8 +874,7 @@ ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::skip_char (void)
{
ACE_CDR::Char x;
- void *temp = &x;
- return this->read_1 (reinterpret_cast<ACE_CDR::Octet*> (temp));
+ return this->read_1 (reinterpret_cast<ACE_CDR::Octet*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
@@ -945,48 +896,42 @@ ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::skip_short (void)
{
ACE_CDR::Short x;
- void *temp = &x;
- return this->read_2 (reinterpret_cast<ACE_CDR::UShort*> (temp));
+ return this->read_2 (reinterpret_cast<ACE_CDR::UShort*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::skip_ushort (void)
{
ACE_CDR::UShort x;
- void *temp = &x;
- return this->read_2 (reinterpret_cast<ACE_CDR::UShort*> (temp));
+ return this->read_2 (reinterpret_cast<ACE_CDR::UShort*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::skip_long (void)
{
ACE_CDR::Long x;
- void *temp = &x;
- return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp));
+ return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::skip_ulong (void)
{
ACE_CDR::ULong x;
- void *temp = &x;
- return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp));
+ return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::skip_longlong (void)
{
ACE_CDR::LongLong x;
- void *temp = &x;
- return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp));
+ return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::skip_ulonglong (void)
{
ACE_CDR::ULongLong x;
- void *temp = &x;
- return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp));
+ return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
@@ -995,24 +940,21 @@ ACE_InputCDR::skip_float (void)
// Changing this removes the warning for GHS and it
// stops the compiler from getting an internal error.
ACE_CDR::ULong value;
- void *temp = &value;
- return this->read_4 (reinterpret_cast<ACE_CDR::ULong*> (temp));
+ return this->read_4 (&value);
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::skip_double (void)
{
double x;
- void *temp = &x;
- return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (temp));
+ return this->read_8 (reinterpret_cast<ACE_CDR::ULongLong*> (&x));
}
ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::skip_longdouble (void)
{
ACE_CDR::LongDouble x;
- void *temp = &x;
- return this->read_16 (reinterpret_cast<ACE_CDR::LongDouble*> (temp));
+ return this->read_16 (reinterpret_cast<ACE_CDR::LongDouble*> (&x));
}
ACE_INLINE char*
@@ -1044,12 +986,7 @@ ACE_InputCDR::adjust (size_t size,
size_t align,
char*& buf)
{
-#if !defined (ACE_LACKS_CDR_ALIGNMENT)
buf = ACE_ptr_align_binary (this->rd_ptr (), align);
-#else
- buf = this->rd_ptr ();
-#endif /* ACE_LACKS_CDR_ALIGNMENT */
-
char *end = buf + size;
if (end <= this->wr_ptr ())
{
@@ -1059,9 +996,6 @@ ACE_InputCDR::adjust (size_t size,
this->good_bit_ = false;
return -1;
-#if defined (ACE_LACKS_CDR_ALIGNMENT)
- ACE_UNUSED_ARG (align);
-#endif /* ACE_LACKS_CDR_ALIGNMENT */
}
ACE_INLINE int
@@ -1502,12 +1436,8 @@ ACE_InputCDR::byte_order (void) const
ACE_INLINE int
ACE_InputCDR::align_read_ptr (size_t alignment)
{
-#if !defined (ACE_LACKS_CDR_ALIGNMENT)
char *buf = ACE_ptr_align_binary (this->rd_ptr (),
alignment);
-#else
- char *buf = this->rd_ptr ();
-#endif /* ACE_LACKS_CDR_ALIGNMENT */
if (buf <= this->wr_ptr ())
{
@@ -1740,4 +1670,14 @@ ACE_WChar_Codeset_Translator::minor_version (ACE_OutputCDR& output)
return output.minor_version_;
}
-ACE_END_VERSIONED_NAMESPACE_DECL
+ACE_INLINE
+OutputCDR_Auto_Reset::OutputCDR_Auto_Reset (ACE_OutputCDR& cdr)
+ : cdr_ (cdr)
+{
+}
+
+ACE_INLINE
+OutputCDR_Auto_Reset::~OutputCDR_Auto_Reset (void)
+{
+ cdr_.reset ();
+}