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

Method setObjectAttributes

Engine/source/console/SimXMLDocument.cpp:811–926  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

809// Set attribute of top stack element to given value.
810// -----------------------------------------------------------------------------
811void SimXMLDocument::setObjectAttributes(const char* objectID)
812{
813 if( !objectID || !objectID[0] )
814 return;
815
816 if(m_paNode.empty())
817 return;
818
819 SimObject *pObject = Sim::findObject( objectID );
820
821 if( pObject == NULL )
822 return;
823
824 const S32 iLastElement = m_paNode.size() - 1;
825 tinyxml2::XMLElement* pElement = m_paNode[iLastElement]->ToElement();
826 if(!pElement)
827 return;
828
829 char textbuf[1024];
830 tinyxml2::XMLElement* field = m_qDocument->NewElement("Field");
831 pElement->SetAttribute( "Name", pObject->getName() );
832
833
834 // Iterate over our filed list and add them to the XML document...
835 AbstractClassRep::FieldList fieldList = pObject->getFieldList();
836 AbstractClassRep::FieldList::iterator itr;
837 for(itr = fieldList.begin(); itr != fieldList.end(); itr++)
838 {
839
840 if( itr->type == AbstractClassRep::DeprecatedFieldType ||
841 itr->type == AbstractClassRep::StartGroupFieldType ||
842 itr->type == AbstractClassRep::EndGroupFieldType) continue;
843
844 // Not an Array
845 if(itr->elementCount == 1)
846 {
847 // get the value of the field as a string.
848 ConsoleBaseType *cbt = ConsoleBaseType::getType(itr->type);
849
850 const char *val = Con::getData(itr->type, (void *) (((const char *)pObject) + itr->offset), 0, itr->table, itr->flag);
851
852 // Make a copy for the field check.
853 if (!val)
854 continue;
855
856 FrameTemp<char> valCopy( dStrlen( val ) + 1 );
857 dStrcpy( (char *)valCopy, val, valCopy.size() );
858
859 if (!pObject->writeField(itr->pFieldname, valCopy))
860 continue;
861
862 val = valCopy;
863
864
865 expandEscape(textbuf, val);
866
867 if( !pObject->writeField( itr->pFieldname, textbuf ) )
868 continue;

Callers 1

SimXMLDocument.cppFile · 0.80

Calls 15

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

Tested by

no test coverage detected