diff --git a/src/ItemData.cc b/src/ItemData.cc index d179b75f..a8d6b367 100644 --- a/src/ItemData.cc +++ b/src/ItemData.cc @@ -16,16 +16,22 @@ ItemData::ItemData(const ItemData& other) { this->data2d = other.data2d; } -ItemData::ItemData(const string& desc) { +ItemData::ItemData(const string& desc, bool allow_raw_data) { + this->clear(); try { this->parse(desc, false); return; } catch (const exception&) { + this->clear(); } try { this->parse(desc, true); return; } catch (const exception&) { + if (!allow_raw_data) { + throw; + } + this->clear(); } string data = parse_data_string(desc); diff --git a/src/ItemData.hh b/src/ItemData.hh index 344932d7..8c732140 100644 --- a/src/ItemData.hh +++ b/src/ItemData.hh @@ -96,7 +96,7 @@ struct ItemData { // 0x14 bytes } __attribute__((packed)); ItemData(); - explicit ItemData(const std::string& orig_description); + explicit ItemData(const std::string& orig_description, bool allow_raw_data = true); ItemData(const ItemData& other); ItemData& operator=(const ItemData& other); diff --git a/src/Main.cc b/src/Main.cc index 3bcf8dda..b7ce8203 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -1333,7 +1333,7 @@ int main(int argc, char** argv) { } case Behavior::ENCODE_ITEM: { - ItemData item(input_filename); + ItemData item(input_filename, false); string desc = item.name(false); log_info("Data: %02hhX%02hhX%02hhX%02hhX %02hhX%02hhX%02hhX%02hhX %02hhX%02hhX%02hhX%02hhX -------- %02hhX%02hhX%02hhX%02hhX", item.data1[0], item.data1[1], item.data1[2], item.data1[3],