Example #1
0
 // Properly working breakpoints on windows with msvc10 and cdb inside static-function-inside-class-inside-function?
 // Qt-Creator: "No, not heard."
 static void* Helper(rapidjson::Document::ValueType* document, char *nextName)
 {
     bool isObject = document->IsObject();
     TypeInfo *typeInfo = TypeInfo::GetTypeInfo(nextName);
     void *next = typeInfo->New();
     for (rapidjson::Document::ValueType::MemberIterator i = document->MemberBegin(); i != document->MemberEnd(); ++i)
     {
         std::string propertyName = i->name.GetString();
         PropertyInfo *prop = typeInfo->FindProperty(propertyName);
         if (i->value.IsObject())
         {
             prop->SetValue(next, Helper(&(i->value), prop->TypeName()));
         }
         else if( i->value.IsArray())
         {
             for (int j = 0; j < i->value.Size(); j++)
             {
                 TypeInfo *tempTypeInfo = TypeInfo::GetTypeInfo(prop->TypeName());
                 void *temp = tempTypeInfo->New();
                 tempTypeInfo->SetString(temp, i->value[j].GetString());
                 prop->PushValue(next, temp);
                 delete temp;
             }
         }
         else
         {
             TypeInfo *tempTypeInfo = TypeInfo::GetTypeInfo(prop->TypeName());
             void *temp = tempTypeInfo->New();
             tempTypeInfo->SetString(temp, i->value.GetString());
             prop->SetValue(next, temp);
             delete temp;
         }
     }
     return next;
 }
Example #2
0
// allocate a object given the classname by string
RTRoot* NewType(const char *typeName)
{
TypeInfo *t = FindType(typeName);
if (!t) return(NULL);
if (t->New == 0) return(NULL);		// abstract type
return t->New();
}