本文整理汇总了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