本文整理汇总了C++中TAO_InputCDR::rd_ptr方法的典型用法代码示例。如果您正苦于以下问题:C++ TAO_InputCDR::rd_ptr方法的具体用法?C++ TAO_InputCDR::rd_ptr怎么用?C++ TAO_InputCDR::rd_ptr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TAO_InputCDR
的用法示例。
在下文中一共展示了TAO_InputCDR::rd_ptr方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new_mb
void
TAO::Unknown_IDL_Type::_tao_decode (TAO_InputCDR & cdr)
{
// @@ (JP) The following code depends on the fact that
// TAO_InputCDR does not contain chained message blocks,
// otherwise <begin> and <end> could be part of
// different buffers!
// This will be the start of a new message block.
char const * const begin = cdr.rd_ptr ();
// Skip over the next argument.
TAO::traverse_status const status =
TAO_Marshal_Object::perform_skip (this->type_, &cdr);
if (status != TAO::TRAVERSE_CONTINUE)
{
throw ::CORBA::MARSHAL ();
}
// This will be the end of the new message block.
char const * const end = cdr.rd_ptr ();
// The ACE_CDR::mb_align() call can shift the rd_ptr by up to
// ACE_CDR::MAX_ALIGNMENT - 1 bytes. Similarly, the offset adjustment
// can move the rd_ptr by up to the same amount. We accommodate
// this by including 2 * ACE_CDR::MAX_ALIGNMENT bytes of additional
// space in the message block.
size_t const size = end - begin;
ACE_Message_Block new_mb (size + 2 * ACE_CDR::MAX_ALIGNMENT);
ACE_CDR::mb_align (&new_mb);
ptrdiff_t offset = ptrdiff_t (begin) % ACE_CDR::MAX_ALIGNMENT;
if (offset < 0)
{
offset += ACE_CDR::MAX_ALIGNMENT;
}
new_mb.rd_ptr (offset);
new_mb.wr_ptr (offset + size);
ACE_OS::memcpy (new_mb.rd_ptr (), begin, size);
this->cdr_.reset (&new_mb, cdr.byte_order ());
this->cdr_.char_translator (cdr.char_translator ());
this->cdr_.wchar_translator (cdr.wchar_translator ());
this->cdr_.set_repo_id_map (cdr.get_repo_id_map ());
this->cdr_.set_codebase_url_map (cdr.get_codebase_url_map ());
this->cdr_.set_value_map (cdr.get_value_map ());
// Take over the GIOP version, the input cdr can have a different
// version then our current GIOP version.
ACE_CDR::Octet major_version;
ACE_CDR::Octet minor_version;
cdr.get_version (major_version, minor_version);
this->cdr_.set_version (major_version, minor_version);
}
示例2: INTERNAL
CORBA::Boolean
CORBA::ValueBase::_tao_unmarshal_codebase_url_indirection (TAO_InputCDR &strm,
ACE_CString& codebase_url)
{
CORBA::Long offset = 0;
if (!strm.read_long (offset) || offset >= 0)
{
return false;
}
void* pos = strm.rd_ptr () + offset - sizeof (CORBA::Long);
if (strm.get_codebase_url_map()->get()->find (pos, codebase_url) != 0)
{
throw CORBA::INTERNAL ();
}
else if (TAO_debug_level)
{
TAOLIB_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_unmarshal_codebase_url_indirection, found %x=%C\n"),
pos, codebase_url.c_str ()));
}
return 1;
}
示例3: sizeof
CORBA::Boolean
CORBA::ValueBase::_tao_unmarshal_value_indirection_pre (TAO_InputCDR &strm,
TAO_InputCDR &indirected_strm)
{
CORBA::Long offset = 0;
if (!strm.read_long (offset) || offset >= 0)
{
return false;
}
size_t const buffer_size = -(offset) + sizeof (CORBA::Long);
// Cribbed from tc_demarshal_indirection in Typecode_CDR_Extraction.cpp
indirected_strm = TAO_InputCDR (strm.rd_ptr () + offset - sizeof (CORBA::Long),
buffer_size,
strm.byte_order ());
indirected_strm.set_repo_id_map (strm.get_repo_id_map ());
indirected_strm.set_codebase_url_map (strm.get_codebase_url_map ());
indirected_strm.set_value_map (strm.get_value_map ());
return indirected_strm.good_bit ();
}
示例4: ACE_TMAIN
int ACE_TMAIN (int, ACE_TCHAR *[])
{
int status = 0;
for (CORBA::ULong i = 16; i != 64; ++i)
{
ACE_Message_Block mb (i + ACE_CDR::MAX_ALIGNMENT);
ACE_CDR::mb_align (&mb);
mb.wr_ptr (i);
CORBA::Double dbl = i;
TAO_OutputCDR cdr;
cdr.write_ulong (i); // length
cdr.write_octet_array_mb (&mb);
cdr.write_double (dbl);
cdr.write_double (dbl);
TAO_InputCDR input (cdr);
CORBA::ULong len;
input.read_ulong (len);
if (len != i)
{
ACE_DEBUG ((LM_DEBUG,
"ERROR: mismatched lengths,"
" got %d, expected %d\n",
len, i));
}
ACE_Message_Block read_mb (len + ACE_CDR::MAX_ALIGNMENT);
ACE_CDR::mb_align (&mb);
mb.wr_ptr (len);
input.read_char_array (mb.rd_ptr (), len);
CORBA::Double read_dbl;
if (input.read_double (read_dbl) == 0)
ACE_DEBUG ((LM_DEBUG, "Failure reading double...\n"));
if (!ACE::is_equal (read_dbl, dbl))
{
status = 1;
ACE_DEBUG ((LM_DEBUG,
"ERROR: mismatched doubles,"
" got %f, expected %f\n",
read_dbl, dbl));
for (const ACE_Message_Block *j = cdr.begin ();
j != cdr.end ();
j = j->cont ())
{
ACE_HEX_DUMP ((LM_DEBUG,
j->rd_ptr (),
j->length (),
ACE_TEXT("Output CDR stream")));
}
TAO_InputCDR debug (cdr);
ACE_HEX_DUMP ((LM_DEBUG,
debug.rd_ptr (),
debug.length (),
ACE_TEXT("Input CDR stream")));
}
}
return status;
}
示例5: _tao_unmarshal_value_indirection
CORBA::Boolean
CORBA::ValueBase::_tao_unmarshal_pre (
TAO_InputCDR &strm,
CORBA::ValueBase *&valuetype,
const char *const fallback_repo_id,
CORBA::Boolean &is_null_object,
CORBA::Boolean &is_indirected)
{
// %! yet much to do ... look for +++ !
// 1. Get the <value-tag> (else it may be <indirection-tag> or <null-ref>).
// Is object yet unmarshalled (<indirection-tag> is set) ? (->1a)
// Is <null-ref> given ? Set 0 and return ok.
// 1a. Lookup the real address in memory, which should be aligned +++
// to CORBA::ValueBase. Its possible at this point that worse
// type mismatch gets by undetected, if the CDR stream fakes.
// So the type should be checked ... +++
// 2. Now at this point it must be a <value-tag> (error else).
// if (chunking) check that any last chunk ends with matching
// size. If not raise marshal exception.
// Increase the nesting level of valuetypes.
// 3. if (chunking) read and record the blocksize-tag.
// 4. Unmarshal type information and lookup factory.
// If no type information is given in the CDR encoding, as told
// from the <value-tag>, then use the repository id parameter
// (it _must_ be right).
CORBA::Boolean is_chunked = false;
// Save the position of the start of the ValueType
// to allow caching for later indirection.
if (strm.align_read_ptr (ACE_CDR::LONG_SIZE))
{
return false;
}
void *const start_of_valuetype = strm.rd_ptr();
Repository_Id_List ids;
CORBA::Boolean result =
CORBA::ValueBase::_tao_unmarshal_header (
strm, fallback_repo_id, ids,
is_null_object, is_indirected, is_chunked);
if (!result || is_null_object)
{
valuetype = 0;
return result;
}
if (is_indirected)
{
return _tao_unmarshal_value_indirection (strm, valuetype);
}
CORBA::ValueBase::_tao_unmarshal_find_factory (
strm, start_of_valuetype, valuetype, ids, is_chunked);
return true;
}
示例6: _tao_unmarshal_codebase_url_indirection
CORBA::Boolean
CORBA::ValueBase::_tao_read_codebase_url (TAO_InputCDR& strm,
ACE_CString& codebase_url)
{
CORBA::ULong length = 0;
size_t buffer_size = strm.length();
if (!strm.read_ulong (length))
{
return 0;
}
VERIFY_MAP (TAO_InputCDR, codebase_url_map, Codebase_URL_Map);
char * pos = strm.rd_ptr();
// 'length' may not be the codebase url length - it could be the
// FFFFFFF indirection marker instead. If it is an indirection marker, we
// get the offset following the indirection marker, otherwise we can follow
// the same logic using the offset to simply rewind to the start of length
// and re-read the length as part of the string
if (TAO_OBV_GIOP_Flags::is_indirection_tag (length))
{
return _tao_unmarshal_codebase_url_indirection (strm, codebase_url);
}
pos -= sizeof (CORBA::ULong);
// Cribbed from tc_demarshal_indirection in Typecode_CDR_Extraction.cpp
TAO_InputCDR url_stream (pos,
buffer_size,
strm.byte_order ());
if (!url_stream.good_bit ())
{
return 0;
}
if (! url_stream.read_string (codebase_url))
return 0;
// It's possible the codebase url is read again from an indirection stream,
// so make sure the codebase url is the same.
ACE_CString mapped_url;
if (strm.get_codebase_url_map ()->get()->find (pos, mapped_url) == 0)
{
if (TAO_debug_level)
{
TAOLIB_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_read_codebase_url, found %x=%C\n"),
pos, mapped_url.c_str ()));
}
if (ACE_OS::strcmp (mapped_url.c_str (), codebase_url.c_str ()) != 0)
throw CORBA::INTERNAL ();
}
else if (strm.get_codebase_url_map ()->get()->bind (pos, codebase_url) != 0)
{
throw CORBA::INTERNAL ();
}
else
{
if (TAO_debug_level)
{
TAOLIB_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO (%P|%t) - %N:%l ValueBase::_tao_read_codebase_url, bound %x=%C\n"),
pos, codebase_url.c_str ()));
}
}
// Since the codebase url is always read from the indirection cdr we have to skip
// the main CDR forward if we were in fact reading from the current
// location and not rewinding back some offset.
strm.skip_bytes (length);
return 1;
}
示例7: if
CORBA::Boolean
TAO_ChunkInfo::handle_chunking (TAO_InputCDR &strm)
{
if (!this->chunking_)
{
return 1;
}
char* the_rd_ptr = strm.start()->rd_ptr ();
//This case could happen if a handle_chunking() reads a chunk size
//and then calls the handle_chunking() again without reading the chunk data.
//The handle_chunking() called continuously without reading the chunk data
//only happens at the beginning of _tao_unmarshal_state() in a valuetype
//that has parents.
if (the_rd_ptr < this->chunk_octets_end_pos_)
{
++this->value_nesting_level_;
return 1;
}
//Safty check if reading is out of range of current chunk.
if (this->chunk_octets_end_pos_ != 0
&& the_rd_ptr > this->chunk_octets_end_pos_)
{
return 0;
}
// Read a long value that might be an endtag, the chunk size or the value tag
// of the nested valuetype.
CORBA::Long tag;
if (!strm.read_long (tag))
{
return 0;
}
if (tag < 0)
{
// tag is an end tag
if (-tag > this->value_nesting_level_)
{
TAOLIB_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("TAO (%P|%t) - %N:%l TAO_ChunkInfo::handle_chunking, received end tag ")
ACE_TEXT ("%d > value_nesting_level %d\n"),
-tag,
this->value_nesting_level_),
0);
}
this->value_nesting_level_ = - tag;
--this->value_nesting_level_;
this->chunk_octets_end_pos_ = 0;
// Continue reading so that we can read the outmost endtag. This
// would simplify the implementation in the derived valuetype.
if (this->value_nesting_level_ > 0)
{
this->handle_chunking(strm);
}
}
else if (tag < TAO_OBV_GIOP_Flags::Value_tag_base)
{
// Read the chunk size of another chunk.
this->chunk_octets_end_pos_ = strm.rd_ptr () + tag;
++this->value_nesting_level_;
}
else // (tag >= 0x7fffff00)
{
// This should not happen since the valuetag of the nested
// values are always unmarshalled in the
// ValueBase::_tao_unmarshal_pre().
return 0;
}
return 1;
}