浏览代码

More XML moves

Panagiotis Christopoulos Charitos 13 年之前
父节点
当前提交
901ceb3fd7

+ 45 - 18
include/anki/misc/Xml.h

@@ -6,10 +6,11 @@
 #if !ANKI_TINYXML2
 #if !ANKI_TINYXML2
 #	error "Wrong tinyxml2 included"
 #	error "Wrong tinyxml2 included"
 #endif
 #endif
+#include <string>
 
 
 namespace anki {
 namespace anki {
 
 
-/// XXX
+/// XML element
 struct XmlElement
 struct XmlElement
 {
 {
 	friend class XmlDocument;
 	friend class XmlDocument;
@@ -20,21 +21,47 @@ public:
 		: el(b.el)
 		: el(b.el)
 	{}
 	{}
 
 
+	/// If element has something return true
+	operator bool() const
+	{
+		return el != nullptr;
+	}
+
+	/// Copy
+	XmlElement& operator=(const XmlElement& b)
+	{
+		el = b.el;
+		return *this;
+	}
+
+	/// Return the text inside a tag
 	const char* getText() const
 	const char* getText() const
 	{
 	{
+		check();
 		return el->GetText();
 		return el->GetText();
 	}
 	}
 
 
-	XmlElement getChildElementOptional(const char* name)
+	/// Return the text inside as a string
+	int getInt() const
 	{
 	{
+		check();
+		return std::stoi(getText());
+	}
+
+	/// Get a child element quietly
+	XmlElement getChildElementOptional(const char* name) const
+	{
+		check();
 		XmlElement out;
 		XmlElement out;
 		out.el = el->FirstChildElement(name);
 		out.el = el->FirstChildElement(name);
 		return out;
 		return out;
 	}
 	}
 
 
-	XmlElement getChildElement(const char* name)
+	/// Get a child element and throw exception if not found
+	XmlElement getChildElement(const char* name) const
 	{
 	{
-		XmlElement out = getChildElementOptional(name);
+		check();
+		const XmlElement out = getChildElementOptional(name);
 		if(!out)
 		if(!out)
 		{
 		{
 			throw ANKI_EXCEPTION("Cannot find <" + name + ">");
 			throw ANKI_EXCEPTION("Cannot find <" + name + ">");
@@ -42,30 +69,29 @@ public:
 		return out;
 		return out;
 	}
 	}
 
 
-	XmlElement getNextSiblingElement(const char* name)
+	/// Get the next element with the same name. Returns empty XmlElement if
+	/// it reached the end of the list
+	XmlElement getNextSiblingElement(const char* name) const
 	{
 	{
+		check();
 		XmlElement out;
 		XmlElement out;
 		out.el = el->NextSiblingElement(name);
 		out.el = el->NextSiblingElement(name);
 		return out;
 		return out;
 	}
 	}
 
 
-	/// If element has something return true
-	operator bool() const
-	{
-		return el != nullptr;
-	}
+private:
+	tinyxml2::XMLElement* el = nullptr;
 
 
-	XmlElement& operator=(const XmlElement& b)
+	void check() const
 	{
 	{
-		el = b.el;
-		return *this;
+		if(el == nullptr)
+		{
+			throw ANKI_EXCEPTION("Empty element");
+		}
 	}
 	}
-
-private:
-	tinyxml2::XMLElement* el = nullptr;
 };
 };
 
 
-/// XXX
+/// XML document
 class XmlDocument
 class XmlDocument
 {
 {
 public:
 public:
@@ -73,7 +99,8 @@ public:
 	{
 	{
 		if(doc.LoadFile(filename))
 		if(doc.LoadFile(filename))
 		{
 		{
-			throw ANKI_EXCEPTION("Cannot parse file");
+			throw ANKI_EXCEPTION("Cannot parse file. Reason: "
+				+ doc.GetErrorStr1());
 		}
 		}
 	}
 	}
 
 

+ 3 - 3
include/anki/resource/Material.h

@@ -10,13 +10,13 @@
 #include "anki/util/NonCopyable.h"
 #include "anki/util/NonCopyable.h"
 #include "anki/gl/Ogl.h"
 #include "anki/gl/Ogl.h"
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <boost/ptr_container/ptr_vector.hpp>
-#include <boost/property_tree/ptree_fwd.hpp>
 
 
 namespace anki {
 namespace anki {
 
 
 // Forward
 // Forward
 class ShaderProgram;
 class ShaderProgram;
 class ShaderProgramUniformVariable;
 class ShaderProgramUniformVariable;
+class XmlElement;
 
 
 /// Material variable base. Its a visitable
 /// Material variable base. Its a visitable
 typedef Visitable<float, Vec2, Vec3, Vec4, Mat3, Mat4, TextureResourcePointer> 
 typedef Visitable<float, Vec2, Vec3, Vec4, Mat3, Mat4, TextureResourcePointer> 
@@ -362,14 +362,14 @@ private:
 	PassLevelToShaderProgramHashMap eSProgs;
 	PassLevelToShaderProgramHashMap eSProgs;
 
 
 	/// Parse what is within the @code <material></material> @endcode
 	/// Parse what is within the @code <material></material> @endcode
-	void parseMaterialTag(const boost::property_tree::ptree& pt);
+	void parseMaterialTag(const XmlElement& el);
 
 
 	/// Create a unique shader source in chache. If already exists do nothing
 	/// Create a unique shader source in chache. If already exists do nothing
 	std::string createShaderProgSourceToCache(const std::string& source);
 	std::string createShaderProgSourceToCache(const std::string& source);
 
 
 	/// Read all shader programs and pupulate the @a vars and @a nameToVar
 	/// Read all shader programs and pupulate the @a vars and @a nameToVar
 	/// containers
 	/// containers
-	void populateVariables(const boost::property_tree::ptree& pt);
+	void populateVariables(const XmlElement& el);
 
 
 	/// Parses something like this: "0.0 0.01 -1.2" and returns a valid
 	/// Parses something like this: "0.0 0.01 -1.2" and returns a valid
 	/// math type
 	/// math type

+ 7 - 6
include/anki/resource/MaterialShaderProgramCreator.h

@@ -2,17 +2,18 @@
 #define ANKI_RESOURCE_MATERIAL_SHADER_PROGRAM_CREATOR_H
 #define ANKI_RESOURCE_MATERIAL_SHADER_PROGRAM_CREATOR_H
 
 
 #include "anki/util/StringList.h"
 #include "anki/util/StringList.h"
-#include <boost/property_tree/ptree_fwd.hpp>
 
 
 namespace anki {
 namespace anki {
 
 
+class XmlElement;
+
 /// Creator of shader programs. This class parses between
 /// Creator of shader programs. This class parses between
 /// <shaderProgam></shaderProgram> located inside a <material></material>
 /// <shaderProgam></shaderProgram> located inside a <material></material>
 /// and creates the source of a custom program.
 /// and creates the source of a custom program.
 class MaterialShaderProgramCreator
 class MaterialShaderProgramCreator
 {
 {
 public:
 public:
-	MaterialShaderProgramCreator(const boost::property_tree::ptree& pt);
+	MaterialShaderProgramCreator(const XmlElement& pt);
 	~MaterialShaderProgramCreator();
 	~MaterialShaderProgramCreator();
 
 
 	/// Get the shader program source code. This is the one and only public
 	/// Get the shader program source code. This is the one and only public
@@ -33,18 +34,18 @@ private:
 
 
 	/// Parse what is within the
 	/// Parse what is within the
 	/// @code <shaderProgram></shaderProgram> @endcode
 	/// @code <shaderProgram></shaderProgram> @endcode
-	void parseShaderProgramTag(const boost::property_tree::ptree& pt);
+	void parseShaderProgramTag(const XmlElement& el);
 
 
 	/// Parse what is within the
 	/// Parse what is within the
 	/// @code <shader></shader> @endcode
 	/// @code <shader></shader> @endcode
-	void parseShaderTag(const boost::property_tree::ptree& pt);
+	void parseShaderTag(const XmlElement& el);
 
 
 	/// Parse what is within the @code <input></input> @endcode
 	/// Parse what is within the @code <input></input> @endcode
-	void parseInputTag(const boost::property_tree::ptree& pt,
+	void parseInputTag(const XmlElement& el,
 		std::string& line);
 		std::string& line);
 
 
 	/// Parse what is within the @code <operation></operation> @endcode
 	/// Parse what is within the @code <operation></operation> @endcode
-	void parseOperationTag(const boost::property_tree::ptree& pt);
+	void parseOperationTag(const XmlElement& el);
 };
 };
 
 
 } // end namespace anki
 } // end namespace anki

+ 1 - 1
shaders/IsLpGeneric.glsl

@@ -99,7 +99,7 @@ float getAttenuation(in float fragLightDist)
 /// @return The blurred shadow
 /// @return The blurred shadow
 float pcfLow(in vec3 shadowUv)
 float pcfLow(in vec3 shadowUv)
 {
 {
-	shadowCol  = textureOffset(shadowMap, shadowUv, ivec2(-1, -1));
+	float shadowCol = textureOffset(shadowMap, shadowUv, ivec2(-1, -1));
 	shadowCol += textureOffset(shadowMap, shadowUv, ivec2(0, -1));
 	shadowCol += textureOffset(shadowMap, shadowUv, ivec2(0, -1));
 	shadowCol += textureOffset(shadowMap, shadowUv, ivec2(1, -1));
 	shadowCol += textureOffset(shadowMap, shadowUv, ivec2(1, -1));
 	shadowCol += textureOffset(shadowMap, shadowUv, ivec2(-1, 0));
 	shadowCol += textureOffset(shadowMap, shadowUv, ivec2(-1, 0));

+ 2 - 2
src/renderer/Dbg.cpp

@@ -66,10 +66,10 @@ void Dbg::run()
 		sceneDrawer->draw(*node);
 		sceneDrawer->draw(*node);
 	}
 	}
 
 
-	for(const Sector& sector : scene.sectors)
+	/*for(const Sector& sector : scene.sectors)
 	{
 	{
 		sceneDrawer->draw(sector.getOctree());
 		sceneDrawer->draw(sector.getOctree());
-	}
+	}*/
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki

+ 50 - 65
src/resource/Material.cpp

@@ -5,11 +5,11 @@
 #include "anki/util/Filesystem.h"
 #include "anki/util/Filesystem.h"
 #include "anki/resource/ShaderProgramResource.h"
 #include "anki/resource/ShaderProgramResource.h"
 #include "anki/resource/TextureResource.h"
 #include "anki/resource/TextureResource.h"
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/xml_parser.hpp>
+#include "anki/misc/Xml.h"
 #include <functional>
 #include <functional>
 #include <algorithm>
 #include <algorithm>
 #include <map>
 #include <map>
+#include <fstream>
 
 
 namespace anki {
 namespace anki {
 
 
@@ -97,10 +97,9 @@ void Material::load(const char* filename)
 	fname = filename;
 	fname = filename;
 	try
 	try
 	{
 	{
-		using namespace boost::property_tree;
-		ptree pt;
-		read_xml(filename, pt, xml_parser::no_comments);
-		parseMaterialTag(pt.get_child("material"));
+		XmlDocument doc;
+		doc.loadFile(filename);
+		parseMaterialTag(doc.getChildElement("material"));
 	}
 	}
 	catch(std::exception& e)
 	catch(std::exception& e)
 	{
 	{
@@ -109,22 +108,19 @@ void Material::load(const char* filename)
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
+void Material::parseMaterialTag(const XmlElement& materialEl)
 {
 {
-	using namespace boost::property_tree;
-
 	// renderingStage
 	// renderingStage
 	//
 	//
-	renderingStage = pt.get<int>("renderingStage");
+	renderingStage = materialEl.getChildElement("renderingStage").getInt();
 
 
 	// passes
 	// passes
 	//
 	//
-	boost::optional<std::string> pass =
-		pt.get_optional<std::string>("passes");
+	XmlElement passEl = materialEl.getChildElementOptional("passes");
 
 
-	if(pass)
+	if(passEl)
 	{
 	{
-		passes = StringList::splitString(pass.get().c_str(), ' ');
+		passes = StringList::splitString(passEl.getText(), ' ');
 	}
 	}
 	else
 	else
 	{
 	{
@@ -133,11 +129,12 @@ void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
 
 
 	// levelsOfDetail
 	// levelsOfDetail
 	//
 	//
-	boost::optional<int> lod = pt.get_optional<int>("levelsOfDetail");
+	XmlElement lodEl = materialEl.getChildElementOptional("levelsOfDetail");
 
 
-	if(lod)
+	if(lodEl)
 	{
 	{
-		levelsOfDetail = (lod.get() < 1) ? 1 : lod.get();
+		int tmp = lodEl.getInt();
+		levelsOfDetail = (tmp < 1) ? 1 : tmp;
 	}
 	}
 	else
 	else
 	{
 	{
@@ -146,55 +143,52 @@ void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
 
 
 	// shadow
 	// shadow
 	//
 	//
-	boost::optional<int> sw = pt.get_optional<int>("shadow");
+	XmlElement shadowEl = materialEl.getChildElementOptional("shadow");
 
 
-	if(sw)
+	if(shadowEl)
 	{
 	{
-		shadow = sw.get();
+		shadow = shadowEl.getInt();
 	}
 	}
 
 
 	// blendFunctions
 	// blendFunctions
 	//
 	//
-	boost::optional<const ptree&> blendFuncsTree =
-		pt.get_child_optional("blendFunctions");
-	if(blendFuncsTree)
+	XmlElement blendFunctionsEl =
+		materialEl.getChildElementOptional("blendFunctions");
+
+	if(blendFunctionsEl)
 	{
 	{
 		// sFactor
 		// sFactor
-		{
-			const std::string& tmp =
-				blendFuncsTree.get().get<std::string>("sFactor");
-			blendingSfactor = blendToEnum(tmp.c_str());
-		}
+		blendingSfactor = blendToEnum(
+			blendFunctionsEl.getChildElement("sFactor").getText());
 
 
 		// dFactor
 		// dFactor
-		{
-			const std::string& tmp =
-				blendFuncsTree.get().get<std::string>("dFactor");
-			blendingDfactor = blendToEnum(tmp.c_str());
-		}
+		blendingDfactor = blendToEnum(
+			blendFunctionsEl.getChildElement("dFactor").getText());
 	}
 	}
 
 
 	// depthTesting
 	// depthTesting
 	//
 	//
-	boost::optional<int> dp = pt.get_optional<int>("depthTesting");
+	XmlElement depthTestingEl =
+		materialEl.getChildElementOptional("depthTesting");
 
 
-	if(dp)
+	if(depthTestingEl)
 	{
 	{
-		depthTesting = dp.get();
+		depthTesting = depthTestingEl.getInt();
 	}
 	}
 
 
 	// wireframe
 	// wireframe
 	//
 	//
-	boost::optional<int> wf = pt.get_optional<int>("wireframe");
+	XmlElement wireframeEl = materialEl.getChildElementOptional("wireframe");
 
 
-	if(wf)
+	if(wireframeEl)
 	{
 	{
-		wireframe = wf.get();
+		wireframe = wireframeEl.getInt();
 	}
 	}
 
 
 	// shaderProgram
 	// shaderProgram
 	//
 	//
-	MaterialShaderProgramCreator mspc(pt.get_child("shaderProgram"));
+	XmlElement shaderProgramEl = materialEl.getChildElement("shaderProgram");
+	MaterialShaderProgramCreator mspc(shaderProgramEl);
 
 
 	for(uint level = 0; level < levelsOfDetail; ++level)
 	for(uint level = 0; level < levelsOfDetail; ++level)
 	{
 	{
@@ -222,7 +216,7 @@ void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
 		}
 		}
 	}
 	}
 
 
-	populateVariables(pt.get_child("shaderProgram"));
+	populateVariables(shaderProgramEl);
 }
 }
 
 
 //==============================================================================
 //==============================================================================
@@ -257,10 +251,8 @@ std::string Material::createShaderProgSourceToCache(const std::string& source)
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-void Material::populateVariables(const boost::property_tree::ptree& pt)
+void Material::populateVariables(const XmlElement& shaderProgramEl)
 {
 {
-	using namespace boost::property_tree;
-
 	// Get all names of all the uniforms. Dont duplicate
 	// Get all names of all the uniforms. Dont duplicate
 	//
 	//
 	std::map<std::string, GLenum> allVarNames;
 	std::map<std::string, GLenum> allVarNames;
@@ -277,33 +269,22 @@ void Material::populateVariables(const boost::property_tree::ptree& pt)
 	// Iterate all the <input> and get the value
 	// Iterate all the <input> and get the value
 	//
 	//
 	std::map<std::string, std::string> nameToValue;
 	std::map<std::string, std::string> nameToValue;
+	XmlElement shaderEl = shaderProgramEl.getChildElement("shader");
 
 
-	for(const ptree::value_type& v : pt)
+	do
 	{
 	{
-		if(v.first != "shader")
-		{
-			throw ANKI_EXCEPTION("Expected \"shader\" tag and not: " +
-				v.first);
-		}
+		XmlElement insEl = shaderEl.getChildElementOptional("inputs");
 
 
-		boost::optional<const ptree&> insPt =
-			v.second.get_child_optional("inputs");
-
-		if(!insPt)
+		if(!insEl)
 		{
 		{
 			continue;
 			continue;
 		}
 		}
 
 
-		for(const ptree::value_type& vv : insPt.get())
+		XmlElement inEl = insEl.getChildElement("input");
+		do
 		{
 		{
-			if(vv.first != "input")
-			{
-				throw ANKI_EXCEPTION("Expected \"input\" tag and not: " 
-					+ vv.first);
-			}
-
-			std::string name = vv.second.get<std::string>("name");
-			std::string value = vv.second.get<std::string>("value");
+			std::string name = inEl.getChildElement("name").getText();
+			std::string value = inEl.getChildElement("value").getText();
 
 
 			nameToValue[name] = value;
 			nameToValue[name] = value;
 
 
@@ -317,8 +298,12 @@ void Material::populateVariables(const boost::property_tree::ptree& pt)
 					<< " not used by shader program. Material:"
 					<< " not used by shader program. Material:"
 					<< fname);
 					<< fname);
 			}
 			}
-		}
-	}
+
+			inEl = inEl.getNextSiblingElement("input");
+		} while(inEl);
+
+		shaderEl = shaderEl.getNextSiblingElement("shader");
+	} while(shaderEl);
 
 
 	// Now combine
 	// Now combine
 	//
 	//

+ 55 - 84
src/resource/MaterialShaderProgramCreator.cpp

@@ -1,15 +1,17 @@
 #include "anki/resource/MaterialShaderProgramCreator.h"
 #include "anki/resource/MaterialShaderProgramCreator.h"
 #include "anki/util/Assert.h"
 #include "anki/util/Assert.h"
 #include "anki/util/Exception.h"
 #include "anki/util/Exception.h"
-#include <boost/property_tree/ptree.hpp>
+#include "anki/misc/Xml.h"
+#include <algorithm>
+#include <sstream>
 
 
 namespace anki {
 namespace anki {
 
 
 //==============================================================================
 //==============================================================================
 MaterialShaderProgramCreator::MaterialShaderProgramCreator(
 MaterialShaderProgramCreator::MaterialShaderProgramCreator(
-	const boost::property_tree::ptree& pt)
+	const XmlElement& el)
 {
 {
-	parseShaderProgramTag(pt);
+	parseShaderProgramTag(el);
 }
 }
 
 
 //==============================================================================
 //==============================================================================
@@ -18,20 +20,16 @@ MaterialShaderProgramCreator::~MaterialShaderProgramCreator()
 
 
 //==============================================================================
 //==============================================================================
 void MaterialShaderProgramCreator::parseShaderProgramTag(
 void MaterialShaderProgramCreator::parseShaderProgramTag(
-	const boost::property_tree::ptree& pt)
+	const XmlElement& shaderProgramEl)
 {
 {
-	using namespace boost::property_tree;
+	XmlElement shaderEl = shaderProgramEl.getChildElement("shader");
 
 
-	for(const ptree::value_type& v : pt)
+	do
 	{
 	{
-		if(v.first != "shader")
-		{
-			throw ANKI_EXCEPTION("Expected \"shader\" tag and not: "
-				+ v.first);
-		}
-		
-		parseShaderTag(v.second);
-	}
+		parseShaderTag(shaderEl);
+
+		shaderEl = shaderEl.getNextSiblingElement("shader");
+	} while(shaderEl);
 
 
 	source = srcLines.join("\n");
 	source = srcLines.join("\n");
 	//std::cout << source << std::endl;
 	//std::cout << source << std::endl;
@@ -39,57 +37,49 @@ void MaterialShaderProgramCreator::parseShaderProgramTag(
 
 
 //==============================================================================
 //==============================================================================
 void MaterialShaderProgramCreator::parseShaderTag(
 void MaterialShaderProgramCreator::parseShaderTag(
-	const boost::property_tree::ptree& pt)
+	const XmlElement& shaderEl)
 {
 {
-	using namespace boost::property_tree;
-
 	// <type></type>
 	// <type></type>
 	//
 	//
-	const std::string& type = pt.get<std::string>("type");
+	std::string type = shaderEl.getChildElement("type").getText();
 	srcLines.push_back("#pragma anki start " + type + "Shader");
 	srcLines.push_back("#pragma anki start " + type + "Shader");
 
 
 	// <includes></includes>
 	// <includes></includes>
 	//
 	//
 	std::vector<std::string> includeLines;
 	std::vector<std::string> includeLines;
 
 
-	const ptree& includesPt = pt.get_child("includes");
-	for(const ptree::value_type& v : includesPt)
+	XmlElement includesEl = shaderEl.getChildElement("includes");
+	XmlElement includeEl = includesEl.getChildElement("include");
+
+	do
 	{
 	{
-		if(v.first != "include")
-		{
-			throw ANKI_EXCEPTION("Expected \"include\" tag and not: " + 
-				v.first);
-		}
+		std::string fname = includeEl.getText();
+		includeLines.push_back(std::string("#pragma anki include \"")
+			+ fname + "\"");
 
 
-		const std::string& fname = v.second.data();
-		includeLines.push_back(std::string("#pragma anki include \"") +
-			fname + "\"");
-	}
+		includeEl = includeEl.getNextSiblingElement("include");
+	} while(includeEl);
 
 
 	//std::sort(includeLines.begin(), includeLines.end(), compareStrings);
 	//std::sort(includeLines.begin(), includeLines.end(), compareStrings);
 	srcLines.insert(srcLines.end(), includeLines.begin(), includeLines.end());
 	srcLines.insert(srcLines.end(), includeLines.begin(), includeLines.end());
 
 
 	// <inputs></inputs>
 	// <inputs></inputs>
 	//
 	//
-	boost::optional<const ptree&> insPt = pt.get_child_optional("inputs");
-	if(insPt)
+	XmlElement inputsEl = shaderEl.getChildElementOptional("inputs");
+	if(inputsEl)
 	{
 	{
 		// Store the source of the uniform vars
 		// Store the source of the uniform vars
 		std::vector<std::string> uniformsLines;
 		std::vector<std::string> uniformsLines;
 	
 	
-		for(const ptree::value_type& v : insPt.get())
+		XmlElement inputEl = inputsEl.getChildElement("input");
+		do
 		{
 		{
-			if(v.first != "input")
-			{
-				throw ANKI_EXCEPTION("Expected \"input\" tag and not: "
-					+  v.first);
-			}
-
-			const ptree& inPt = v.second;
 			std::string line;
 			std::string line;
-			parseInputTag(inPt, line);
+			parseInputTag(inputEl, line);
 			uniformsLines.push_back(line);
 			uniformsLines.push_back(line);
-		} // end for all ins
+
+			inputEl = inputEl.getNextSiblingElement("input");
+		} while(inputEl);
 
 
 		srcLines.push_back("");
 		srcLines.push_back("");
 		std::sort(uniformsLines.begin(), uniformsLines.end(), compareStrings);
 		std::sort(uniformsLines.begin(), uniformsLines.end(), compareStrings);
@@ -101,79 +91,60 @@ void MaterialShaderProgramCreator::parseShaderTag(
 	//
 	//
 	srcLines.push_back("\nvoid main()\n{");
 	srcLines.push_back("\nvoid main()\n{");
 
 
-	const ptree& opsPt = pt.get_child("operations");
-
-	for(const ptree::value_type& v : opsPt)
+	XmlElement opsEl = shaderEl.getChildElement("operations");
+	XmlElement opEl = opsEl.getChildElement("operation");
+	do
 	{
 	{
-		if(v.first != "operation")
-		{
-			throw ANKI_EXCEPTION("Expected \"operation\" tag and not: "
-				+ v.first);
-		}
+		parseOperationTag(opEl);
 
 
-		const ptree& opPt = v.second;
-		parseOperationTag(opPt);
-	} // end for all operations
+		opEl = opEl.getNextSiblingElement("operation");
+	} while(opEl);
 
 
 	srcLines.push_back("}\n");
 	srcLines.push_back("}\n");
 }
 }
 
 
 //==============================================================================
 //==============================================================================
 void MaterialShaderProgramCreator::parseInputTag(
 void MaterialShaderProgramCreator::parseInputTag(
-	const boost::property_tree::ptree& pt, std::string& line)
+	const XmlElement& inputEl, std::string& line)
 {
 {
-	using namespace boost::property_tree;
-
-	const std::string& name = pt.get<std::string>("name");
-	const std::string& type = pt.get<std::string>("type");
+	const std::string& name = inputEl.getChildElement("name").getText();
+	const std::string& type = inputEl.getChildElement("type").getText();
 
 
 	line = "uniform " + type + " " + name + ";";
 	line = "uniform " + type + " " + name + ";";
 }
 }
 
 
 //==============================================================================
 //==============================================================================
 void MaterialShaderProgramCreator::parseOperationTag(
 void MaterialShaderProgramCreator::parseOperationTag(
-	const boost::property_tree::ptree& pt)
+	const XmlElement& operationTag)
 {
 {
-	using namespace boost::property_tree;
-
 	// <id></id>
 	// <id></id>
-	int id = pt.get<int>("id");
+	int id = operationTag.getChildElement("id").getInt();
 	
 	
 	// <returnType></returnType>
 	// <returnType></returnType>
-	boost::optional<std::string> retTypeOpt =
-		pt.get_optional<std::string>("returnType");
+	XmlElement retTypeEl = operationTag.getChildElementOptional("returnType");
 
 
 	std::string operationOut;
 	std::string operationOut;
-	if(retTypeOpt)
+	if(retTypeEl)
 	{
 	{
 		operationOut = "operationOut" + std::to_string(id);
 		operationOut = "operationOut" + std::to_string(id);
 	}
 	}
 	
 	
 	// <function>functionName</function>
 	// <function>functionName</function>
-	const std::string& funcName = pt.get<std::string>("function");
+	std::string funcName = operationTag.getChildElement("function").getText();
 	
 	
 	// <arguments></arguments>
 	// <arguments></arguments>
-	boost::optional<const ptree&> argsPt = pt.get_child_optional("arguments");
+	XmlElement argsEl = operationTag.getChildElementOptional("arguments");
 	StringList argsList;
 	StringList argsList;
 	
 	
-	if(argsPt)
+	if(argsEl)
 	{
 	{
 		// Get all arguments
 		// Get all arguments
-		ptree::const_iterator it = argsPt.get().begin();
-		for(; it != argsPt.get().end(); ++it)
+		XmlElement argEl = argsEl.getChildElement("argument");
+		do
 		{
 		{
-			const ptree::value_type& v = *it;
-		
-			if(v.first != "argument")
-			{
-				throw ANKI_EXCEPTION("Operation "
-					+ std::to_string(id)
-					+ ": Expected \"argument\" tag and not: " + v.first);
-			}
-
-			const std::string& argName = v.second.data();
-			argsList.push_back(argName);
-		}
+			argsList.push_back(argEl.getText());
+			argEl = argEl.getNextSiblingElement("argument");
+		} while(argEl);
 	}
 	}
 
 
 	// Now write everything
 	// Now write everything
@@ -192,10 +163,10 @@ void MaterialShaderProgramCreator::parseOperationTag(
 	}
 	}
 	line << "\n";
 	line << "\n";
 
 
-	if(retTypeOpt)
+	if(retTypeEl)
 	{
 	{
 		line << "#\tdefine " << operationOut << "_DEFINED\n";
 		line << "#\tdefine " << operationOut << "_DEFINED\n";
-		line << '\t' << retTypeOpt.get() << " " << operationOut << " = ";
+		line << '\t' << retTypeEl.getText() << " " << operationOut << " = ";
 	}
 	}
 	else
 	else
 	{
 	{
@@ -218,4 +189,4 @@ bool MaterialShaderProgramCreator::compareStrings(
 	return a < b;
 	return a < b;
 }
 }
 
 
-} // end namespace
+} // end namespace anki

+ 6 - 3
src/resource/Model.cpp

@@ -125,12 +125,15 @@ void Model::load(const char* filename)
 		XmlElement rootEl = doc.getChildElement("model");
 		XmlElement rootEl = doc.getChildElement("model");
 
 
 		// modelPatches
 		// modelPatches
-		XmlElement modelPatchesEl = rootEl.getChildElement("modelPatches");
-		XmlElement modelPatchEl = modelPatchesEl.getChildElement("modelPatch");
+		XmlElement modelPatchesEl =
+			rootEl.getChildElement("modelPatches");
+		XmlElement modelPatchEl =
+			modelPatchesEl.getChildElement("modelPatch");
 		do
 		do
 		{
 		{
 			XmlElement meshEl = modelPatchEl.getChildElement("mesh");
 			XmlElement meshEl = modelPatchEl.getChildElement("mesh");
-			XmlElement materialEl = modelPatchEl.getChildElement("material");
+			XmlElement materialEl =
+				modelPatchEl.getChildElement("material");
 
 
 			ModelPatch* patch = new ModelPatch(meshEl.getText(),
 			ModelPatch* patch = new ModelPatch(meshEl.getText(),
 				materialEl.getText());
 				materialEl.getText());