sfizz/sources/Opcode.cpp

18 lines
642 B
C++
Raw Normal View History

2019-07-29 02:13:03 +02:00
#include "Opcode.h"
sfz::Opcode::Opcode(std::string_view inputOpcode, std::string_view inputValue)
2019-08-25 14:01:03 +02:00
: opcode(inputOpcode)
, value(inputValue)
2019-07-29 02:13:03 +02:00
{
2019-08-25 14:01:03 +02:00
if (const auto lastCharIndex = inputOpcode.find_last_not_of("1234567890"); lastCharIndex != inputOpcode.npos) {
2019-07-29 02:13:03 +02:00
int returnedValue;
std::string_view parameterView = inputOpcode;
parameterView.remove_prefix(lastCharIndex + 1);
2019-08-25 14:01:03 +02:00
if (absl::SimpleAtoi(parameterView, &returnedValue)) {
2019-07-29 02:13:03 +02:00
parameter = returnedValue;
opcode.remove_suffix(opcode.size() - lastCharIndex - 1);
}
}
trimInPlace(value);
trimInPlace(opcode);
}