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

Method writeObject

Engine/source/console/simSerialize.cpp:36–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34//-----------------------------------------------------------------------------
35
36bool SimObject::writeObject(Stream *stream)
37{
38 stream->writeString(getName() ? getName() : "");
39
40 // Static fields
41 AbstractClassRep *rep = getClassRep();
42 AbstractClassRep::FieldList &fieldList = rep->mFieldList;
43 AbstractClassRep::FieldList::iterator itr;
44
45 U32 savePos = stream->getPosition();
46 U32 numFields = fieldList.size();
47 stream->write(numFields);
48
49 for(itr = fieldList.begin();itr != fieldList.end();itr++)
50 {
51 if( itr->type >= AbstractClassRep::ARCFirstCustomField )
52 {
53 numFields--;
54 continue;
55 }
56
57 const char *field = getDataField(itr->pFieldname, NULL);
58 if(field == NULL)
59 field = "";
60
61 stream->writeString(itr->pFieldname);
62 stream->writeString(field);
63 }
64
65 // Dynamic Fields
66 if(mCanSaveFieldDictionary)
67 {
68 SimFieldDictionary * fieldDictionary = getFieldDictionary();
69 for(SimFieldDictionaryIterator ditr(fieldDictionary); *ditr; ++ditr)
70 {
71 SimFieldDictionary::Entry * entry = (*ditr);
72
73 stream->writeString(entry->slotName);
74 stream->writeString(entry->value);
75 numFields++;
76 }
77 }
78
79 // Overwrite the number of fields with the correct value
80 U32 savePos2 = stream->getPosition();
81 stream->setPosition(savePos);
82 stream->write(numFields);
83 stream->setPosition(savePos2);
84
85 return true;
86}
87
88bool SimObject::readObject(Stream *stream)
89{

Callers 1

saveObjectFunction · 0.45

Calls 12

beginFunction · 0.85
endFunction · 0.85
saveObjectFunction · 0.85
getNameFunction · 0.50
sizeFunction · 0.50
writeStringMethod · 0.45
getPositionMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected