当前位置: 首页>>代码示例>>C++>>正文


C++ ACE_InputCDR类代码示例

本文整理汇总了C++中ACE_InputCDR的典型用法代码示例。如果您正苦于以下问题:C++ ACE_InputCDR类的具体用法?C++ ACE_InputCDR怎么用?C++ ACE_InputCDR使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ACE_InputCDR类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: StreamFrom

//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);

}
开发者ID:chenbk85,项目名称:WOAL,代码行数:26,代码来源:COFPMPAggregateFlowStatisticsMsg.cpp

示例2: ACE_Message_Block

int Logging_Handler::recv_log_record (ACE_Message_Block *&mblk)
{
  // Put <logging_peer>'s hostname in new message block.
  ACE_INET_Addr peer_addr;
  logging_peer_.get_remote_addr (peer_addr);
  mblk = new ACE_Message_Block (MAXHOSTNAMELEN + 1);
  peer_addr.get_host_name (mblk->wr_ptr (), MAXHOSTNAMELEN);
  mblk->wr_ptr (ACE_OS::strlen (mblk->wr_ptr ()) + 1); // Go past name

  // Allocate a message block for the payload; initially at least
  // large enough to hold the header, but needs some room for
  // alignment.
  ACE_Message_Block *payload =
    new ACE_Message_Block (ACE_DEFAULT_CDR_BUFSIZE);
  // Align the Message Block for a CDR stream
  ACE_CDR::mb_align (payload);
  if (logging_peer_.recv_n (payload->wr_ptr (), 8) == 8) {
    payload->wr_ptr (8);               // Reflect addition of 8 bytes

    // Create a CDR stream to parse the 8-byte header.
    ACE_InputCDR cdr (payload);

    // Extract the byte-order and use helper methods to
    // disambiguate octet, booleans, and chars.
    ACE_CDR::Boolean byte_order;
    cdr >> ACE_InputCDR::to_boolean (byte_order);

    // Set the byte-order on the stream...
    cdr.reset_byte_order (byte_order);

    // Extract the length
    ACE_CDR::ULong length;
    cdr >> length;

    // Ensure there's sufficient room for log record payload.
    ACE_CDR::grow (payload, 8 + ACE_CDR::MAX_ALIGNMENT + length);

    // Use <recv_n> to obtain the contents.
    if (logging_peer_.recv_n (payload->wr_ptr (), length) > 0) {
      payload->wr_ptr (length);   // Reflect additional bytes
      // Chain the payload to mblk via the contination field.
      mblk->cont (payload);
      return length;
    }
  }
开发者ID:CCJY,项目名称:ACE,代码行数:45,代码来源:Logging_Handler.cpp

示例3: if

ACE_CDR::Boolean
UTF16_UCS2_Translator::read_wstring (ACE_InputCDR &cdr,
                                    ACE_CDR::WChar *&x)
{
  ACE_CDR::ULong len;
  if (!this->read_4 (cdr, &len))
    return 0;

  // A check for the length being too great is done later in the
  // call to read_char_array but we want to have it done before
  // the memory is allocated.
  if (len > 0 && len <= cdr.length())
    {
      if (static_cast <ACE_CDR::Short> (this->major_version(cdr)) == 1
          && static_cast <ACE_CDR::Short> (this->minor_version(cdr)) == 2)
        {
          len /= ACE_UTF16_CODEPOINT_SIZE;

          //allocating one extra for the null character needed by applications
          ACE_NEW_RETURN (x,
                          ACE_CDR::WChar [len + 1],
                          0);

          x[len] = L'\x00';
          if (this->read_wchar_array_i (cdr, x, len, 1))
            {
              // Since reading the array may have adjusted the length,
              // we simply rewrite the null terminator
              x[len] = L'\x00';
              return 1;
            }
        }
      else
        {
          ACE_NEW_RETURN (x,
                          ACE_CDR::WChar [len],
                          0);
          if (this->read_wchar_array (cdr, x, len))
            return 1;
        }
      delete [] x;
    }
  else if (len == 0)
    {
      // Convert any null strings to empty strings since empty
      // strings can cause crashes. (See bug 58.)
      ACE_NEW_RETURN (x,
                      ACE_CDR::WChar[1],
                      0);
      x[0] = '\x00';
      return 1;
    }
  x = 0;
  return 0;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:55,代码来源:UTF16_UCS2_Translator.cpp

示例4: if

void AIO_Input_Handler::handle_read_stream
    (const ACE_Asynch_Read_Stream::Result &result) {
  if (!result.success () || result.bytes_transferred () == 0)
    delete this;
  else if (result.bytes_transferred () < result.bytes_to_read ())
    reader_.read (*mblk_, result.bytes_to_read () -
                  result.bytes_transferred ());
  else if (mblk_->length () == LOG_HEADER_SIZE) {
    ACE_InputCDR cdr (mblk_);

    ACE_CDR::Boolean byte_order;
    cdr >> ACE_InputCDR::to_boolean (byte_order);
    cdr.reset_byte_order (byte_order);

    ACE_CDR::ULong length;
    cdr >> length;

    mblk_->size (length + LOG_HEADER_SIZE);
    reader_.read (*mblk_, length);
  }
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:20,代码来源:AIO_Client_Logging_Daemon.cpp

示例5: 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;
}
开发者ID:chenbk85,项目名称:WOAL,代码行数:18,代码来源:COFPSwitchConfig.cpp

示例6:

ACE_CDR::Boolean
ACE_ISO8859_IBM1047::read_string (ACE_InputCDR &in,
                                  ACE_CDR::Char *&x)
{
  ACE_CDR::ULong len;

  in.read_ulong (len);

  if (len > 0)
    {
      ACE_NEW_RETURN (x,
                      ACE_CDR::Char[len],
                      0);

      if (this->read_char_array (in, x, len))
        return 1;

      delete [] x;
    }

  x = 0;
  return 0;
}
开发者ID:binary42,项目名称:OCI,代码行数:23,代码来源:Codeset_IBM1047.cpp

示例7: defined

ACE_CDR::Boolean
UTF16_UCS2_Translator::read_wchar_array_i (ACE_InputCDR & cdr,
                                           ACE_CDR::WChar *x,
                                           ACE_CDR::ULong &length,
                                           int)
{
  int must_swap = 0;
  char* buf;
  static const size_t align = ACE_CDR::SHORT_ALIGN;
  if (cdr.adjust (ACE_UTF16_CODEPOINT_SIZE * length, align, buf) == 0)
    {
      ACE_UTF16_T *sb = reinterpret_cast <ACE_UTF16_T *> (buf);
#if defined (ACE_LITTLE_ENDIAN)
          must_swap = 1;
#endif // ACE_LITTLE_ENDIAN

      for (size_t i = 0; i < length; ++i)
#if defined (ACE_DISABLE_SWAP_ON_READ)
        x[i] = static_cast <ACE_CDR::WChar> (sb[i]);
#else
      if (!must_swap)
        {
          x[i] = static_cast <ACE_CDR::WChar> (sb[i]);
        }
      else
        {
          ACE_CDR::UShort sx;
          ACE_CDR::swap_2 (&buf[i*2], reinterpret_cast <char *> (&sx));
          x[i] = static_cast <ACE_CDR::WChar> (sx);
        }
#endif /* ACE_DISABLE_SWAP_ON_READ */

      return 1;
    }
  return 0;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:36,代码来源:UTF16_UCS2_Translator.cpp

示例8: sizeof

CmResult COFP13TableFeatureProp::DecodeMPTFP(ACE_InputCDR &is, COFP13TableFeatureProp * &prop)
{
    ACE_UINT16 type;
    bool bGood = is.pre_read(&type, sizeof(type));
    CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
    ACE_CDR::swap_2(reinterpret_cast<const char *>(&type), reinterpret_cast<char *>(&type));

    COFP13TableFeatureProp *propData = nullptr;
    ACE_DEBUG((LM_DEBUG, ACE_TEXT("COFP13TableFeatureProp::DecodeMPTFP, type=%u\n"), type));

    switch (type)
    {
        case OFPTFPT_INSTRUCTIONS:
        case OFPTFPT_INSTRUCTIONS_MISS:
        {
            propData = new COFP13TableFeaturePropInstruct(type);
            break;
        }
        case OFPTFPT_EXPERIMENTER:
        case OFPTFPT_EXPERIMENTER_MISS:
        {
            propData = new COFP13TableFeaturePropExperimenter(type);
            break;
        }
        case OFPTFPT_NEXT_TABLES:
        case OFPTFPT_NEXT_TABLES_MISS:
        {
            propData = new COFP13TableFeaturePropNextTables(type);
        }
        case OFPTFPT_WRITE_ACTIONS:
        case OFPTFPT_WRITE_ACTIONS_MISS:
        case OFPTFPT_APPLY_ACTIONS:
        case OFPTFPT_APPLY_ACTIONS_MISS:
        {
            propData = new COFP13TableFeaturePropActions(type);
        }
        case OFPTFPT_MATCH:
        case OFPTFPT_WILDCARDS:
        case OFPTFPT_WRITE_SETFIELD:
        case OFPTFPT_WRITE_SETFIELD_MISS:
        case OFPTFPT_APPLY_SETFIELD:
        case OFPTFPT_APPLY_SETFIELD_MISS:
        {
            propData = new COFP13TableFeaturePropOXM(type);
        }
        default:
        {
            break;
        }
    }
    CM_ASSERT_RETURN(propData != nullptr, CM_ERROR_OUT_OF_MEMORY);

    CmResult rv = propData->StreamFrom(is);
    if (CM_FAILED(rv))
    {
        ACE_ERROR((LM_ERROR, ACE_TEXT("COFP13TableFeatureProp::DecodeMPTFP error\n")));
        return CM_ERROR_FAILURE;
    }

    prop = propData;

    return CM_OK;
}
开发者ID:chenbk85,项目名称:WOAL,代码行数:63,代码来源:COFPTableFeatureProp.cpp

示例9: short_stream

static int
short_stream (void)
{
  // counter
  u_int i;

  // Build an output stream
  ACE_OutputCDR os;

  // Basic types for output
  ACE_CDR::Char ch = 'A';
  ACE_CDR::Char wchtmp[] = {"\xF3"};
  ACE_CDR::WChar wch = *wchtmp;
  ACE_CString str ("Test String");
  ACE_CDR::Short s = -123;
  ACE_CDR::UShort us =  123;
  ACE_CDR::Long l = -65800L;
  ACE_CDR::ULong ul =  65800UL;
  ACE_CDR::Float f =  1.23f;
  ACE_CDR::Double d =  123.456789;

  // Arrays for output
  ACE_CDR::Short s_array[3] = { -1, 0, 1 };
  ACE_CDR::Long l_array[3] = { -345678, 0, 345678 };
  ACE_CDR::Float f_array[3] = { -1.23f, 0.0f, 1.23f };
  ACE_CDR::Double d_array[3] = { -123.456789, 0.0, 123.456789 };

  ACE_OutputCDR::from_char fc (ch);
  os << fc;
  ACE_OutputCDR::from_wchar fwc (wch);
  os << fwc;
  os << str;
  os << s;
  os << us;
  os << l;
  os << ul;
  os << f;
  os << d;
  os.write_short_array (s_array, 3);
  os.write_long_array (l_array, 3);
  os.write_float_array (f_array, 3);
  os.write_double_array (d_array, 3);

  const ACE_Message_Block *out_mb = os.begin ();
  u_int len = out_mb->length ();

  // Create an input stream (copy constructor)
  ACE_InputCDR is (os);
  const ACE_Message_Block *in_mb = is.start ();

  if (in_mb->length () != len)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%p\n"),
                       ACE_TEXT ("buffer length not preserved")),
                      1);

  u_long in_chunk, out_chunk;

  for (i = 0; i < len; i++)
    {
      in_chunk = u_long (* (in_mb->rd_ptr () + i));
      out_chunk = u_long (* (out_mb->rd_ptr () + i));
      if (in_chunk != out_chunk )
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("%p\n"),
                           ACE_TEXT ("buffer contents not preserved")),
                          1);
    }

  // Basic types for input
  ACE_CDR::Char ch1 = '\0';
  ACE_CDR::WChar wch1 = '\x00';
  ACE_CString str1;
  ACE_CDR::Short s1 = 0;
  ACE_CDR::UShort us1 = 0;
  ACE_CDR::Long l1 = 0L;
  ACE_CDR::ULong ul1 = 0UL;
  ACE_CDR::Float f1 = 0.0f;
  ACE_CDR::Double d1 = 0.0;

  // Arrays for input
  ACE_CDR::Short s_array1[3];
  ACE_CDR::Long l_array1[3];
  ACE_CDR::Float f_array1[3];
  ACE_CDR::Double d_array1[3];

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("Checking operators and arrays\n\n")));

  ACE_InputCDR::to_char tc (ch1);
  is >> tc;
  ACE_InputCDR::to_wchar twc (wch1);
  is >> twc;
  is >> str1;
  is >> s1;
  is >> us1;
  is >> l1;
  is >> ul1;
  is >> f1;
  is >> d1;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例10: main

int
main (int argc, ACE_TCHAR *argv[])
{
  ACE_START_TEST (ACE_TEXT ("CDR_Test"));

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("This is ACE Version %u.%u.%u\n\n"),
              ACE::major_version (),
              ACE::minor_version(),
              ACE::beta_version()));

  ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("dn:l:"));
  int opt;
  int debug = 0;

  while ((opt = get_opt ()) != EOF)
    {
      switch (opt)
        {
          case 'd':
            debug++;
            break;
          case 'n':
            n = ACE_OS::atoi (get_opt.optarg);
            break;
          case 'l':
            nloops = ACE_OS::atoi (get_opt.optarg);
            break;
          case '?':
          default:
            ACE_DEBUG ((LM_DEBUG,
                        ACE_TEXT ("Usage: %s ")
                        ACE_TEXT ("-d debug")
                        ACE_TEXT ("-n <num> ")
                        ACE_TEXT ("-l <loops> ")
                        ACE_TEXT ("\n"),
                        argv[0]));
            return -1;
        }
    }

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("Testing ACE CDR functions - short stream\n\n")));

  if (short_stream () != 0 )
    return 1;

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("Short stream - no errors\n\n")
              ACE_TEXT ("Testing basic types - long stream\n\n")));

  for (int i = 0; i < nloops; ++i)
    {
      ACE_OutputCDR output;
      CDR_Test_Types test_types;

      if (test_types.test_put (output) != 0)
        return 1;

      ACE_InputCDR input (output);
      if (debug > 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("Output CDR: \n")));
          ACE_HEX_DUMP ((LM_DEBUG,
                         input.rd_ptr(),
                         64));
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("Input CDR: \n")));
          ACE_HEX_DUMP ((LM_DEBUG,
                         input.rd_ptr(),
                         64));
        }

      if (test_types.test_get (input) != 0)
        return 1;
    }

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("Long stream - no errors\n\n")
              ACE_TEXT ("Testing basic types - long stream[2]\n\n")));

  for (int j = 0; j < nloops; ++j)
    {
      ACE_OutputCDR output;
      CDR_Test_Types test_types;

      if (test_types.test_put (output) != 0)
        return 1;

      ACE_InputCDR input (output.begin ());
      if (debug > 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("Output CDR: \n")));
          ACE_HEX_DUMP ((LM_DEBUG,
                         input.rd_ptr(),
                         64));
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("Input CDR: \n")));
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例11:

int
CDR_Test_Types::test_get (ACE_InputCDR &cdr) const
{
  ACE_CDR::Octet xo;
  ACE_CDR::Short xs;
  ACE_CDR::Long xl;

  for (int i = 0; i < n; ++i)
    {
      if (cdr.read_octet (xo) == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("read_octet[%d] failed\n"),
                           i),
                          1);
      if (xo != this->o)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("octet[%d] differs\n"),
                           i),
                          1);
      if (cdr.read_short (xs) == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("read_short[%d] failed\n"),
                           i), 1);
      if (xs != this->s)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("short[%d] differs\n"),
                           i),
                          1);
      if (cdr.read_octet (xo) == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("read_octet-2[%d] failed\n"),
                           i),
                          1);
      if (xo != this->o)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("octet-2[%d] differs\n"),
                           i),
                          1);
      if (cdr.read_long (xl) == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("read_long[%d] failed\n"),
                           i),
                          1);
      if (xl != this->l)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("long[%d] differs\n"),
                           i),
                          1);
      if (cdr.read_long (xl) == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("read_long-2[%d] failed\n"),
                           i),
                          1);
      if (xl != this->l)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("long-2[%d] differs\n"),
                           i),
                          1);

      ACE_CDR::Char *xstr;
      if (cdr.read_string (xstr) == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("read_string2[%d] failed\n"),
                           i),
                          1);
      ACE_Auto_Basic_Array_Ptr<ACE_CDR::Char> auto_xstr (xstr);
      if (ACE_OS::strcmp (auto_xstr.get (), this->str) != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("string[%d] differs\n"),
                           i),
                          1);
    }
  return 0;
}
开发者ID:,项目名称:,代码行数:74,代码来源:

示例12: ACE_DEBUG

void
UDPGenerator::handle_read_dgram (const ACE_Asynch_Read_Dgram::Result &result)
{
    ACE_DEBUG ((LM_DEBUG, "handle_read_dgram called\n"));

    ACE_DEBUG ((LM_DEBUG, "********************\n"));/*{{{*/
    ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_read", result.bytes_to_read ()));
    ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ()));
    ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ()));
    ACE_INET_Addr peerAddr;
    result.remote_address (peerAddr);
    ACE_DEBUG ((LM_DEBUG, "%s = %s:%d\n", "peer_address", peerAddr.get_host_addr (), peerAddr.get_port_number ()));
    ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "flags", result.flags ()));
    ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "act", result.act ()));
    ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ()));
    ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "completion_key", result.completion_key ()));
    ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ()));
    ACE_DEBUG ((LM_DEBUG, "********************\n"));/*}}}*/

    if (result.success () && result.bytes_transferred () != 0)
    {
        const ACE_Message_Block * msg = result.message_block();

        ACE_InputCDR cdr (msg->cont());

        ACE_CDR::Boolean byte_order;
        cdr >> ACE_InputCDR::to_boolean (byte_order);
        cdr.reset_byte_order(byte_order);
        ACE_CDR::ULong length;
        cdr >> length;

        ACE_InputCDR cdrpayload(msg->cont());
        cdrpayload.reset_byte_order(byte_order);
        DataGloveData glovedata;
        cdrpayload >> glovedata;

        // loop through our message block and print out the contents/*{{{*/
        //for (const ACE_Message_Block* msg = result.message_block(); msg != 0; msg = msg->cont ())
        //  { // use msg->length() to get the number of bytes written to the message
        // block.
        //if (msg->length() == 8)
        //{
        //    ACE_InputCDR cdr (msg);

        //    ACE_CDR::Boolean byte_order;
        //    cdr >> ACE_InputCDR::to_boolean (byte_order);
        //    cdr.reset_byte_order(byte_order);
        //    ACE_CDR::ULong length;
        //    cdr >> length;

        //    ACE_InputCDR cdrpayload(msg->cont());
        //    cdrpayload.reset_byte_order(byte_order);
        //    DataGloveData glovedata;
        //    cdrpayload >> glovedata;
        //    continue;
        //}
        //else
        //{
        //       ACE_DEBUG ((LM_DEBUG, "Buf=[size=<%d>", msg->length ()));
        //      for (u_long i = 0; i < msg->length(); ++i)
        //         ACE_DEBUG ((LM_DEBUG, "%c", (msg->rd_ptr())[i]));
        //    ACE_DEBUG ((LM_DEBUG, "]\n"));
        //}/*}}}*/
        //}
    }

    ACE_DEBUG ((LM_DEBUG, "Receive completed\n"));

    // No need for this message block anymore.
    result.message_block ()->release ();
    readdatagram(4);

    // Note that we are done with the test.
    done++;
}
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:75,代码来源:UDPGenerator.cpp

示例13: 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;
}
开发者ID:chenbk85,项目名称:WOAL,代码行数:80,代码来源:COFPPacketOutMsg.cpp

示例14: ACE_DEBUG


//.........这里部分代码省略.........
          }
      }

    totalsecs = totalsecs / niter;

    ACE_DEBUG((LM_DEBUG,
               ACE_TEXT ("Writing to stream %d %s values: %f seconds.\n"),
               total,
               H::name (),
               totalsecs));
  }

  {
    int i;
    for (i = 0; i < total; i++)
      {
        idata[i] = 0;
      }
  }

  ACE_DEBUG((LM_DEBUG,
             ACE_TEXT( "Reading them back in opposing byte order...\n" )));

  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 ();
开发者ID:helixum,项目名称:wow-cata,代码行数:66,代码来源:CDR_Array_Test.cpp

示例15: stream

//
// 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;
//.........这里部分代码省略.........
开发者ID:SEDS,项目名称:CUTS,代码行数:101,代码来源:TCPIP_Event_Handler.cpp


注:本文中的ACE_InputCDR类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。