Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Caha committed Oct 4, 2024
1 parent 62ce8c7 commit cebbd28
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions mdal/mdal_data_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,21 @@ void MDAL::DatasetGroup::setName( const std::string &name )

while ( existingNames.find( assignedName ) != existingNames.end() )
{
std::regex reEndsNumber( "_[0-9]+$" );
std::regex reNumber( "[0-9]+$" );
std::smatch m;
if ( std::regex_search( assignedName, reEndsNumber ) )
std::regex reEndsNumber( "_[0-9]+$" );
std::regex reNumber( "[0-9]+$" );
std::smatch m;
if ( std::regex_search( assignedName, reEndsNumber ) )
{
if ( std::regex_search( assignedName, m, reNumber ) )
{
if ( std::regex_search( assignedName, m, reNumber ))
{
int number = std::stoi( m.str() );
assignedName = assignedName.substr( 0, assignedName.size() - m.str().size() ) + std::to_string( number + 1 );
}
}
else{
assignedName = assignedName + "_1";
int number = std::stoi( m.str() );
assignedName = assignedName.substr( 0, assignedName.size() - m.str().size() ) + std::to_string( number + 1 );
}
}
else
{
assignedName = assignedName + "_1";
}
}

setMetadata( "name", assignedName );
Expand Down

0 comments on commit cebbd28

Please sign in to comment.