#include #include "anki/misc/PropertyTree.h" #include "anki/util/Exception.h" namespace anki { namespace PropertyTree { //============================================================================== // getBool = //============================================================================== bool getBool(const boost::property_tree::ptree& pt, const char* tag) { std::string str = pt.get(tag); if(str == "true") { return true; } else if(str == "false") { return false; } else { throw ANKI_EXCEPTION("Expected true or false for tag " + tag + " and not " + str); } } //============================================================================== // getBoolOptional = //============================================================================== extern boost::optional getBoolOptional( const boost::property_tree::ptree& pt, const char* tag) { boost::optional str = pt.get_optional(tag); if(str) { if(str.get() == "true") { return boost::optional(true); } else if(str.get() == "false") { return boost::optional(true); } else { throw ANKI_EXCEPTION("Expected true or false for tag " + tag + " and not " + str.get()); } } return boost::optional(); } //============================================================================== // getFloat = //============================================================================== float getFloat(const boost::property_tree::ptree& pt) { return pt.get("float"); } //============================================================================== // getVec2 = //============================================================================== Vec2 getVec2(const boost::property_tree::ptree& pt) { const boost::property_tree::ptree& tree = pt.get_child("vec2"); return Vec2(tree.get("x"), tree.get("y")); } //============================================================================== // getVec3 = //============================================================================== Vec3 getVec3(const boost::property_tree::ptree& pt) { const boost::property_tree::ptree& tree = pt.get_child("vec3"); return Vec3( tree.get("x"), tree.get("y"), tree.get("z")); } //============================================================================== // getVec4 = //============================================================================== Vec4 getVec4(const boost::property_tree::ptree& pt) { const boost::property_tree::ptree& tree = pt.get_child("vec4"); return Vec4( tree.get("x"), tree.get("y"), tree.get("z"), tree.get("w")); } } // end namespace } // end namespace