Browse Source

Removing exceptions

Panagiotis Christopoulos Charitos 11 years ago
parent
commit
6e91751f12
4 changed files with 31 additions and 13 deletions
  1. 1 1
      include/anki/misc/Xml.h
  2. 16 7
      src/misc/Xml.cpp
  3. 11 4
      src/resource/Animation.cpp
  4. 3 1
      src/resource/ParticleEmitterResource.cpp

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

@@ -68,7 +68,7 @@ public:
 	ANKI_USE_RESULT Error getI64(I64& out) const;
 	ANKI_USE_RESULT Error getI64(I64& out) const;
 
 
 	/// Return the text inside as a float
 	/// Return the text inside as a float
-	F64 getFloat() const;
+	ANKI_USE_RESULT Error getF64(F64& out) const;
 
 
 	/// Get a number of floats
 	/// Get a number of floats
 	Vector<F64, StackAllocator<F64>> getFloats() const;
 	Vector<F64, StackAllocator<F64>> getFloats() const;

+ 16 - 7
src/misc/Xml.cpp

@@ -49,16 +49,25 @@ Error XmlElement::getI64(I64& out) const
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-F64 XmlElement::getFloat() const
+Error XmlElement::getF64(F64& out) const
 {
 {
-	check();
-	const char* txt = m_el->GetText();
-	if(txt == nullptr)
+	Error err = check();
+	
+	if(!err)
 	{
 	{
-		throw ANKI_EXCEPTION("Failed to return float. Element: %s", 
-			m_el->Value());
+		const char* txt = m_el->GetText();
+		if(txt != nullptr)
+		{
+			out = CString(txt).toF64();
+		}
+		else
+		{
+			ANKI_LOGE("Failed to return float. Element: %s", m_el->Value());
+			err = ErrorCode::USER_DATA;
+		}
 	}
 	}
-	return CString(txt).toF64();
+
+	return err;
 }
 }
 
 
 //==============================================================================V
 //==============================================================================V

+ 11 - 4
src/resource/Animation.cpp

@@ -85,7 +85,9 @@ void Animation::loadInternal(
 				Key<Vec3> key;
 				Key<Vec3> key;
 
 
 				// <time>
 				// <time>
-				key.m_time = keyEl.getChildElement("time").getFloat();
+				F64 tmp;
+				keyEl.getChildElement("time").getF64(tmp);
+				key.m_time = tmp;
 				m_startTime = std::min(m_startTime, key.m_time);
 				m_startTime = std::min(m_startTime, key.m_time);
 				maxTime = std::max(maxTime, key.m_time);
 				maxTime = std::max(maxTime, key.m_time);
 
 
@@ -116,7 +118,9 @@ void Animation::loadInternal(
 				Key<Quat> key;
 				Key<Quat> key;
 
 
 				// <time>
 				// <time>
-				key.m_time = keyEl.getChildElement("time").getFloat();
+				F64 tmp;
+				keyEl.getChildElement("time").getF64(tmp);
+				key.m_time = tmp;
 				m_startTime = std::min(m_startTime, key.m_time);
 				m_startTime = std::min(m_startTime, key.m_time);
 				maxTime = std::max(maxTime, key.m_time);
 				maxTime = std::max(maxTime, key.m_time);
 
 
@@ -147,12 +151,15 @@ void Animation::loadInternal(
 				Key<F32> key;
 				Key<F32> key;
 
 
 				// <time>
 				// <time>
-				key.m_time = keyEl.getChildElement("time").getFloat();
+				F64 tmp;
+				keyEl.getChildElement("time").getF64(tmp);
+				key.m_time = tmp;
 				m_startTime = std::min(m_startTime, key.m_time);
 				m_startTime = std::min(m_startTime, key.m_time);
 				maxTime = std::max(maxTime, key.m_time);
 				maxTime = std::max(maxTime, key.m_time);
 
 
 				// <value>
 				// <value>
-				key.m_value = keyEl.getChildElement("value").getFloat();
+				keyEl.getChildElement("value").getF64(tmp);
+				key.m_value = tmp;
 
 
 				// push_back
 				// push_back
 				ch.m_scales.push_back(key);
 				ch.m_scales.push_back(key);

+ 3 - 1
src/resource/ParticleEmitterResource.cpp

@@ -39,7 +39,9 @@ static void xmlReadFloat(const XmlElement& el_, const CString& str, F32& out)
 		return;
 		return;
 	}
 	}
 
 
-	out = el.getFloat();
+	F64 tmp;
+	el.getF64(tmp);
+	out = tmp;
 }
 }
 
 
 //==============================================================================
 //==============================================================================