Add tests, fix missing bool in Accept and operator[] insert

Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
This commit is contained in:
Nicholas Van Sickle
2021-12-09 21:37:22 -08:00
parent a2d474cc4f
commit 15e0bb1693
2 changed files with 107 additions and 1 deletions
+20 -1
View File
@@ -407,7 +407,22 @@ namespace AZ::Dom
Value& Value::operator[](KeyType name)
{
return FindMember(name)->second;
Object::ContainerType& object = GetObjectInternal();
auto existingEntry = AZStd::find_if(
object.begin(), object.end(),
[&name](const Object::EntryType& entry)
{
return entry.first == name;
});
if (existingEntry != object.end())
{
return existingEntry->second;
}
else
{
object.emplace_back(name, Value());
return object[object.size() - 1].second;
}
}
const Value& Value::operator[](KeyType name) const
@@ -924,6 +939,10 @@ namespace AZ::Dom
{
result = visitor.Double(arg);
}
else if constexpr (AZStd::is_same_v<Alternative, bool>)
{
result = visitor.Bool(arg);
}
else if constexpr (AZStd::is_same_v<Alternative, AZStd::string_view>)
{
result = visitor.String(arg, copyStrings ? Lifetime::Temporary : Lifetime::Persistent);