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

Method writeFields

Engine/source/console/simFieldDictionary.cpp:243–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241}
242
243void SimFieldDictionary::writeFields(SimObject *obj, Stream &stream, U32 tabStop)
244{
245 const AbstractClassRep::FieldList &list = obj->getFieldList();
246 Vector<Entry *> flist(__FILE__, __LINE__);
247
248 for (U32 curEntry = 0; curEntry < HashTableSize; curEntry++)
249 {
250 for (Entry *walk = mHashTable[curEntry]; walk; walk = walk->next)
251 {
252 // make sure we haven't written this out yet:
253 U32 curField;
254 for (curField = 0; curField < list.size(); curField++)
255 if (list[curField].pFieldname == walk->slotName)
256 break;
257
258 if (curField != list.size())
259 continue;
260
261
262 if (!obj->writeField(walk->slotName, walk->value))
263 continue;
264
265 flist.push_back(walk);
266 }
267 }
268
269 // Sort Entries to prevent version control conflicts
270 dQsort(flist.address(), flist.size(), sizeof(Entry *), compareEntries);
271
272 // Save them out
273 for (Vector<Entry *>::iterator itr = flist.begin(); itr != flist.end(); itr++)
274 {
275 U32 nBufferSize = (dStrlen((*itr)->value) * 2) + dStrlen((*itr)->slotName) + 16;
276 FrameTemp<char> expandedBuffer(nBufferSize);
277
278 stream.writeTabs(tabStop + 1);
279
280 const char *typeName = (*itr)->type && (*itr)->type->getTypeID() != TypeString ? (*itr)->type->getTypeName() : "";
281 dSprintf(expandedBuffer, nBufferSize, "%s%s%s = \"", typeName, *typeName ? " " : "", (*itr)->slotName);
282 if ((*itr)->value)
283 expandEscape((char*)expandedBuffer + dStrlen(expandedBuffer), (*itr)->value);
284 dStrcat(expandedBuffer, "\";\r\n", nBufferSize);
285
286 stream.write(dStrlen(expandedBuffer), expandedBuffer);
287 }
288
289}
290void SimFieldDictionary::printFields(SimObject *obj)
291{
292 const AbstractClassRep::FieldList &list = obj->getFieldList();

Callers

nothing calls this directly

Calls 15

dQsortFunction · 0.85
dSprintfFunction · 0.85
expandEscapeFunction · 0.85
dStrcatFunction · 0.85
writeTabsMethod · 0.80
getTypeIDMethod · 0.80
dStrlenFunction · 0.50
sizeMethod · 0.45
writeFieldMethod · 0.45
push_backMethod · 0.45
addressMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected