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

Method write

Engine/source/console/simPersistSet.cpp:84–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82//-----------------------------------------------------------------------------
83
84void SimPersistSet::write( Stream& stream, U32 tabStop, U32 flags )
85{
86 if( ( flags & SelectedOnly ) && !isSelected() )
87 return;
88
89 // If the selection is transient, we cannot really save it.
90 // Just invoke the default SimObject::write and return.
91
92 if( !getCanSave() )
93 {
94 Con::errorf( "SimPersistSet::write - transient set being saved: %d:%s (%s)",
95 getId(), getClassName(), getName() );
96 Parent::write( stream, tabStop, flags );
97 return;
98 }
99
100 // If there are unresolved PIDs, give resolving them one last
101 // chance before writing out the set.
102
103 if( !mUnresolvedPIDs.empty() )
104 resolvePIDs();
105
106 // Write the set out.
107
108 stream.writeTabs( tabStop );
109
110 StringBuilder buffer;
111 buffer.format( "new %s(%s", getClassName(), getName() ? getName() : "" );
112
113 // Write the persistent IDs of all child objects into the set's
114 // object constructor so we see them passed back to us through
115 // processArguments when the object gets read in.
116
117 const U32 numChildren = size();
118 for( U32 i = 0; i < numChildren; ++ i )
119 {
120 SimObject* child = at( i );
121
122 SimPersistID* pid = child->getPersistentId();
123 AssertWarn( pid != NULL, "SimPersistSet::write - object without pid in persistent selection!" );
124 if( !pid )
125 continue;
126
127 buffer.append( ',' );
128 buffer.append( '"' );
129 buffer.append( pid->getUUID().toString() );
130 buffer.append( '"' );
131 }
132
133 buffer.append( ") {\r\n" );
134
135 stream.write( buffer.length(), buffer.data() );
136
137 // Write our object fields.
138
139 writeFields( stream, tabStop + 1 );
140
141 // Close our object definition.

Callers

nothing calls this directly

Calls 13

isSelectedFunction · 0.85
writeTabsMethod · 0.80
getPersistentIdMethod · 0.80
errorfFunction · 0.70
getNameFunction · 0.50
writeFunction · 0.50
sizeFunction · 0.50
emptyMethod · 0.45
formatMethod · 0.45
appendMethod · 0.45
toStringMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected