Add loading of gdt entries to info based assets

This commit is contained in:
Jan
2021-03-28 12:07:36 +02:00
parent d9abf12b16
commit 579c0747d0
19 changed files with 410 additions and 146 deletions

View File

@ -93,7 +93,7 @@ void InfoString::ToGdtProperties(const std::string& prefix, GdtEntry& gdtEntry)
gdtEntry.m_properties[key] = value->second;
}
gdtEntry.m_properties["configstringFileType"] = prefix;
gdtEntry.m_properties[GDT_PREFIX_FIELD] = prefix;
}
class InfoStringInputStream
@ -195,3 +195,21 @@ bool InfoString::FromStream(const std::string& prefix, std::istream& stream)
return true;
}
bool InfoString::FromGdtProperties(const std::string& prefix, const GdtEntry& gdtEntry)
{
const auto foundPrefixEntry = gdtEntry.m_properties.find(GDT_PREFIX_FIELD);
if (foundPrefixEntry == gdtEntry.m_properties.end() || foundPrefixEntry->second != prefix)
return false;
for(const auto& [key, value] : gdtEntry.m_properties)
{
if(key == GDT_PREFIX_FIELD)
continue;
m_keys_by_insertion.push_back(key);
m_values.emplace(std::make_pair(key, value));
}
return true;
}

View File

@ -9,6 +9,8 @@
class InfoString
{
static constexpr const char* GDT_PREFIX_FIELD = "configstringFileType";
static const std::string EMPTY_VALUE;
std::unordered_map<std::string, std::string> m_values;
std::vector<std::string> m_keys_by_insertion;
@ -26,4 +28,5 @@ public:
bool FromStream(std::istream& stream);
bool FromStream(const std::string& prefix, std::istream& stream);
bool FromGdtProperties(const std::string& prefix, const GdtEntry& gdtEntry);
};