CfgDrivers::CfgDrivers(ConfigParser *parent) { XMLElement *xel; config = new ConfigParser(parent, Cfg_Drivers); xel = config->getElement(); drivers.FreeOnDelete(true); for (int i=0; (xel!=0) && (i<xel->GetChildrenCount()); i++) { XMLElement *el = xel->GetChild(i); ASSERT (el != 0); if (el != 0) { String *h = el->GetAttributeValue(Cfg_DriverHarmful); String *n = el->GetAttributeValue(Cfg_DriverName); if ((h != 0) && (n != 0)) { Driver *d = new Driver; d->driver = *n; d->harmful = (h->ToLong() != 0) ? true : false; drivers << d; } } } }
void ArchiveXML::DeserializeFields( void* structure, const Structure* type ) { if ( m_Iterator.GetCurrent()->GetFirstChild() ) { // advance to the first child m_Iterator.Advance(); for ( XMLElement* sibling = m_Iterator.GetCurrent(); sibling != NULL; sibling = sibling->GetNextSibling() ) { HELIUM_ASSERT( m_Iterator.GetCurrent() == sibling ); const String* fieldNameStr = sibling->GetAttributeValue( Name( TXT("Name") ) ); uint32_t fieldNameCrc = fieldNameStr ? Crc32( fieldNameStr->GetData() ) : 0x0; const Field* field = type->FindFieldByName(fieldNameCrc); if ( field ) { #ifdef REFLECT_ARCHIVE_VERBOSE m_Indent.Get(stdout); Log::Debug(TXT("Deserializing field %s\n"), field->m_Name); m_Indent.Push(); #endif // pull and structure and downcast to data DataPtr latentData = SafeCast<Data>( Allocate() ); if (!latentData.ReferencesObject()) { // this should never happen, the type id read from the file is bogus throw Reflect::TypeInformationException( TXT( "Unknown data for field %s (%s)" ), field->m_Name, m_Path.c_str() ); #pragma TODO("Support blind data") } // if the types match we are a natural fit to just deserialize directly into the field data if ( field->m_DataClass == field->m_DataClass ) { // set data pointer latentData->ConnectField( structure, field ); // process natively DeserializeInstance( (ObjectPtr&)latentData ); // disconnect latentData->Disconnect(); } else // else the type does not match, deserialize it into temp data then attempt to cast it into the field data { REFLECT_SCOPE_TIMER(("Casting")); // construct current serialization structure ObjectPtr currentObject = Registry::GetInstance()->CreateInstance( field->m_DataClass ); // downcast to data DataPtr currentData = SafeCast<Data>(currentObject); if (!currentData.ReferencesObject()) { // this should never happen, the type id in the rtti data is bogus throw Reflect::TypeInformationException( TXT( "Invalid type id for field %s (%s)" ), field->m_Name, m_Path.c_str() ); } // process into temporary memory currentData->ConnectField(structure, field); // process natively DeserializeInstance( (ObjectPtr&)latentData ); // attempt cast data into new definition Data::CastValue( latentData, currentData, DataFlags::Shallow ); // disconnect currentData->Disconnect(); } } #ifdef REFLECT_ARCHIVE_VERBOSE m_Indent.Pop(); #endif } } else { // advance to the next element m_Iterator.Advance(); } }