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


C++ TypeInfo::BaseInfo方法代码示例

本文整理汇总了C++中TypeInfo::BaseInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeInfo::BaseInfo方法的具体用法?C++ TypeInfo::BaseInfo怎么用?C++ TypeInfo::BaseInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeInfo的用法示例。


在下文中一共展示了TypeInfo::BaseInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Helper

        static void Helper(CStateInfo& state, void* next, const string &nextName)
        {
            state.s += RepeatString("\t", state.depth);
            state.s += "{\n";
            state.depth++;

            TypeInfo *typeInfo = TypeInfo::GetTypeInfo(nextName);
            while (typeInfo)
            {
                map<string, PropertyInfo*> &props = typeInfo->Properties();
                for (map<string, PropertyInfo*>::iterator i = props.begin(); i != props.end(); ++i)
                {
                    map<string, PropertyInfo*>::iterator nextIter = ++i;
                    i--;

                    if (i->second->Integral())
                    {
                        if ( i->second->IsPointer() )
                        {
                            printf( "we are here ");
                        }
                        void *value = i->second->GetValue(next);
                        std::string stringTypeName = i->second->TypeName();
                        TypeInfo* _typeInfo = TypeInfo::GetTypeInfo(stringTypeName);
                        std::string stringValue = _typeInfo->GetString(value);

                        state.s += RepeatString("\t", state.depth) +
                                   "\"" +
                                   i->second->Name() +
                                   "\" : \"" +
                                   stringValue.c_str() +
                                   "\"" +
                                   RepeatString(",", typeInfo->BaseInfo() != 0 || nextIter != props.end()) +
                                   "\n";
                    }
                    else if (i->second->IsArray())
                    {
                        state.s += RepeatString("\t", state.depth) +
                                   "\"" +
                                   i->second->Name() +
                                   "\" : \n" +
                                   RepeatString("\t", state.depth) +
                                   "[\n";
                        state.depth++;
                        for (int j = 0; j < i->second->GetArraySize(next); j++)
                        {
                            void *value = i->second->GetValue(next, j);
                            char floatStr[256];
                            sprintf(floatStr, "%f", *(static_cast<float*>(value)));

                            state.s += RepeatString("\t", state.depth) +
                                       "\"" +
                                       floatStr +
                                       "\"" +
                                       RepeatString(",", j != i->second->GetArraySize(next) - 1 ) +
                                       "\n";
                            delete value;
                        }
                        state.depth--;
                        state.s += RepeatString("\t", state.depth) +
                                   "]" +
                                   RepeatString(",", nextIter != props.end() || typeInfo->BaseInfo()) +
                                   "\n";
                    }
                    else
                    {
                        state.s += RepeatString("\t", state.depth) +
                                   "\"" +
                                   i->second->Name() +
                                   "\" : \n";
                        bool alreadySerialized = false;
                        bool nullPtr = false;
                        if ( i->second->IsPointer() )
                        {
                            if (i->second->GetValue(next) == 0)
                                nullPtr = true;
                            if (nullPtr)
                            {
                                state.s += "0";
                            }
                            else
                            {
                                alreadySerialized = state.addresTable.count( i->second->GetValue(next) ) == 1;
                                if (alreadySerialized)
                                {
                                    state.s += "\"@ptr" +
                                               To<int>::String( state.addresTable[ i->second->GetValue(next) ] ) +
                                               "\",\n";
                                }
                                else
                                {
                                    state.ptrCount++;
                                    state.addresTable[ i->second->GetValue(next) ] = state.ptrCount;
                                    state.s += RepeatString("\t", state.depth) +
                                               "{\n" +
                                               RepeatString("\t", state.depth + 1) +
                                               "\"@ptr\" : " +
                                               To<int>::String(state.ptrCount) +
                                               ",\n" +
                                               RepeatString("\t", state.depth + 1) +
//.........这里部分代码省略.........
开发者ID:rotanov,项目名称:way-station,代码行数:101,代码来源:main.cpp


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