add option to require item descriptions instead of data

This commit is contained in:
Martin Michelsen
2023-07-06 21:58:17 -07:00
parent acfa708332
commit 97daebdf83
3 changed files with 9 additions and 3 deletions
+7 -1
View File
@@ -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);