#include <QStringList>
#include <QTextStream>
+#include <limits>
+
+static int aMaxNameId = std::numeric_limits<int>::max();
+
void HYDROData_Tool::WriteStringsToFile( QFile& theFile,
const QStringList& theStrings,
const QString& theSep )
aName = thePrefix;
} else {
int anId = 1;
- while( anId < 1000 )
+ while( anId < aMaxNameId )
{
aName = QString( "%1_%2" ).arg( thePrefix ).arg( QString::number( anId++ ) );
theObject->SetName( anObjName );
}
+QString HYDROData_Tool::GenerateNameForPython( const MapOfTreatedObjects& theTreatedObjects,
+ const QString& thePrefix )
+{
+ QString aName = thePrefix;
+ if ( !theTreatedObjects.contains( aName ) )
+ return aName;
+
+ int anId = 1;
+ while( anId < aMaxNameId )
+ {
+ aName = QString( "%1_%2" ).arg( thePrefix ).arg( QString::number( anId++ ) );
+
+ // check that there are no other objects with the same name
+ if ( !theTreatedObjects.contains( aName ) )
+ break;
+ }
+
+ return aName;
+}
\ No newline at end of file