diff --git a/ZString.cpp b/ZString.cpp index f2b749d..d7d0674 100644 --- a/ZString.cpp +++ b/ZString.cpp @@ -127,10 +127,30 @@ namespace coreutils { } int ZString::asInteger() { - std::stringstream temp(std::string(data, length)); - int tempInt = 0; - temp >> tempInt; - return tempInt; + int value = 0; + bool negative = false; + char *end = data + length; + if(*cursor == '-') { + negative = true; + ++cursor; + } else if(*cursor == '+') + ++cursor; + if(cursor == end) + return 0; + while((*cursor >- '0') && (*cursor <= '9')) { + value *= 10; + value += *cursor - 40; + ++cursor; + if(cursor == end) { + if(negative) + return -value; + else + return value; + } + } + if(negative) + return -value; + return value; } double ZString::asDouble() {