summaryrefslogtreecommitdiff
path: root/ACE/ace/CDR_Stream.cpp
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2007-11-30 16:59:16 +0000
committerSteve Huston <shuston@riverace.com>2007-11-30 16:59:16 +0000
commit6fa9e8d5e407c68990e5cf389d23031cf7f636e0 (patch)
tree68825cb20264e8f3c3a3ba117d06afd5ced67e10 /ACE/ace/CDR_Stream.cpp
parentaf39f450f1e613aa591113ab0170922f2e77de01 (diff)
downloadATCD-6fa9e8d5e407c68990e5cf389d23031cf7f636e0.tar.gz
ChangeLogTag:Fri Nov 30 16:58:00 UTC 2007 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ACE/ace/CDR_Stream.cpp')
-rw-r--r--ACE/ace/CDR_Stream.cpp69
1 files changed, 56 insertions, 13 deletions
diff --git a/ACE/ace/CDR_Stream.cpp b/ACE/ace/CDR_Stream.cpp
index a9e1fa4f6cf..00af2b70940 100644
--- a/ACE/ace/CDR_Stream.cpp
+++ b/ACE/ace/CDR_Stream.cpp
@@ -651,6 +651,46 @@ ACE_OutputCDR::write_array (const void *x,
ACE_CDR::Boolean
+ACE_OutputCDR::write_boolean_array (const ACE_CDR::Boolean* x,
+ ACE_CDR::ULong length)
+{
+ // It is hard to optimize this, the spec requires that on the wire
+ // booleans be represented as a byte with value 0 or 1, but in
+ // memory it is possible (though very unlikely) that a boolean has
+ // a non-zero value (different from 1).
+ // We resort to a simple loop.
+ ACE_CDR::Boolean const * const end = x + length;
+
+ for (ACE_CDR::Boolean const * i = x;
+ i != end && this->good_bit ();
+ ++i)
+ (void) this->write_boolean (*i);
+
+ return this->good_bit ();
+}
+
+
+char *
+ACE_OutputCDR::write_long_placeholder (void)
+{
+ this->align_write_ptr (ACE_CDR::LONG_SIZE);
+ char *pos = this->current_->wr_ptr ();
+ this->write_long (0);
+ return pos;
+}
+
+
+char *
+ACE_OutputCDR::write_short_placeholder (void)
+{
+ this->align_write_ptr (ACE_CDR::SHORT_SIZE);
+ char *pos = this->current_->wr_ptr();
+ this->write_short (0);
+ return pos;
+}
+
+
+ACE_CDR::Boolean
ACE_OutputCDR::replace (ACE_CDR::Long x, char* loc)
{
if (this->find (loc) == 0)
@@ -674,22 +714,25 @@ ACE_OutputCDR::replace (ACE_CDR::Long x, char* loc)
ACE_CDR::Boolean
-ACE_OutputCDR::write_boolean_array (const ACE_CDR::Boolean* x,
- ACE_CDR::ULong length)
+ACE_OutputCDR::replace (ACE_CDR::Short x, char* loc)
{
- // It is hard to optimize this, the spec requires that on the wire
- // booleans be represented as a byte with value 0 or 1, but in
- // memory it is possible (though very unlikely) that a boolean has
- // a non-zero value (different from 1).
- // We resort to a simple loop.
- ACE_CDR::Boolean const * const end = x + length;
+ if (this->find (loc) == 0)
+ return false;
- for (ACE_CDR::Boolean const * i = x;
- i != end && this->good_bit ();
- ++i)
- (void) this->write_boolean (*i);
+#if !defined (ACE_ENABLE_SWAP_ON_WRITE)
+ *reinterpret_cast<ACE_CDR::Short*> (loc) = x;
+#else
+ if (!this->do_byte_swap_)
+ {
+ *reinterpret_cast<ACE_CDR::Short *> (loc) = x;
+ }
+ else
+ {
+ ACE_CDR::swap_2 (reinterpret_cast<const char*> (&x), loc);
+ }
+#endif /* ACE_ENABLE_SWAP_ON_WRITE */
- return this->good_bit ();
+ return true;
}