MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / setObjectAttributes

Method setObjectAttributes

Engine/source/console/SimXMLDocument.cpp:789–905  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Set attribute of top stack element to given value. -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

787// Set attribute of top stack element to given value.
788// -----------------------------------------------------------------------------
789void SimXMLDocument::setObjectAttributes(const char* objectID)
790{
791 if( !objectID || !objectID[0] )
792 return;
793
794 if(m_paNode.empty())
795 return;
796
797 SimObject *pObject = Sim::findObject( objectID );
798
799 if( pObject == NULL )
800 return;
801
802 const S32 iLastElement = m_paNode.size() - 1;
803 TiXmlElement* pElement = m_paNode[iLastElement];
804 if(!pElement)
805 return;
806
807 char textbuf[1024];
808 TiXmlElement field( "Field" );
809 TiXmlElement group( "FieldGroup" );
810 pElement->SetAttribute( "Name", pObject->getName() );
811
812
813 // Iterate over our filed list and add them to the XML document...
814 AbstractClassRep::FieldList fieldList = pObject->getFieldList();
815 AbstractClassRep::FieldList::iterator itr;
816 for(itr = fieldList.begin(); itr != fieldList.end(); itr++)
817 {
818
819 if( itr->type == AbstractClassRep::DeprecatedFieldType ||
820 itr->type == AbstractClassRep::StartGroupFieldType ||
821 itr->type == AbstractClassRep::EndGroupFieldType) continue;
822
823 // Not an Array
824 if(itr->elementCount == 1)
825 {
826 // get the value of the field as a string.
827 ConsoleBaseType *cbt = ConsoleBaseType::getType(itr->type);
828
829 const char *val = Con::getData(itr->type, (void *) (((const char *)pObject) + itr->offset), 0, itr->table, itr->flag);
830
831 // Make a copy for the field check.
832 if (!val)
833 continue;
834
835 FrameTemp<char> valCopy( dStrlen( val ) + 1 );
836 dStrcpy( (char *)valCopy, val );
837
838 if (!pObject->writeField(itr->pFieldname, valCopy))
839 continue;
840
841 val = valCopy;
842
843
844 expandEscape(textbuf, val);
845
846 if( !pObject->writeField( itr->pFieldname, textbuf ) )

Callers 1

SimXMLDocument.cppFile · 0.80

Calls 15

getTypeFunction · 0.85
getDataFunction · 0.85
dStrcpyFunction · 0.85
expandEscapeFunction · 0.85
InsertEndChildMethod · 0.80
findObjectFunction · 0.70
dStrlenFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
SetAttributeMethod · 0.45
getNameMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected