summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-06-10 01:52:33 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-06-10 01:52:33 +0000
commite34ab1057bb644f011959028ade8d8e360e5c8af (patch)
tree9f8bd6228e96ffaf1c07d9843ea230b2c9ca2a18 /ace
parent6acb1385292b59eb4ce1538ff849f76db197b618 (diff)
downloadATCD-e34ab1057bb644f011959028ade8d8e360e5c8af.tar.gz
ChangeLogTag:Wed Jun 9 20:40:50 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
Diffstat (limited to 'ace')
-rw-r--r--ace/CDR_Stream.cpp65
-rw-r--r--ace/CDR_Stream.h11
2 files changed, 51 insertions, 25 deletions
diff --git a/ace/CDR_Stream.cpp b/ace/CDR_Stream.cpp
index 990ccd91323..aa026c9b1bc 100644
--- a/ace/CDR_Stream.cpp
+++ b/ace/CDR_Stream.cpp
@@ -580,32 +580,12 @@ ACE_InputCDR::ACE_InputCDR (size_t bufsiz,
ACE_InputCDR::ACE_InputCDR (const ACE_Message_Block *data,
int byte_order)
- : start_ (ACE_CDR::total_length (data, 0) + ACE_CDR::MAX_ALIGNMENT),
- // @@ We may need allocators for the previous line, and the size may
- // be a standard ACE_*CDR size...
- do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER),
+ : start_ (),
good_bit_ (1),
char_translator_ (0),
wchar_translator_ (0)
{
- // We must copy the contents of <data> into the new buffer, but
- // respecting the alignment.
- ptr_arith_t curalign =
- ptr_arith_t(data->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT;
- ptr_arith_t tmpalign =
- ptr_arith_t(this->start_.rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT;
- int offset = curalign - tmpalign;
- if (offset < 0)
- offset += ACE_CDR::MAX_ALIGNMENT;
- this->start_.rd_ptr (offset);
- this->start_.wr_ptr (offset);
-
- for (const ACE_Message_Block* i = data;
- i != 0;
- i = i->cont ())
- {
- this->start_.copy (i->rd_ptr (), i->length ());
- }
+ this->reset (data, byte_order);
}
ACE_InputCDR::ACE_InputCDR (ACE_Data_Block *data,
@@ -993,8 +973,6 @@ ACE_InputCDR::skip_bytes (size_t len)
return 0;
}
-
-
int
ACE_InputCDR::grow (size_t newsize)
{
@@ -1005,3 +983,42 @@ ACE_InputCDR::grow (size_t newsize)
this->start_.wr_ptr (newsize);
return 0;
}
+
+void
+ACE_InputCDR::reset (const ACE_Message_Block* data,
+ int byte_order)
+{
+ this->reset_byte_order (byte_order);
+ this->start_.size (ACE_CDR::total_length (data, 0)
+ + ACE_CDR::MAX_ALIGNMENT);
+
+ // We must copy the contents of <data> into the new buffer, but
+ // respecting the alignment.
+ ptr_arith_t curalign =
+ ptr_arith_t(data->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT;
+ ptr_arith_t tmpalign =
+ ptr_arith_t(this->start_.rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT;
+ int offset = curalign - tmpalign;
+ if (offset < 0)
+ offset += ACE_CDR::MAX_ALIGNMENT;
+ this->start_.rd_ptr (offset);
+ this->start_.wr_ptr (offset);
+
+ for (const ACE_Message_Block* i = data;
+ i != 0;
+ i = i->cont ())
+ {
+ this->start_.copy (i->rd_ptr (), i->length ());
+ }
+}
+
+ACE_Message_Block*
+ACE_InputCDR::steal_contents (void)
+{
+ ACE_Message_Block* block =
+ this->start_.clone ();
+ this->start_.data_block (block->data_block ()->clone ());
+ ACE_CDR::mb_align (&this->start_);
+
+ return block;
+}
diff --git a/ace/CDR_Stream.h b/ace/CDR_Stream.h
index aea71014629..cff1f7f38da 100644
--- a/ace/CDR_Stream.h
+++ b/ace/CDR_Stream.h
@@ -704,7 +704,7 @@ public:
// CDR stream from a socket or file.
int grow (size_t newsize);
- // Grow the internal buffer, reset rd_ptr() to the first byte in the
+ // Grow the internal buffer, reset rd_ptr() to the first byte in the
// new buffer that is properly aligned, and set wr_ptr() to
// rd_ptr() + newsize
@@ -713,6 +713,15 @@ public:
// detect a change in the byte order, this method will let him
// change it.
+ void reset (const ACE_Message_Block *data,
+ int byte_order);
+ // Re-initialize the CDR stream, copying the contents of the chain
+ // of message_blocks starting from <data>.
+
+ ACE_Message_Block * steal_contents (void);
+ // Re-initialize the CDR stream, copying the contents of the chain
+ // of message_blocks starting from <data>.
+
char* rd_ptr (void);
// Returns the current position for the rd_ptr....