本文整理汇总了C++中StringRef::Resize1D方法的典型用法代码示例。如果您正苦于以下问题:C++ StringRef::Resize1D方法的具体用法?C++ StringRef::Resize1D怎么用?C++ StringRef::Resize1D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringRef
的用法示例。
在下文中一共展示了StringRef::Resize1D方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EggShell_ReadValueString
//------------------------------------------------------------
//! Read a symbol's value as a string. Value will be formatted according to designated format.
VIREO_EXPORT EggShellResult EggShell_ReadValueString(TypeManagerRef tm, const TypeRef typeRef, void* pData, const char* format, UInt8** valueString)
{
TypeManagerScope scope(tm);
if (typeRef == nullptr || !typeRef->IsValid())
return kEggShellResult_InvalidTypeRef;
static StringRef returnBuffer = nullptr;
if (returnBuffer == nullptr) {
// Allocate a string the first time it is used.
// After that it will be resized as needed.
STACK_VAR(String, tempReturn);
returnBuffer = tempReturn.DetachValue();
} else {
returnBuffer->Resize1D(0);
}
if (returnBuffer) {
SubString formatss(format);
TDViaFormatter formatter(returnBuffer, true, 0, &formatss, kJSONEncodingEggShell);
formatter.FormatData(typeRef, pData);
// Add an explicit null terminator so it looks like a C string.
returnBuffer->Append((Utf8Char)'\0');
*valueString = returnBuffer->Begin();
return kEggShellResult_Success;
}
return kEggShellResult_UnableToCreateReturnBuffer;
}
示例2: TypeRef_ElementName
//------------------------------------------------------------
VIREO_EXPORT StringRef TypeRef_ElementName(TypeManagerRef tm, TypeRef typeRef)
{
TypeManagerScope scope(tm);
SubString name = typeRef->ElementName();
static StringRef returnBuffer = nullptr;
if (returnBuffer == nullptr) {
// Allocate a string the first time it is used.
// After that it will be resized as needed.
STACK_VAR(String, tempReturn);
returnBuffer = tempReturn.DetachValue();
} else {
returnBuffer->Resize1D(name.Length());
}
if (returnBuffer) {
returnBuffer->CopyFromSubString(&name);
return returnBuffer;
}
return nullptr;
}