Example #1
//! 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 {

    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.
        *valueString = returnBuffer->Begin();
        return kEggShellResult_Success;

    return kEggShellResult_UnableToCreateReturnBuffer;
Example #2
void CopyArrayTypeNameStringToBuffer(StringRef arrayTypeNameBuffer, SubString arrayTypeName)
    arrayTypeNameBuffer->Append(arrayTypeName.Length(), static_cast<const Utf8Char*>(arrayTypeName.Begin()));