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


C++ StrPtrLen::setPtrLen方法代码示例

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


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

示例1:

OSCL_EXPORT_REF bool
RTSPOutgoingMessage::addField(
    StrCSumPtrLen * newFieldName,
    const StrPtrLen *    newFieldValue
)
{
    StrPtrLen * fieldVal = const_cast<StrPtrLen *>(queryField(* newFieldName));

    uint32  extraSize;

    // check if this field already exists in the message
    //
    if (NULL == fieldVal)
    { // this field is new to the message

        // check that there are enough pointers
        if (RTSP_MAX_NUMBER_OF_FIELDS == numPtrFields)
        {
            return false;
        }

        // check for the extra size
        extraSize = newFieldName->length() + newFieldValue->length() + 2;
        if (RTSP_MAX_FULL_REQUEST_SIZE < secondaryBufferSizeUsed + extraSize)
        {
            return false;
        }

        // oscl_memcpy is unsafe for overlaps, but source and target memory come from
        // different sources
        //
        oscl_memcpy(secondaryBufferSpace, newFieldName->c_str(),
                    newFieldName->length() + 1);
        oscl_memcpy(secondaryBufferSpace + newFieldName->length() + 1,
                    newFieldValue->c_str(), newFieldValue->length() + 1);

        // save the incoming structures, but reset pointers to their new home in the
        // secondary buffer

        fieldKeys[ numPtrFields ].setPtrLen(secondaryBufferSpace,
                                            newFieldName->length());
        fieldVals[ numPtrFields ].setPtrLen(
            secondaryBufferSpace + newFieldName->length() + 1,
            newFieldValue->length()
        );

        // pop up the number of used pointers
        //
        ++ numPtrFields;

        // do buffer accounting
        //
    }
    else
    { // this field is known to the message, we just have to replace its value

        // check for the extra size
        extraSize = newFieldValue->length() + 1;
        if (RTSP_MAX_FULL_REQUEST_SIZE < secondaryBufferSizeUsed + extraSize)
        {
            return false;
        }

        // oscl_memcpy is unsafe for overlaps, but source and target memory come from
        // different sources
        //
        oscl_memcpy(secondaryBufferSpace, newFieldValue->c_str(),
                    newFieldValue->length() + 1);

        // save the incoming structures, but reset pointers to their new home in the
        // secondary buffer

        fieldVal->setPtrLen(secondaryBufferSpace, newFieldValue->length());
    }

    secondaryBufferSizeUsed += extraSize;
    secondaryBufferSpace = secondaryBuffer + secondaryBufferSizeUsed;

    return true;
}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:80,代码来源:rtsp_par_com_outgoing_message.cpp


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