void PrintValue()

in LCM/codec/mof/parser/types.c [1820:1965]


void PrintValue(const void* value, MI_Type type, FILE* file)
{
    if (!value) 
    {
        fprintf(file,"NULL");
        return;
    }
    else 
    {
        switch (type)
        {
            case MI_BOOLEAN:
            {
                const MI_Boolean* p = (const MI_Boolean*)value;
                fprintf(file,"%s", *p ? "true" : "false");
                break;
            }
            case MI_SINT8:
            {
                fprintf(file,"%d", *((const MI_Sint8*)value));
                break;
            }
            case MI_UINT8:
            {
                fprintf(file,"%u", *((const MI_Uint8*)value));
                break;
            }
            case MI_SINT16:
            {
                fprintf(file,"%d", *((const MI_Sint16*)value));
                break;
            }
            case MI_UINT16:
            {
                fprintf(file,"%u", *((const MI_Uint16*)value));
                break;
            }
            case MI_SINT32:
            {
                fprintf(file,"%d", *((const MI_Sint32*)value));
                break;
            }
            case MI_UINT32:
            {
                fprintf(file,"%u", *((const MI_Uint32*)value));
                break;
            }
            case MI_SINT64:
            {
                fprintf(file, SINT64_FMT, *((const MI_Sint64*)value));
                break;
            }
            case MI_UINT64:
            {
                fprintf(file, UINT64_FMT, *((const MI_Uint64*)value));
                break;
            }
            case MI_REAL32:
            {
                fprintf(file,"%g", *((const MI_Real32*)value));
                break;
            }
            case MI_REAL64:
            {
                fprintf(file,"%g", *((const MI_Real64*)value));
                break;
            }
            case MI_CHAR16:
            {
                fprintf(file,"%u", *((const MI_Char16*)value));
                break;
            }
            case MI_DATETIME:
            {
                MI_Char buf[26];
                _DatetimeToStr((const MI_Datetime*)value, buf);
                Zfprintf(file, MI_T(" %s"), buf);
                break;
            }
            case MI_STRING:
            {
                Zfprintf(file, MI_T(" %s"), tcs(((const MI_Char*)value)));
                break;
            }
            case MI_BOOLEANA:
            case MI_SINT8A:
            case MI_UINT8A:
            case MI_SINT16A:
            case MI_UINT16A:
            case MI_SINT32A:
            case MI_UINT32A:
            case MI_SINT64A:
            case MI_UINT64A:
            case MI_REAL32A:
            case MI_REAL64A:
            case MI_CHAR16A:
            case MI_DATETIMEA:
            {
                MI_BooleanA* arr = (MI_BooleanA*)value;
                char* ptr = (char*)arr->data;
                MI_Uint32 i;

                fprintf(file,"{");

                for (i = 0; i < arr->size; i++)
                {
                    MI_Type stype = type & ~MI_ARRAY_BIT;
                    PrintValue(ptr, stype, file);
#ifdef _PREFAST_
    #pragma prefast (push)
    #pragma prefast (disable: 26014)
#endif          
                    ptr += _typeSizes[stype];
#ifdef _PREFAST_
        #pragma prefast (pop)
#endif          

                    if (i + 1 != arr->size)
                        fprintf(file,", ");
                }
                fprintf(file,"}");
                break;
            }
            case MI_STRINGA:
            {
                MI_StringA* arr = (MI_StringA*)value;
                MI_Uint32 i;

                fprintf(file,"{");

                for (i = 0; i < arr->size; i++)
                {
                    Zfprintf(file, MI_T("%s"), tcs(arr->data[i]));

                    if (i + 1 != arr->size)
                        fprintf(file,", ");
                }

                fprintf(file,"}");
                break;
            }
            default:
                break;
        }
    }
}