static MI_Result _PutValue()

in LCM/codec/mof/mofserializer.c [578:665]


static MI_Result _PutValue(
    _Inout_ Buf* out,
    _In_ const MI_Value* value,
    MI_Type type,
    _Inout_ Aliases* aliases)
{
    switch (type)
    {
        case MI_BOOLEAN:
        case MI_UINT8:
        case MI_SINT8:
        case MI_UINT16:
        case MI_SINT16:
        case MI_UINT32:
        case MI_SINT32:
        case MI_UINT64:
        case MI_SINT64:
        case MI_REAL32:
        case MI_REAL64:
        case MI_CHAR16:
        case MI_DATETIME:
        case MI_STRING:
        case MI_REFERENCE:
        case MI_INSTANCE:
        {
            RETERR(_PutScalarValue(out, value, type, aliases));
            break;
        }
        case MI_BOOLEANA:
        case MI_UINT8A:
        case MI_SINT8A:
        case MI_UINT16A:
        case MI_SINT16A:
        case MI_UINT32A:
        case MI_SINT32A:
        case MI_UINT64A:
        case MI_SINT64A:
        case MI_REAL32A:
        case MI_REAL64A:
        case MI_CHAR16A:
        case MI_DATETIMEA:
        case MI_STRINGA:
        case MI_REFERENCEA:
        case MI_INSTANCEA:
        {
            MI_Uint32 i;
            MI_Type stype = (MI_Type)((MI_Uint32)type & 0x0000000F);
            size_t ssize = _scalarSizes[(MI_Uint32)stype];
            MI_Uint8* sdata = value->array.data;

            /* Put opening brace */

            RETERR(Buf_Put(out, LIT("{")));

            /* Put comma-separated elements */

            for (i = 0; i < value->array.size; i++)
            {
                MI_Value svalue;

#ifdef _PREFAST_
# pragma prefast (push)
# pragma prefast (disable: 26015)
#endif
                memcpy(&svalue, sdata, ssize);
#ifdef _PREFAST_
# pragma prefast (pop)
#endif

                /* Put the value */
                RETERR(_PutScalarValue(out, &svalue, stype, aliases));

                /* Put the comma if not the last element */

                if (i + 1 != value->array.size)
                    RETERR(Buf_Put(out, LIT(", ")));

                sdata += ssize;
            }

            /* Put closing brace */

            RETERR(Buf_Put(out, LIT("}")));
        }
    }

    return MI_RESULT_OK;
}