]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelHighAPI/ModelHighAPI_Dumper.cpp
Salome HOME
Avoid SegFault exception
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Dumper.cpp
1 // Copyright (C) 2016-20xx CEA/DEN, EDF R&D -->
2
3 // File:        ModelHighAPI_Dumper.cpp
4 // Created:     1 August 2016
5 // Author:      Artem ZHIDKOV
6
7 //--------------------------------------------------------------------------------------
8 #include "ModelHighAPI_Dumper.h"
9
10 #include <GeomAPI_Pnt.h>
11 #include <GeomAPI_Dir.h>
12
13 #include <GeomDataAPI_Dir.h>
14 #include <GeomDataAPI_Point.h>
15 #include <GeomDataAPI_Point2D.h>
16
17 #include <ModelAPI_AttributeBoolean.h>
18 #include <ModelAPI_AttributeDouble.h>
19 #include <ModelAPI_AttributeInteger.h>
20 #include <ModelAPI_AttributeRefAttr.h>
21 #include <ModelAPI_AttributeRefAttrList.h>
22 #include <ModelAPI_AttributeReference.h>
23 #include <ModelAPI_AttributeRefList.h>
24 #include <ModelAPI_AttributeSelection.h>
25 #include <ModelAPI_AttributeSelectionList.h>
26 #include <ModelAPI_AttributeString.h>
27 #include <ModelAPI_CompositeFeature.h>
28 #include <ModelAPI_Document.h>
29 #include <ModelAPI_Entity.h>
30 #include <ModelAPI_Feature.h>
31 #include <ModelAPI_Result.h>
32 #include <ModelAPI_ResultPart.h>
33
34 #include <PartSetPlugin_Part.h>
35
36 #include <OSD_OpenFile.hxx>
37
38 #include <fstream>
39
40 #define DUMP_USER_DEFINED_NAMES
41
42 static int gCompositeStackDepth = 0;
43
44 ModelHighAPI_Dumper* ModelHighAPI_Dumper::mySelf = 0;
45
46 ModelHighAPI_Dumper::ModelHighAPI_Dumper()
47 {
48   clear();
49 }
50
51 void ModelHighAPI_Dumper::setInstance(ModelHighAPI_Dumper* theDumper)
52 {
53   if (mySelf == 0)
54     mySelf = theDumper;
55 }
56
57 ModelHighAPI_Dumper* ModelHighAPI_Dumper::getInstance()
58 {
59   return mySelf;
60 }
61
62 void ModelHighAPI_Dumper::clear(bool bufferOnly)
63 {
64   myDumpBuffer.str("");
65   myDumpBuffer << std::setprecision(16);
66
67   clearNotDumped();
68
69   if (!bufferOnly) {
70     myFullDump.str("");
71     myFullDump << std::setprecision(16);
72
73     myNames.clear();
74     myModules.clear();
75     myFeatureCount.clear();
76     myLastEntityWithName = EntityPtr();
77   }
78 }
79
80 void ModelHighAPI_Dumper::clearNotDumped()
81 {
82   myNotDumpedEntities.clear();
83 }
84
85 const std::string& ModelHighAPI_Dumper::name(const EntityPtr& theEntity, bool theSaveNotDumped)
86 {
87   EntityNameMap::const_iterator aFound = myNames.find(theEntity);
88   if (aFound != myNames.end())
89     return aFound->second.first;
90
91   // entity is not found, store it
92   std::string aName;
93   bool isUserDefined = false;
94   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theEntity);
95   if (aFeature) {
96     isUserDefined = true;
97     aName = aFeature->name();
98     const std::string& aKind = aFeature->getKind();
99     DocumentPtr aDoc = aFeature->document();
100     int& aNbFeatures = myFeatureCount[aDoc][aKind];
101
102     size_t anIndex = aName.find(aKind);
103     if (anIndex == 0 && aName[aKind.length()] == '_') { // name starts with "FeatureKind_"
104       std::string anIdStr = aName.substr(aKind.length() + 1, std::string::npos);
105       int anId = std::stoi(anIdStr);
106
107       // Check number of already registered objects of such kind. Index of current object
108       // should be the same to identify feature's name as automatically generated.
109       if (aNbFeatures + 1 == anId) {
110         isUserDefined = false;
111         //aNbFeatures = anId - 1;
112       }
113     }
114
115     aNbFeatures += 1;
116   }
117
118   myNames[theEntity] = std::pair<std::string, bool>(aName, isUserDefined);
119   if (theSaveNotDumped)
120     myNotDumpedEntities.insert(theEntity);
121   return myNames[theEntity].first;
122 }
123
124 const std::string& ModelHighAPI_Dumper::parentName(const FeaturePtr& theEntity)
125 {
126   const std::set<AttributePtr>& aRefs = theEntity->data()->refsToMe();
127   std::set<AttributePtr>::const_iterator aRefIt = aRefs.begin();
128   for (; aRefIt != aRefs.end(); ++aRefIt) {
129     CompositeFeaturePtr anOwner = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(
130         ModelAPI_Feature::feature((*aRefIt)->owner()));
131     if (anOwner)
132       return name(anOwner);
133   }
134
135   static const std::string DUMMY;
136   return DUMMY;
137 }
138
139 bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_Document>& theDoc,
140                                   const std::string& theFileName)
141 {
142   // dump top level document feature
143   static const std::string aDocName("partSet");
144   myNames[theDoc] = std::pair<std::string, bool>(aDocName, false);
145   *this << aDocName << " = model.moduleDocument()" << std::endl;
146
147   // dump subfeatures and store result to file
148   return process(theDoc) && exportTo(theFileName);
149 }
150
151 bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_Document>& theDoc)
152 {
153   bool isOk = true;
154   std::list<FeaturePtr> aFeatures = theDoc->allFeatures();
155   std::list<FeaturePtr>::const_iterator aFeatIt = aFeatures.begin();
156   // firstly, dump all parameters
157   for (; aFeatIt != aFeatures.end(); ++ aFeatIt)
158     dumpParameter(*aFeatIt);
159   // dump all other features
160   for (aFeatIt = aFeatures.begin(); aFeatIt != aFeatures.end(); ++aFeatIt) {
161     CompositeFeaturePtr aCompFeat = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(*aFeatIt);
162     if (aCompFeat) // iteratively process composite features
163       isOk = process(aCompFeat) && isOk;
164     else if (!isDumped(*aFeatIt)) // dump common feature 
165       dumpFeature(*aFeatIt);
166   }
167   return isOk;
168 }
169
170 bool ModelHighAPI_Dumper::process(const std::shared_ptr<ModelAPI_CompositeFeature>& theComposite, bool isForce)
171 {
172   // increase composite features stack
173   ++gCompositeStackDepth;
174   // dump composite itself
175   if (!isDumped(theComposite) || isForce)
176     dumpFeature(theComposite, isForce);
177
178   // sub-part is processed independently, because it provides separate document
179   if (theComposite->getKind() == PartSetPlugin_Part::ID()) {
180     // decrease composite features stack because we run into separate document
181     --gCompositeStackDepth;
182
183     ResultPartPtr aPartResult =
184         std::dynamic_pointer_cast<ModelAPI_ResultPart>(theComposite->lastResult());
185     if (!aPartResult)
186       return false;
187     DocumentPtr aSubDoc = aPartResult->partDoc();
188     // set name of document
189     const std::string& aPartName = myNames[theComposite].first;
190     std::string aDocName = aPartName + "_doc";
191     myNames[aSubDoc] = std::pair<std::string, bool>(aDocName, false);
192
193     // dump document in a separate line
194     *this << aDocName << " = " << aPartName << ".document()" << std::endl;
195     // dump features in the document
196     return process(aSubDoc);
197   }
198
199   // dump sub-features
200   bool isOk = processSubs(theComposite);
201   // decrease composite features stack
202   --gCompositeStackDepth;
203
204   return isOk;
205 }
206
207 bool ModelHighAPI_Dumper::processSubs(const std::shared_ptr<ModelAPI_CompositeFeature>& theComposite,
208                                       bool theDumpModelDo)
209 {
210   bool isOk = true;
211   // dump all sub-features;
212   int aNbSubs = theComposite->numberOfSubs();
213   for (int anIndex = 0; anIndex < aNbSubs; ++anIndex) {
214     FeaturePtr aFeature = theComposite->subFeature(anIndex);
215     if (isDumped(aFeature))
216       continue;
217
218     CompositeFeaturePtr aCompFeat = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
219     if (aCompFeat) // iteratively process composite features
220       isOk = process(aCompFeat) && isOk;
221     else
222       dumpFeature(aFeature, true);
223   }
224
225   // It is necessary for the sketch to create its result when complete (command "model.do()").
226   // This option is set by flat theDumpModelDo.
227   // However, nested sketches are rebuilt by parent feature, so, they do not need
228   // explicit call of "model.do()". This will be controlled by the depth of the stack.
229   if (theDumpModelDo && gCompositeStackDepth <= 1)
230     *this << "model.do()" << std::endl;
231   return isOk;
232 }
233
234 bool ModelHighAPI_Dumper::exportTo(const std::string& theFileName)
235 {
236   std::ofstream aFile;
237   OSD_OpenStream(aFile, theFileName.c_str(), std::ofstream::out);
238   if (!aFile.is_open())
239     return false;
240
241   // standard header
242   for (ModulesMap::const_iterator aModIt = myModules.begin();
243        aModIt != myModules.end(); ++aModIt) {
244     aFile << "from " << aModIt->first << " import ";
245     if (aModIt->second.empty() || 
246         aModIt->second.find(std::string()) != aModIt->second.end())
247       aFile << "*"; // import whole module
248     else {
249       // import specific features
250       std::set<std::string>::const_iterator anObjIt = aModIt->second.begin();
251       aFile << *anObjIt;
252       for (++anObjIt; anObjIt != aModIt->second.end(); ++anObjIt)
253         aFile << ", " << *anObjIt;
254     }
255     aFile << std::endl;
256   }
257   if (!myModules.empty())
258     aFile << std::endl;
259
260   aFile << "import model" << std::endl << std::endl;
261   aFile << "model.begin()" << std::endl;
262
263   // dump collected data
264   aFile << myFullDump.str();
265
266   // standard footer
267   aFile << "model.end()" << std::endl;
268
269   aFile.close();
270   clear();
271
272   return true;
273 }
274
275 void ModelHighAPI_Dumper::importModule(const std::string& theModuleName,
276                                        const std::string& theObject)
277 {
278   myModules[theModuleName].insert(theObject);
279 }
280
281 void ModelHighAPI_Dumper::dumpEntitySetName()
282 {
283   if (!myLastEntityWithName)
284     return;
285
286 #ifdef DUMP_USER_DEFINED_NAMES
287   const std::string& aName = name(myLastEntityWithName);
288   myDumpBuffer << aName;
289   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(myLastEntityWithName);
290   if (aFeature)
291     myDumpBuffer << ".feature()";
292   myDumpBuffer << ".data().setName(\"" << aName << "\")" << std::endl;
293 #endif
294   myNames[myLastEntityWithName].second = false; // don't dump "setName" for the entity twice
295   myLastEntityWithName = EntityPtr();
296 }
297
298 bool ModelHighAPI_Dumper::isDumped(const EntityPtr& theEntity) const
299 {
300   EntityNameMap::const_iterator aFound = myNames.find(theEntity);
301   return aFound != myNames.end();
302 }
303
304 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const char theChar)
305 {
306   myDumpBuffer << theChar;
307   return *this;
308 }
309
310 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const char* theString)
311 {
312   myDumpBuffer << theString;
313   return *this;
314 }
315
316 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const std::string& theString)
317 {
318   myDumpBuffer << theString;
319   return *this;
320 }
321
322 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const bool theValue)
323 {
324   myDumpBuffer << (theValue ? "True" : "False");
325   return *this;
326 }
327
328 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const int theValue)
329 {
330   myDumpBuffer << theValue;
331   return *this;
332 }
333
334 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const double theValue)
335 {
336   myDumpBuffer << theValue;
337   return *this;
338 }
339
340 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const std::shared_ptr<GeomAPI_Pnt>& thePoint)
341 {
342   importModule("GeomAPI", "GeomAPI_Pnt");
343   myDumpBuffer << "GeomAPI_Pnt(" << thePoint->x() << ", "
344                << thePoint->y() << ", " << thePoint->z() << ")";
345   return *this;
346 }
347
348 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const std::shared_ptr<GeomAPI_Dir>& theDir)
349 {
350   importModule("GeomAPI", "GeomAPI_Dir");
351   myDumpBuffer << "GeomAPI_Dir(" << theDir->x() << ", "
352                << theDir->y() << ", " << theDir->z() << ")";
353   return *this;
354 }
355
356 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
357     const std::shared_ptr<GeomDataAPI_Dir>& theDir)
358 {
359   myDumpBuffer << theDir->x() << ", " << theDir->y() << ", " << theDir->z();
360   return *this;
361 }
362
363 static void dumpArray(std::ostringstream& theOutput, int theSize,
364                       double* theValues, std::string* theTexts)
365 {
366   for (int i = 0; i < theSize; ++i) {
367     if (i > 0)
368       theOutput << ", ";
369     if (theTexts[i].empty())
370       theOutput << theValues[i];
371     else
372       theOutput << "\"" << theTexts[i] << "\"";
373   }
374 }
375
376 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
377     const std::shared_ptr<GeomDataAPI_Point>& thePoint)
378 {
379   static const int aSize = 3;
380   double aValues[aSize] = {thePoint->x(), thePoint->y(), thePoint->z()};
381   std::string aTexts[aSize] = {thePoint->textX(), thePoint->textY(), thePoint->textZ()};
382   dumpArray(myDumpBuffer, aSize, aValues, aTexts);
383   return *this;
384 }
385
386 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
387     const std::shared_ptr<GeomDataAPI_Point2D>& thePoint)
388 {
389   static const int aSize = 2;
390   double aValues[aSize] = {thePoint->x(), thePoint->y()};
391   std::string aTexts[aSize] = {thePoint->textX(), thePoint->textY()};
392   dumpArray(myDumpBuffer, aSize, aValues, aTexts);
393   return *this;
394 }
395
396 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
397     const std::shared_ptr<ModelAPI_AttributeBoolean>& theAttrBool)
398 {
399   myDumpBuffer << (theAttrBool->value() ? "True" : "False");
400   return *this;
401 }
402
403 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
404     const std::shared_ptr<ModelAPI_AttributeInteger>& theAttrInt)
405 {
406   std::string aText = theAttrInt->text();
407   if (aText.empty())
408     myDumpBuffer << theAttrInt->value();
409   else
410     myDumpBuffer << "\"" << aText << "\"";
411   return *this;
412 }
413
414 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
415     const std::shared_ptr<ModelAPI_AttributeDouble>& theAttrReal)
416 {
417   std::string aText = theAttrReal->text();
418   if (aText.empty())
419     myDumpBuffer << theAttrReal->value();
420   else
421     myDumpBuffer << "\"" << aText << "\"";
422   return *this;
423 }
424
425 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
426     const std::shared_ptr<ModelAPI_AttributeString>& theAttrStr)
427 {
428   myDumpBuffer << "\"" << theAttrStr->value() << "\"";
429   return *this;
430 }
431
432 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const FeaturePtr& theEntity)
433 {
434   myDumpBuffer << name(theEntity);
435   if (myNames[theEntity].second)
436     myLastEntityWithName = theEntity;
437   myNotDumpedEntities.erase(theEntity);
438   return *this;
439 }
440
441 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const ResultPtr& theResult)
442 {
443   FeaturePtr aFeature = ModelAPI_Feature::feature(theResult);
444   int anIndex = 0;
445   std::list<ResultPtr> aResults = aFeature->results();
446   for(std::list<ResultPtr>::const_iterator anIt = aResults.cbegin(); anIt != aResults.cend(); ++anIt, ++anIndex) {
447     if(theResult->isSame(*anIt)) {
448       break;
449     }
450   }
451   myDumpBuffer << name(aFeature) << ".result()[" << anIndex << "]";
452   return *this;
453 }
454
455 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const ObjectPtr& theObject)
456 {
457   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
458   if(aFeature.get()) {
459     myDumpBuffer << name(aFeature);
460     return *this;
461   }
462
463   ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
464   if(aResult.get()) {
465     *this << aResult;
466     return *this;
467   }
468
469   return *this;
470 }
471
472 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const AttributePtr& theAttr)
473 {
474   FeaturePtr anOwner = ModelAPI_Feature::feature(theAttr->owner());
475   myDumpBuffer << name(anOwner) << "." << attributeGetter(anOwner, theAttr->id()) << "()";
476   return *this;
477 }
478
479 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
480     const std::shared_ptr<ModelAPI_AttributeRefAttr>& theRefAttr)
481 {
482   if (theRefAttr->isObject())
483     *this << theRefAttr->object();
484   else
485     *this << theRefAttr->attr();
486   return *this;
487 }
488
489 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
490     const std::shared_ptr<ModelAPI_AttributeRefAttrList>& theRefAttrList)
491 {
492   myDumpBuffer << "[";
493   std::list<std::pair<ObjectPtr, AttributePtr> > aList = theRefAttrList->list();
494   bool isAdded = false;
495   std::list<std::pair<ObjectPtr, AttributePtr> >::const_iterator anIt = aList.begin();
496   for (; anIt != aList.end(); ++anIt) {
497     if (isAdded)
498       myDumpBuffer << ", ";
499     else
500       isAdded = true;
501     if (anIt->first)
502       *this << anIt->first;
503     else if (anIt->second)
504       * this << anIt->second;
505   }
506   myDumpBuffer << "]";
507   return *this;
508 }
509
510 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
511     const std::shared_ptr<ModelAPI_AttributeReference>& theReference)
512 {
513   *this << theReference->value();
514   return *this;
515 }
516
517 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
518     const std::shared_ptr<ModelAPI_AttributeRefList>& theRefList)
519 {
520   static const int aThreshold = 2;
521   // if number of elements in the list if greater than a threshold,
522   // dump it in a separate line with specific name
523   std::string aDumped = myDumpBuffer.str();
524   if (aDumped.empty() || theRefList->size() <= aThreshold) {
525     myDumpBuffer << "[";
526     std::list<ObjectPtr> aList = theRefList->list();
527     bool isAdded = false;
528     std::list<ObjectPtr>::const_iterator anIt = aList.begin();
529     for (; anIt != aList.end(); ++anIt) {
530       if (isAdded)
531         myDumpBuffer << ", ";
532       else
533         isAdded = true;
534
535       *this << *anIt;
536     }
537     myDumpBuffer << "]";
538   } else {
539     // clear buffer and store list "as is"
540     myDumpBuffer.str("");
541     *this << theRefList;
542     // save buffer and clear it again
543     std::string aDumpedList = myDumpBuffer.str();
544     myDumpBuffer.str("");
545     // obtain name of list
546     FeaturePtr anOwner = ModelAPI_Feature::feature(theRefList->owner());
547     std::string aListName = name(anOwner) + "_objects";
548     // store all previous data
549     myDumpBuffer << aListName << " = " << aDumpedList << std::endl
550                  << aDumped << aListName;
551   }
552   return *this;
553 }
554
555 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
556     const std::shared_ptr<ModelAPI_AttributeSelection>& theAttrSelect)
557 {
558   myDumpBuffer << "model.selection(";
559
560   if(!theAttrSelect->isInitialized()) {
561     myDumpBuffer << ")";
562     return *this;
563   }
564
565   GeomShapePtr aShape = theAttrSelect->value();
566   if(!aShape.get()) {
567     aShape = theAttrSelect->context()->shape();
568   }
569
570   if(!aShape.get()) {
571     myDumpBuffer << ")";
572     return *this;
573   }
574
575   myDumpBuffer << "\"" << aShape->shapeTypeStr() << "\", \"" << theAttrSelect->namingName() << "\")";
576   return *this;
577 }
578
579 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
580     const std::shared_ptr<ModelAPI_AttributeSelectionList>& theAttrSelList)
581 {
582   myDumpBuffer << "[";
583
584   GeomShapePtr aShape;
585   std::string aShapeTypeStr;
586
587   bool isAdded = false;
588
589   for(int anIndex = 0; anIndex < theAttrSelList->size(); ++anIndex) {
590     AttributeSelectionPtr anAttribute = theAttrSelList->value(anIndex);
591     aShape = anAttribute->value();
592     if(!aShape.get()) {
593       aShape = anAttribute->context()->shape();
594     }
595
596     if(!aShape.get()) {
597       continue;
598     }
599
600     if(isAdded) {
601       myDumpBuffer << ", ";
602     } else {
603       isAdded = true;
604     }
605     myDumpBuffer << "model.selection(\"" << aShape->shapeTypeStr() << "\", \"" << anAttribute->namingName() << "\")";
606   }
607
608   myDumpBuffer << "]";
609   return *this;
610 }
611
612 /// Dump std::endl
613 MODELHIGHAPI_EXPORT
614 ModelHighAPI_Dumper& operator<<(ModelHighAPI_Dumper& theDumper,
615                                 std::basic_ostream<char>& (*theEndl)(std::basic_ostream<char>&))
616 {
617   theDumper.myDumpBuffer << theEndl;
618   theDumper.dumpEntitySetName();
619
620   // store all not-dumped entities first
621   std::set<EntityPtr> aNotDumped = theDumper.myNotDumpedEntities;
622   std::string aBufCopy = theDumper.myDumpBuffer.str();
623   theDumper.clear(true);
624   std::set<EntityPtr>::const_iterator anIt = aNotDumped.begin();
625   for (; anIt != aNotDumped.end(); ++anIt) {
626     // if the feature is composite, dump it with all subs
627     CompositeFeaturePtr aCompFeat =
628         std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(*anIt);
629     if (aCompFeat)
630       theDumper.process(aCompFeat, true);
631     else {
632       FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*anIt);
633       theDumper.dumpFeature(aFeature, true);
634     }
635   }
636
637   // avoid multiple empty lines
638   size_t anInd = std::string::npos;
639   while ((anInd = aBufCopy.find("\n\n\n")) != std::string::npos)
640     aBufCopy.erase(anInd, 1);
641   // then store currently dumped string
642   theDumper.myFullDump << aBufCopy;
643
644   return theDumper;
645 }