Extract logic to NoteDataUtil::StringInterpretsAs

This commit is contained in:
Martin Kröning
2020-06-13 13:46:02 +02:00
parent dc25295879
commit 67bce17382
3 changed files with 23 additions and 39 deletions
+11
View File
@@ -11,6 +11,17 @@
#include "TimingData.h"
#include <utility>
bool NoteDataUtil::StringInterpretsAs( const std::string& str, int integer ) {
try
{
return std::stoi( str ) == integer;
}
catch ( const std::invalid_argument & )
{
return false;
}
}
// TODO: Remove these constants that aren't time signature-aware
static const int BEATS_PER_MEASURE = 4;
static const int ROWS_PER_MEASURE = ROWS_PER_BEAT * BEATS_PER_MEASURE;