MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / importFromStream

Function importFromStream

radiantcore/map/algorithm/Import.cpp:338–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336};
337
338void importFromStream(std::istream& stream)
339{
340 GlobalSelectionSystem().setSelectedAll(false);
341
342 // Instantiate the default import filter
343 SimpleMapImportFilter importFilter;
344
345 try
346 {
347 auto format = determineMapFormat(stream);
348
349 if (!format)
350 {
351 throw IMapReader::FailureException(_("Unknown map format"));
352 }
353
354 auto reader = format->getMapReader(importFilter);
355
356 // Start parsing
357 reader->readFromStream(stream);
358
359 // Prepare child primitives
360 scene::addOriginToChildPrimitives(importFilter.getRootNode());
361
362 // Adjust all new names to fit into the existing map namespace
363 prepareNamesForImport(GlobalMap().getRoot(), importFilter.getRootNode());
364
365 importMap(importFilter.getRootNode());
366 }
367 catch (IMapReader::FailureException& ex)
368 {
369 // Clear out the root node, otherwise we end up with half a map
370 scene::NodeRemover remover;
371 importFilter.getRootNode()->traverseChildren(remover);
372
373 throw cmd::ExecutionFailure(fmt::format(_("Failure reading map from clipboard:\n{0}"), ex.what()));
374 }
375}
376
377}
378

Callers 1

pasteToMapFunction · 0.85

Calls 15

determineMapFormatFunction · 0.85
prepareNamesForImportFunction · 0.85
importMapFunction · 0.85
ExecutionFailureClass · 0.85
whatMethod · 0.80
FailureExceptionClass · 0.50
_Function · 0.50
formatFunction · 0.50
setSelectedAllMethod · 0.45
getMapReaderMethod · 0.45
readFromStreamMethod · 0.45

Tested by

no test coverage detected