本文整理汇总了C++中ACE_InputCDR::read_char_array方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_InputCDR::read_char_array方法的具体用法?C++ ACE_InputCDR::read_char_array怎么用?C++ ACE_InputCDR::read_char_array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_InputCDR
的用法示例。
在下文中一共展示了ACE_InputCDR::read_char_array方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Data
CmResult COFP10PacketOutMsg::StreamFrom(ACE_InputCDR &is)
{
CmResult lRet = CM_ERROR_FAILURE;
lRet = COFPMessage::StreamFrom(is);
if (CM_FAILED(lRet))
{
ACE_ERROR((LM_ERROR, ACE_TEXT("COFP10PacketOutMsg::StreamFrom, COFPMessage::StreamFrom fail\n")));
return lRet;
}
is>>m_tMember.buffer_id;
is>>m_tMember.in_port;
is>>m_tMember.actions_len;
bool bGood = is.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
if (m_tMember.actions_len > 0)
{
ACE_INT16 swListLen = m_tMember.actions_len;
ACE_UINT16 i = 0;
while (swListLen > 0)
{
COFP10Action *action = nullptr;
lRet = COFP10Action::DecodeAction(is, action);
if (CM_SUCCEEDED(lRet))
{
m_action_list.push_back(action);
ACE_DEBUG((LM_DEBUG, ACE_TEXT("action[%u], len=%u\n"), i++, action->GetActionLen()));
swListLen -= action->GetActionLen();
}
else
{
ACE_ERROR((LM_ERROR, ACE_TEXT("COFP10PacketOutMsg::StreamFrom, COFP10Action::DecodeAction failed\n")));
return CM_ERROR_FAILURE;
}
}
}
ACE_INT16 swDataLen = m_wLength - COFPMessage::GetStreamLen() - sizeof(m_tMember) - m_tMember.actions_len;
if (swDataLen < 0)
{
ACE_ERROR((LM_ERROR,
ACE_TEXT("COFP10PacketOutMsg::StreamFrom, packet data len(%d) is invalid\n"),
swDataLen));
ACE_ASSERT(0);
return CM_ERROR_FAILURE;
}
if (swDataLen == 0)
{
m_wDataLen = 0;
return CM_OK;
}
ACE_Message_Block Data(swDataLen);
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("COFP10PacketOutMsg::StreamFrom, wr_ptr = %p, space = %u\n"),
Data.wr_ptr(),
Data.space()));
bGood = is.read_char_array(Data.wr_ptr(), swDataLen);
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
Data.wr_ptr((size_t)swDataLen);
if (m_PacketData)
{
m_PacketData->append(Data.duplicate());
}
else
{
m_PacketData = Data.duplicate();
}
m_wDataLen += swDataLen;
return CM_OK;
}
示例2: data
CmResult COFP13PacketOutMsg::StreamFrom(ACE_InputCDR &is)
{
ACE_INT32 remainActLen = 0;
ACE_INT32 packet_length = 0;
ACE_CDR::Octet pad[6];
CmResult lRet = CM_ERROR_FAILURE;
lRet = COFPMessage::StreamFrom(is);
if (CM_FAILED(lRet))
{
ACE_ERROR((LM_ERROR, ACE_TEXT("COFP13PacketOutMsg::StreamFrom(), COFPMessage::StreamFrom fail\n")));
return lRet;
}
ACE_DEBUG((LM_DEBUG, ACE_TEXT("COFP13PacketOutMsg::StreamFrom(): \n")));
is>>m_buffer_id;
is>>m_in_port;
is>>m_actions_len;
is.read_octet_array(pad, sizeof(pad));
bool bGood = is.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
ACE_DEBUG((LM_DEBUG, ACE_TEXT("m_actions_len=%u\n"), m_actions_len));
if (m_actions_len>0)
{
remainActLen = m_actions_len;
ACE_UINT16 i = 0;
while (remainActLen > 0)
{
COFP13Action *action = nullptr;
CmResult result = COFP13Action::DecodeAction(is, action);
if (CM_SUCCEEDED(result))
{
m_action_list.push_back(action);
ACE_DEBUG((LM_DEBUG, ACE_TEXT("action[%u], len=%u\n"), i++, action->GetStreamLen()));
remainActLen = remainActLen - (action->GetStreamLen());
}
else
{
ACE_ERROR((LM_ERROR, ACE_TEXT("COFP13Action::DecodeAction failed.\n")));
return CM_ERROR_FAILURE;
}
}
}
ACE_UINT32 length = sizeof(m_buffer_id)+sizeof(m_in_port)+sizeof(m_actions_len)+sizeof(m_pad);
ACE_DEBUG((LM_DEBUG, ACE_TEXT("length=%u\n"), length));
packet_length = m_wLength-COFPMessage::GetStreamLen()-length-m_actions_len;
ACE_DEBUG((LM_DEBUG, ACE_TEXT("packet_length=%d, GetStreamLen=%u\n"), packet_length, GetStreamLen()));
if (packet_length < 0)
{
ACE_ERROR((LM_ERROR,
ACE_TEXT("COFP13PacketOutMsg::StreamFrom, error, length=%u, actionlength=%u\n"),
length,
m_actions_len));
return CM_ERROR_FAILURE;
}
ACE_Message_Block data(packet_length);
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("COFP13PacketOutMsg::StreamFrom, wr_ptr=%p, space=%u\n"),
data.wr_ptr(),
data.space()));
bGood = is.read_char_array(data.wr_ptr(), packet_length);
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
data.wr_ptr((size_t)packet_length);
if (m_PacketData)
{
m_PacketData->append(data.duplicate());
}
else
{
m_PacketData = data.duplicate();
}
return CM_OK;
}
示例3: svc
//.........这里部分代码省略.........
(head, ACE_Message_Block (name_len, MB_CLIENT), 0);
head->copy (name_p, name_len);
mblk.rd_ptr (name_len + 1); // Skip nul also
size_t need = mblk.length () + ACE_CDR::MAX_ALIGNMENT;
ACE_NEW_RETURN (rec, ACE_Message_Block (need), 0);
ACE_CDR::mb_align (rec);
rec->copy (mblk.rd_ptr (), mblk.length ());
// Now rec contains the remaining data we've read so far from
// the file. Create an ACE_InputCDR to start demarshaling the
// log record, header first to find the length, then the data.
// Since the ACE_InputCDR constructor increases the reference count
// on rec, we release it upon return to prevent leaks.
// The cdr 'read' methods return 0 on failure, 1 on success.
ACE_InputCDR cdr (rec); rec->release ();
ACE_CDR::Boolean byte_order;
if (!cdr.read_boolean (byte_order)) {
head->release (); rec->release (); break;
}
cdr.reset_byte_order (byte_order);
// Now read the length of the record. From there, we'll know
// if rec contains the complete record or not.
ACE_CDR::ULong length;
if (!cdr.read_ulong (length)) {
head->release (); mblk.rd_ptr (name_p); break;
}
if (length > cdr.length ()) {
head->release (); mblk.rd_ptr (name_p); break;
}
// The complete record is in rec... grab all the fields into
// separate, chained message blocks.
ACE_NEW_RETURN (temp,
ACE_Message_Block (length, MB_TEXT),
0);
ACE_NEW_RETURN
(temp,
ACE_Message_Block (2 * sizeof (ACE_CDR::Long),
MB_TIME, temp),
0);
ACE_NEW_RETURN
(temp,
ACE_Message_Block (sizeof (ACE_CDR::Long),
MB_PID, temp),
0);
ACE_NEW_RETURN
(temp,
ACE_Message_Block (sizeof (ACE_CDR::Long),
MB_TYPE, temp),
0);
head->cont (temp);
// Extract the type
ACE_CDR::Long *lp;
lp = reinterpret_cast<ACE_CDR::Long*> (temp->wr_ptr ());
cdr >> *lp;
temp->wr_ptr (sizeof (ACE_CDR::Long));
temp = temp->cont ();
// Extract the pid
lp = reinterpret_cast<ACE_CDR::Long*> (temp->wr_ptr ());
cdr >> *lp;
temp->wr_ptr (sizeof (ACE_CDR::Long));
temp = temp->cont ();
// Extract the timestamp (2 Longs)
lp = reinterpret_cast<ACE_CDR::Long*> (temp->wr_ptr ());
cdr >> *lp; ++lp; cdr >> *lp;
temp->wr_ptr (2 * sizeof (ACE_CDR::Long));
temp = temp->cont ();
// Demarshal the length of the message text, then demarshal
// the text into the block.
ACE_CDR::ULong text_len;
cdr >> text_len;
cdr.read_char_array (temp->wr_ptr (), text_len);
temp->wr_ptr (text_len);
// Forward the whole lot to the next module.
if (put_next (head) == -1) break;
// Move the file-content block's read pointer up past whatever
// was just processed. Although the mblk's rd_ptr has not been
// moved, cdr's has. Therefore, use its length() to determine
// how much is left.
mblk.rd_ptr (mblk.length () - cdr.length ());
}
}
// Now that the file is done, send a block down the stream to tell
// the other modules to stop.
ACE_Message_Block *stop;
ACE_NEW_RETURN
(stop, ACE_Message_Block (0, ACE_Message_Block::MB_STOP),
0);
put_next (stop);
return 0;
}