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:
Eduardo Bart
2012-05-28 10:06:26 -03:00
parent 2676eb4da3
commit 4c80d783d6
75 changed files with 856 additions and 652 deletions

View File

@@ -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);

View File

@@ -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];
}

View File

@@ -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>

View File

@@ -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 == "~")