| 82 | //----------------------------------------------------------------------------- |
| 83 | |
| 84 | void 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. |
nothing calls this directly
no test coverage detected