| 369 | } |
| 370 | |
| 371 | void ExtensionContainer::saveExtensions(Base::Writer& writer) const |
| 372 | { |
| 373 | |
| 374 | // we don't save anything if there are no dynamic extensions |
| 375 | if (!hasExtensions()) { |
| 376 | return; |
| 377 | } |
| 378 | |
| 379 | // save dynamic extensions |
| 380 | writer.incInd(); // indentation for 'Extensions' |
| 381 | writer.Stream() << writer.ind() << "<Extensions Count=\"" << _extensions.size() << "\">" |
| 382 | << std::endl; |
| 383 | for (const auto& entry : _extensions) { |
| 384 | |
| 385 | auto ext = entry.second; |
| 386 | writer.incInd(); // indentation for 'Extension name' |
| 387 | writer.Stream() << writer.ind() << "<Extension" |
| 388 | << " type=\"" << ext->getExtensionTypeId().getName() << "\"" |
| 389 | << " name=\"" << ext->name() << "\">" << std::endl; |
| 390 | writer.incInd(); // indentation for the actual Extension |
| 391 | try { |
| 392 | // We must make sure to handle all exceptions accordingly so that |
| 393 | // the project file doesn't get invalidated. In the error case this |
| 394 | // means to proceed instead of aborting the write operation. |
| 395 | ext->extensionSave(writer); |
| 396 | } |
| 397 | catch (const Base::Exception& e) { |
| 398 | Base::Console().error("%s\n", e.what()); |
| 399 | } |
| 400 | catch (const std::exception& e) { |
| 401 | Base::Console().error("%s\n", e.what()); |
| 402 | } |
| 403 | catch (const char* e) { |
| 404 | Base::Console().error("%s\n", e); |
| 405 | } |
| 406 | #ifndef FC_DEBUG |
| 407 | catch (...) { |
| 408 | Base::Console().error( |
| 409 | "ExtensionContainer::Save: Unknown C++ exception thrown. Try to continue...\n"); |
| 410 | } |
| 411 | #endif |
| 412 | writer.decInd(); // indentation for the actual extension |
| 413 | writer.Stream() << writer.ind() << "</Extension>" << std::endl; |
| 414 | writer.decInd(); // indentation for 'Extension name' |
| 415 | } |
| 416 | writer.Stream() << writer.ind() << "</Extensions>" << std::endl; |
| 417 | writer.decInd(); |
| 418 | } |
| 419 | |
| 420 | void ExtensionContainer::restoreExtensions(Base::XMLReader& reader) |
| 421 | { |