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


C++ StringRef::Resize1D方法代码示例

本文整理汇总了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;
}
开发者ID:ni,项目名称:VireoSDK,代码行数:31,代码来源:CEntryPoints.cpp

示例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;
}
开发者ID:ni,项目名称:VireoSDK,代码行数:23,代码来源:CEntryPoints.cpp


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