本文整理汇总了C++中ACE_InputCDR::good_bit方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_InputCDR::good_bit方法的具体用法?C++ ACE_InputCDR::good_bit怎么用?C++ ACE_InputCDR::good_bit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_InputCDR
的用法示例。
在下文中一共展示了ACE_InputCDR::good_bit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//COFP13MPAggregateFlowStatsRequestMsg
CmResult COFP13MPAggregateFlowStatsRequestMsg::
StreamFrom(ACE_InputCDR &is)
{
if (COFP13MultipartMsg::StreamFrom(is) != CM_OK)
{
return CM_ERROR_FAILURE;
}
is>>m_stats_request.table_id;
is.read_octet_array(m_stats_request.pad,sizeof(m_stats_request.pad));
is>>m_stats_request.out_port;
is>>m_stats_request.out_group;
is.read_octet_array(m_stats_request.pad2,sizeof(m_stats_request.pad2));
is>>m_stats_request.cookie;
is>>m_stats_request.cookie_mask;
bool bGood = is.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
return m_match.StreamFrom(is);
}
示例2: StreamFrom
CmResult COFPSwitchConfig::StreamFrom(ACE_InputCDR &is)
{
CmResult lRet = CM_ERROR_FAILURE;
lRet = COFPMessage::StreamFrom(is);
if (CM_FAILED(lRet))
{
ACE_ERROR((LM_ERROR, ACE_TEXT("COFPSwitchConfig::StreamFrom, COFPMessage::StreamFrom fail\n")));
return lRet;
}
is>>m_wFlags;
is>>m_wMissSendLen;
bool bGood = is.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
return CM_OK;
}
示例3: 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;
}
示例4: 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;
}
示例5: os
//.........这里部分代码省略.........
const int opposite_byte_order = 1 - ACE_CDR_BYTE_ORDER;
{
double totalsecs = 0.0;
int n;
for (n = 0; n < niter; n++)
{
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("====== Read iteration %d\n"), n));
size_t size = (total + dst_offset) * H::size ();
ACE_InputCDR is (toread, size, opposite_byte_order);
// This is intrusive...
char* const end = is.rd_ptr () + size;
do_seal (end);
double secs = 0.0;
if (use_array)
{
{
int i;
for (i = 0; i < dst_offset; i++)
{
T v;
is >> v;
}
}
if (n == 0)
{
ACE_DEBUG((LM_DEBUG,
ACE_TEXT ("* src align = %d, dst align = %d\n"),
tellalign (is.rd_ptr ()),
tellalign (src)));
}
Crono crono;
crono.start ();
H::read_array (is, idata, total);
crono.stop ();
secs = crono.read_seconds ();
// Testing for good bit value. Try reading atleast 10
// times the size of total. It should fail with good bit
// set to 0.
H::read_array (is, idata, 10 * total);
if (is.good_bit () != 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Test for good bit failed in %s Array_test\n"),
H::name ()));
}
}
else
{
int i = 0;
Crono crono;
crono.start ();
while (i < total)
{
#if 0
T v;
is >> v;
static char rs[32 + 1];
CDR_Test<T,H>::ttoh (v, rs);
ACE_DEBUG ((LM_DEBUG, "Read idata[%d] = %s\n", i, rs));
idata[i] = v;
i++;
#else
is >> idata[i++];
is >> idata[i++];
is >> idata[i++];
is >> idata[i++];
#endif /* 0 */
}
crono.stop ();
secs = crono.read_seconds ();
}
totalsecs += secs;
if (!check_seal (end))
{
ACE_ERROR((LM_ERROR,
ACE_TEXT( "Broken seal, aborting.\n" )));
ACE_OS::exit(1);
}
}
totalsecs = totalsecs / niter;
ACE_DEBUG((LM_DEBUG,
ACE_TEXT ("Reading from stream %d %s values")
ACE_TEXT (" (byte swapping): %f seconds.\n"),
total,
H::name (),
totalsecs));
}
示例6: handle_input
//
// handle_input
//
int CUTS_TCPIP_Event_Handler::handle_input (ACE_HANDLE fd)
{
// Set the ACE_HANDLE as a socket stream.
ACE_SOCK_Stream stream (fd);
// @todo Since the header size is constant, we can create free list
// of the message blocks that are used to read the header from
// the stream.
// Read the event from the stream. The first chunk of the event
// is be the header information, which is of constrant size.
static const ssize_t header_size = 4 + // magic
4 + // byte order
2 + // version (x.x)
2 + // padding
16 + // UUID
4 + // event id
4; // payload size
ACE_Message_Block header (header_size);
ssize_t retcode = stream.recv_n (header.wr_ptr (), header_size);
if (retcode != header_size)
ACE_ERROR_RETURN ((LM_ERROR,
"%T (%t) - %M - invalid TCP/IP header\n"),
-1);
// Reflect the number of bytes read from the stream.
header.wr_ptr (header_size);
// Extract the header from the message block.
CUTS_TCPIP_SPEC spec;
ACE_CDR::ULong datasize;
ACE_InputCDR input (header.rd_ptr (), header_size);
// Read the SPEC and the datasize from the packet.
input >> spec;
input >> datasize;
if (!input.good_bit ())
ACE_ERROR_RETURN ((LM_ERROR,
"%T (%t) - %M - failed to read TCP/IP header\n"),
-1);
// Construct a chain of message blocks to read the payload associated
// with the received event.
ACE_Message_Block * mb = 0;
ACE_NEW_RETURN (mb, ACE_Message_Block (ACE_CDR::DEFAULT_BUFSIZE), -1);
ssize_t read_count;
ACE_Message_Block * head = mb;
ACE_Auto_Ptr <ACE_Message_Block> auto_clean (head);
for (size_t remaining = datasize; 0 != remaining; )
{
// Determine how much should be read in this attempt.
read_count =
ACE_CDR::DEFAULT_BUFSIZE < remaining ?
ACE_CDR::DEFAULT_BUFSIZE : remaining;
// Read the data from the stream.
retcode = stream.recv_n (mb->wr_ptr (), read_count);
if (retcode != read_count)
ACE_ERROR_RETURN ((LM_ERROR,
"%T - %M - %m\n"),
-1);
// Substract the amount from the remaining count.
mb->wr_ptr (read_count);
remaining -= read_count;
if (0 != remaining)
{
// Allocate a new block for the chain.
ACE_Message_Block * temp = 0;
ACE_NEW_RETURN (temp,
ACE_Message_Block (ACE_CDR::DEFAULT_BUFSIZE),
-1);
// Insert new block in the chain and move forward.
mb->cont (temp);
mb = temp;
}
}
// Since we have made it this far, we have successfully read the
// event and its payload from the socket. Now, pass the message
// the object manger, so it can dispatch it accordingly.
if (this->obj_mgr_ != 0)
{
iCCM::TCPIP_Servant * svnt = 0;
//.........这里部分代码省略.........
示例7: while
CmResult COFP13HelloMsg::StreamFrom(ACE_InputCDR &is)
{
CmResult lRet = CM_ERROR_FAILURE;
ACE_UINT16 i = 0;
bool bGood;
lRet = COFPMessage::StreamFrom(is);
if (CM_FAILED(lRet))
{
ACE_ERROR((LM_ERROR, ACE_TEXT("COFP13HelloMsg::StreamFrom(), COFPMessage::StreamFrom fail\n")));
return lRet;
}
if (m_wLength < COFPMessage::GetStreamLen())
{
ACE_ERROR((LM_ERROR,
ACE_TEXT("COFP13HelloMsg::StreamFrom(): "),
ACE_TEXT("m_wLength(%u) is less than COFPMessage::GetStreamLen()(%u).\n"),
m_wLength,
COFPMessage::GetStreamLen()));
return CM_ERROR_FAILURE;
}
ACE_UINT16 wElemListLen = m_wLength - COFPMessage::GetStreamLen();
ACE_UINT16 data_size = wElemListLen;
ACE_UINT16 iter_size = 0;
ACE_CDR::Octet *pElem = m_pElemList;
while (iter_size < wElemListLen)
{
ACE_UINT16 elem_type = 0;
ACE_UINT16 elem_size = 0; // length of the element, excluding paddings
is>>elem_type;
is>>elem_size;
bGood = is.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
ACE_DEBUG((LM_DEBUG, ACE_TEXT("COFP13HelloMsg::StreamFrom(): parse hello elem %u.\n"), i++));
ACE_DEBUG((LM_DEBUG, ACE_TEXT("elem_type=%u, elem_size=%u\n"), elem_type, elem_size));
SetHelloElemType(pElem, elem_type);
SetHelloElemLen(pElem, elem_size);
if (elem_size < 4)
{
ACE_ERROR((LM_ERROR,
ACE_TEXT("COFP13HelloMsg::StreamFrom(): elem_size(%u) error, less than 4.\n"),
elem_size));
return CM_ERROR_FAILURE;
}
if (((elem_size + 7)/8*8) > data_size)
{
ACE_ERROR((LM_ERROR,
ACE_TEXT("COFP13HelloMsg::StreamFrom(): "),
ACE_TEXT("((elem_size + 7)/8*8)=%u, greater than data_size(%u)\n"),
((elem_size + 7)/8*8),
data_size));
return CM_ERROR_FAILURE;
}
if (elem_type != OFPHET_VERSIONBITMAP)
{
ACE_ERROR((LM_ERROR,
ACE_TEXT("COFP13HelloMsg::StreamFrom(): elem_type(%u) isnot OFPHET_VERSIONBITMAP(%u)\n"),
elem_type,
OFPHET_VERSIONBITMAP));
return CM_ERROR_FAILURE;
}
ACE_UINT16 bitmap_size = elem_size-4;
CM_ASSERT_RETURN((bitmap_size/4*4 == bitmap_size), CM_ERROR_INVALID_ARG);
ACE_UINT16 iter_bitmap_size = 0;
ACE_UINT16 bitmap_index = 0;
while (iter_bitmap_size < bitmap_size)//(bitmap_size > 0)
{
ACE_UINT32 bitmap = 0;
is>>bitmap;
bGood = is.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
ACE_DEBUG((LM_DEBUG, ACE_TEXT("bitmap[%u]=%u\n"), bitmap_index, bitmap));
SetVerBMHelloElemBitmap(pElem, bitmap_index++, bitmap);
//bitmap_size -= sizeof(bitmap);
iter_bitmap_size += sizeof(bitmap);
}
// deal with paddings
ACE_UINT16 pad_size = (elem_size + 7)/8*8 - elem_size;
is.read_octet_array(pElem + 4 + bitmap_index * sizeof(ACE_UINT32), pad_size);
bGood = is.good_bit();
CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
data_size -= (elem_size + pad_size);
iter_size += (elem_size + pad_size);
pElem += (elem_size + pad_size);
//.........这里部分代码省略.........