mirror of
https://github.com/edubart/otclient.git
synced 2026-01-09 07:41:29 +01:00
rewrite and reoganize tools functions
* create stdext namespace which contains additional C++ algorithms * organize stdext in string, math, cast and exception utilities
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
#include "declarations.h"
|
||||
|
||||
/// All OTML errors throw this exception
|
||||
class OTMLException : public Exception
|
||||
class OTMLException : public stdext::exception
|
||||
{
|
||||
public:
|
||||
OTMLException(const OTMLNodePtr& node, const std::string& error);
|
||||
|
||||
@@ -77,14 +77,14 @@ OTMLNodePtr OTMLNode::at(const std::string& childTag)
|
||||
}
|
||||
}
|
||||
if(!res)
|
||||
throw OTMLException(shared_from_this(), Fw::mkstr("child node with tag '", childTag, "' not found"));
|
||||
throw OTMLException(shared_from_this(), stdext::mkstr("child node with tag '", childTag, "' not found"));
|
||||
return res;
|
||||
}
|
||||
|
||||
OTMLNodePtr OTMLNode::atIndex(int childIndex)
|
||||
{
|
||||
if(childIndex >= size() || childIndex < 0)
|
||||
throw OTMLException(shared_from_this(), Fw::mkstr("child node with index '", childIndex, "' not found"));
|
||||
throw OTMLException(shared_from_this(), stdext::mkstr("child node with index '", childIndex, "' not found"));
|
||||
return m_children[childIndex];
|
||||
}
|
||||
|
||||
|
||||
@@ -107,8 +107,8 @@ protected:
|
||||
template<typename T>
|
||||
T OTMLNode::value() {
|
||||
T ret;
|
||||
if(!Fw::cast(m_value, ret))
|
||||
throw OTMLException(shared_from_this(), Fw::mkstr("failed to cast node value to type '", Fw::demangleType<T>(), "'"));
|
||||
if(!stdext::cast(m_value, ret))
|
||||
throw OTMLException(shared_from_this(), stdext::mkstr("failed to cast node value to type '", stdext::demangle_type<T>(), "'"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ T OTMLNode::valueAtIndex(int childIndex, const T& def) {
|
||||
|
||||
template<typename T>
|
||||
void OTMLNode::write(const T& v) {
|
||||
m_value = Fw::safeCast<std::string>(v);
|
||||
m_value = stdext::safe_cast<std::string>(v);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -181,7 +181,7 @@ void OTMLParser::parseNode(const std::string& data)
|
||||
|
||||
node->setUnique(dotsPos != std::string::npos);
|
||||
node->setTag(tag);
|
||||
node->setSource(doc->source() + ":" + Fw::unsafeCast<std::string>(nodeLine));
|
||||
node->setSource(doc->source() + ":" + stdext::unsafe_cast<std::string>(nodeLine));
|
||||
|
||||
// ~ is considered the null value
|
||||
if(value == "~")
|
||||
|
||||
Reference in New Issue
Block a user