diff --git a/include/vsg/core/Object.h b/include/vsg/core/Object.h index 6ecdd0eff..3d6d69aa1 100644 --- a/include/vsg/core/Object.h +++ b/include/vsg/core/Object.h @@ -14,6 +14,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include +#include #include #include @@ -76,7 +77,7 @@ namespace vsg void setValue(const std::string& key, const char* value) { setValue(key, value ? std::string(value) : std::string()); } template - bool getValue(const std::string& key, T& value) const; + std::optional getValue(const std::string& key) const; void setObject(const std::string& key, Object* object); Object* getObject(const std::string& key); diff --git a/include/vsg/core/Value.h b/include/vsg/core/Value.h index 6e4f4feea..7725b9ea9 100644 --- a/include/vsg/core/Value.h +++ b/include/vsg/core/Value.h @@ -106,19 +106,18 @@ namespace vsg } template - bool Object::getValue(const std::string& key, T& value) const + std::optional Object::getValue(const std::string& key) const { using ValueT = Value; const Object* object = getObject(key); if (object && (typeid(*object) == typeid(ValueT))) { const ValueT* vo = static_cast(getObject(key)); - value = *vo; - return true; + return *vo; } else { - return false; + return {}; } } diff --git a/src/vsg/io/ObjectFactory.cpp b/src/vsg/io/ObjectFactory.cpp index eaa1a2e2b..5ed3f2bdd 100644 --- a/src/vsg/io/ObjectFactory.cpp +++ b/src/vsg/io/ObjectFactory.cpp @@ -30,7 +30,7 @@ using namespace vsg; ObjectFactory::ObjectFactory() { - _createMap["nulltr"] = []() { return ref_ptr(); }; + _createMap["nullptr"] = []() { return ref_ptr(); }; VSG_REGISTER_new(vsg::Object);