Skip to content

Commit

Permalink
Trim enum strings of leading/tailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
DonLakeFlyer committed Sep 23, 2024
1 parent ad472f0 commit a1ca9ce
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/FactSystem/FactMetaData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1464,10 +1464,16 @@ bool FactMetaData::_parseEnum(const QJsonObject& jsonObject, DefineMap_t defineM
QString jsonStrings = jsonObject.value(_enumStringsJsonKey).toString();
QString defineMapStrings = defineMap.value(jsonStrings, jsonStrings);
rgDescriptions = defineMapStrings.split(",", Qt::SkipEmptyParts);
for (auto& desc: rgDescriptions) {
desc = desc.trimmed();
}

QString jsonValues = jsonObject.value(_enumValuesJsonKey).toString();
QString defineMapValues = defineMap.value(jsonValues, jsonValues);
rgValues = defineMapValues.split(",", Qt::SkipEmptyParts);
for (auto& value: rgValues) {
value = value.trimmed();
}

if (rgDescriptions.count() != rgValues.count()) {
errorString = QStringLiteral("Enum strings/values count mismatch - strings: '%1'[%2,%3] values: '%4'[%5,%6]").arg(defineMapStrings).arg(rgDescriptions.count()).arg(defineMapStrings.contains(",")).arg(defineMapValues).arg(rgValues.count()).arg(defineMapValues.contains(","));
Expand Down

0 comments on commit a1ca9ce

Please sign in to comment.