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


C++ ACE_InputCDR::pre_read方法代码示例

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


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

示例1: 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

示例2: sizeof

CmResult COFP10Action::
DecodeAction(ACE_InputCDR& is, COFP10Action * &apAction)
{
    CmResult      lRet  = CM_ERROR_FAILURE;
    ACE_UINT16    wType = 0;
    COFP10Action *pAct  = nullptr;
    
    bool bGood = is.pre_read(&wType, sizeof(wType));
    CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
    
	ACE_CDR::swap_2(reinterpret_cast<const char *>(&wType), reinterpret_cast<char *>(&wType));

    switch (wType)
    {
        case OFPAT_OUTPUT:
        {
            pAct = new COFP10ActOutput();
            break;
        }
        case OFPAT_SET_VLAN_VID:
        {
            pAct = new COFP10ActSetVlanVid();
            break;
        }
        case OFPAT_SET_VLAN_PCP:
        {
            pAct = new COFP10ActSetVlanPcp();
            break;
        }
        case OFPAT_STRIP_VLAN:
        {
            pAct = new COFP10ActStripVlan();
            break;
        }
        case OFPAT_SET_DL_SRC:
        case OFPAT_SET_DL_DST:
        {
            pAct = new COFP10ActSetDlAddr(wType);
            break;
        }
        case OFPAT_SET_NW_SRC:
        case OFPAT_SET_NW_DST:
        {
            pAct = new COFP10ActSetNwAddr(wType);
            break;
        }
        case OFPAT_SET_NW_TOS:
        {
            pAct = new COFP10ActSetNwTos();
            break;
        }
        case OFPAT_SET_TP_SRC:
        case OFPAT_SET_TP_DST:
        {
            pAct = new COFP10ActSetTpPort(wType);
            break;
        }
        case OFPAT_ENQUEUE:
        {
            pAct = new COFP10ActEnqueue();
            break;
        }
        default:
        {
            break;
        }
    }
    
    CM_ASSERT_RETURN(pAct != nullptr, CM_ERROR_OUT_OF_MEMORY);

    lRet = pAct->StreamFrom(is);
    if (CM_FAILED(lRet))
    {
        ACE_ERROR((LM_ERROR, ACE_TEXT("COFP10Action::DecodeAction(): fail in StreamFrom(), lRet=%d\n"), lRet));
        return lRet;
    }

    apAction = pAct;
    
    return CM_OK;
}
开发者ID:chenbk85,项目名称:WOAL,代码行数:81,代码来源:COFP10Action.cpp


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