浏览代码

Removing exceptions

Panagiotis Christopoulos Charitos 11 年之前
父节点
当前提交
6107ad474c

+ 2 - 1
include/anki/misc/Xml.h

@@ -93,7 +93,8 @@ public:
 
 
 	/// Get the next element with the same name. Returns empty XmlElement if
 	/// Get the next element with the same name. Returns empty XmlElement if
 	/// it reached the end of the list
 	/// it reached the end of the list
-	XmlElement getNextSiblingElement(const CString& name) const;
+	ANKI_USE_RESULT Error getNextSiblingElement(
+		const CString& name, XmlElement& out) const;
 
 
 private:
 private:
 	tinyxml2::XMLElement* m_el;
 	tinyxml2::XMLElement* m_el;

+ 13 - 4
src/misc/Xml.cpp

@@ -243,11 +243,20 @@ Error XmlElement::getChildElement(const CString& name, XmlElement& out) const
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-XmlElement XmlElement::getNextSiblingElement(const CString& name) const
+Error XmlElement::getNextSiblingElement(
+	const CString& name, XmlElement& out) const
 {
 {
-	check();
-	XmlElement out(m_el->NextSiblingElement(&name[0]), m_alloc);
-	return out;
+	Error err = check();
+	if(!err)
+	{
+		out = XmlElement(m_el->NextSiblingElement(&name[0]), m_alloc);
+	}
+	else
+	{
+		out = XmlElement();
+	}
+
+	return err;
 }
 }
 
 
 //==============================================================================
 //==============================================================================

+ 4 - 4
src/resource/Animation.cpp

@@ -113,7 +113,7 @@ void Animation::loadInternal(
 				}
 				}
 
 
 				// Move to next
 				// Move to next
-				keyEl = keyEl.getNextSiblingElement("key");
+				keyEl.getNextSiblingElement("key", keyEl);
 			} while(keyEl);
 			} while(keyEl);
 		}
 		}
 
 
@@ -150,7 +150,7 @@ void Animation::loadInternal(
 				}
 				}
 
 
 				// Move to next
 				// Move to next
-				keyEl = keyEl.getNextSiblingElement("key");
+				keyEl.getNextSiblingElement("key", keyEl);
 			} while(keyEl);
 			} while(keyEl);
 		}
 		}
 
 
@@ -187,7 +187,7 @@ void Animation::loadInternal(
 				}
 				}
 
 
 				// Move to next
 				// Move to next
-				keyEl = keyEl.getNextSiblingElement("key");
+				keyEl.getNextSiblingElement("key", keyEl);
 			} while(keyEl);
 			} while(keyEl);
 		}
 		}
 
 
@@ -206,7 +206,7 @@ void Animation::loadInternal(
 		}
 		}
 
 
 		// Move to next channel
 		// Move to next channel
-		chEl = chEl.getNextSiblingElement("channel");
+		chEl.getNextSiblingElement("channel", chEl);
 	} while(chEl);
 	} while(chEl);
 
 
 	m_duration = maxTime - m_startTime;
 	m_duration = maxTime - m_startTime;

+ 6 - 6
src/resource/MaterialProgramCreator.cpp

@@ -107,7 +107,7 @@ void MaterialProgramCreator::parseProgramsTag(const XmlElement& el)
 	{
 	{
 		parseInputsTag(programEl);
 		parseInputsTag(programEl);
 
 
-		programEl = programEl.getNextSiblingElement("program");
+		programEl.getNextSiblingElement("program", programEl);
 	} while(programEl);
 	} while(programEl);
 
 
 	// Sort them by name to decrease the change of creating unique shaders
 	// Sort them by name to decrease the change of creating unique shaders
@@ -121,7 +121,7 @@ void MaterialProgramCreator::parseProgramsTag(const XmlElement& el)
 	{
 	{
 		parseProgramTag(programEl);
 		parseProgramTag(programEl);
 
 
-		programEl = programEl.getNextSiblingElement("program");
+		programEl.getNextSiblingElement("program", programEl);
 	} while(programEl);
 	} while(programEl);
 
 
 	//
 	//
@@ -175,7 +175,7 @@ void MaterialProgramCreator::parseProgramTag(
 		lines.push_back(
 		lines.push_back(
 			ANKI_STRL("#pragma anki include \"") + fname + "\"");
 			ANKI_STRL("#pragma anki include \"") + fname + "\"");
 
 
-		includeEl = includeEl.getNextSiblingElement("include");
+		includeEl.getNextSiblingElement("include", includeEl);
 	} while(includeEl);
 	} while(includeEl);
 
 
 	// Inputs
 	// Inputs
@@ -217,7 +217,7 @@ void MaterialProgramCreator::parseProgramTag(
 		lines.push_back(out);
 		lines.push_back(out);
 
 
 		// Advance
 		// Advance
-		opEl = opEl.getNextSiblingElement("operation");
+		opEl.getNextSiblingElement("operation", opEl);
 	} while(opEl);
 	} while(opEl);
 
 
 	lines.push_back(ANKI_STRL("}\n"));
 	lines.push_back(ANKI_STRL("}\n"));
@@ -421,7 +421,7 @@ void MaterialProgramCreator::parseInputsTag(const XmlElement& programEl)
 
 
 advance:
 advance:
 		// Advance
 		// Advance
-		inputEl = inputEl.getNextSiblingElement("input");
+		inputEl.getNextSiblingElement("input", inputEl);
 	} while(inputEl);
 	} while(inputEl);
 }
 }
 
 
@@ -532,7 +532,7 @@ void MaterialProgramCreator::parseOperationTag(
 			}
 			}
 
 
 			// Advance
 			// Advance
-			argEl = argEl.getNextSiblingElement("argument");
+			argEl.getNextSiblingElement("argument", argEl);
 		} while(argEl);
 		} while(argEl);
 	}
 	}
 
 

+ 1 - 1
src/resource/Mesh.cpp

@@ -331,7 +331,7 @@ void BucketMesh::load(const CString& filename, ResourceInitializer& init)
 			m_indicesCount += loader->getIndices().size();
 			m_indicesCount += loader->getIndices().size();
 
 
 			// Move to next
 			// Move to next
-			meshEl = meshEl.getNextSiblingElement("mesh");
+			meshEl.getNextSiblingElement("mesh", meshEl);
 			++i;
 			++i;
 		} while(meshEl);
 		} while(meshEl);
 
 

+ 1 - 1
src/resource/Model.cpp

@@ -403,7 +403,7 @@ void Model::load(const CString& filename, ResourceInitializer& init)
 			m_modelPatches.push_back(patch);
 			m_modelPatches.push_back(patch);
 
 
 			// Move to next
 			// Move to next
-			modelPatchEl = modelPatchEl.getNextSiblingElement("modelPatch");
+			modelPatchEl.getNextSiblingElement("modelPatch", modelPatchEl);
 		} while(modelPatchEl);
 		} while(modelPatchEl);
 
 
 		// Check number of model patches
 		// Check number of model patches

+ 2 - 2
src/resource/Skeleton.cpp

@@ -38,7 +38,7 @@ void Skeleton::load(const CString& filename, ResourceInitializer& init)
 	do
 	do
 	{
 	{
 		++bonesCount;
 		++bonesCount;
-		boneEl = boneEl.getNextSiblingElement("bone");
+		boneEl.getNextSiblingElement("bone", boneEl);
 	} while(boneEl);
 	} while(boneEl);
 
 
 	// Alloc the vector
 	// Alloc the vector
@@ -62,7 +62,7 @@ void Skeleton::load(const CString& filename, ResourceInitializer& init)
 		trfEl.getMat4(bone.m_transform);
 		trfEl.getMat4(bone.m_transform);
 
 
 		// Advance 
 		// Advance 
-		boneEl = boneEl.getNextSiblingElement("bone");
+		boneEl.getNextSiblingElement("bone", boneEl);
 	} while(boneEl);
 	} while(boneEl);
 }
 }