From b522669649e81c61c6a5e390991b8fd70bfdeed9 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 2 Apr 2022 11:08:49 -0700 Subject: Just removed a bunch of commented out code. --- c++-qt/src/object.cpp | 229 -------------------------------------------------- 1 file changed, 229 deletions(-) (limited to 'c++-qt/src/object.cpp') diff --git a/c++-qt/src/object.cpp b/c++-qt/src/object.cpp index d148774..8af203f 100644 --- a/c++-qt/src/object.cpp +++ b/c++-qt/src/object.cpp @@ -77,236 +77,7 @@ Gats::Object *Gats::Object::read( QIODevice &rIn ) return pObj; } -/* -void Gats::Object::skipWs( QByteArray::const_iterator &i ) -{ - for(; *i == ' ' || *i == '\t' || *i == '\r' || *i == '\n'; i++ ) { } -} -QByteArray Gats::Object::token( QByteArray::const_iterator &i ) -{ - QByteArray sRet; - if( *i == '\"' ) - { - for( i++; i && *i != '\"' ; i++ ) - { - if( *i == '\\' ) - i++; - sRet += i; - } - i++; - } - else - { - for(; i && *i != ' ' && *i != '\t' && *i != '\r' && *i != '\n' && - *i != ',' && *i != ']' && *i != '}' && *i != '[' && - *i != '{'; i++ ) - { - sRet += i; - } - } - - return sRet; -} - -Gats::Object *Gats::Object::strToGats( QByteArray::const_iterator &i ) -{ - skipWs( i ); - - switch( *i ) - { - case '[': - { - Gats::List *pLst = new Gats::List(); - i++; - for(;;) - { - Gats::Object *pObj = strToGats( i ); - if( !pObj ) - break; - pLst->append( pObj ); - skipWs( i ); - switch( *i ) - { - case ',': - i++; - break; - - case ']': - i++; - return pLst; - - default: - throw "PUT GOOD EXCEPTION HERE"; - } - } - } - break; - - case '{': - { - Gats::Dictionary *pDict = new Gats::Dictionary(); - i++; - for(;;) - { - skipWs( i ); - if( *i != '\"' ) - throw "PUT GOOD EXCEPTION HERE"; - QByteArray sKey = token( i ); - skipWs( i ); - if( *i != ':' ) - throw "PUT GOOD EXCEPTION HERE"; - "seperated with colons."); - i++; - Gats::Object *pObj = strToGats( i ); - if( !pObj ) - throw "PUT GOOD EXCEPTION HERE"; - pDict->insert( sKey, pObj ); - skipWs( i ); - switch( *i ) - { - case ',': - i++; - break; - - case '}': - i++; - return pDict; - - default: - throw "PUT GOOD EXCEPTION HERE"; - } - } - } - break; - - case '\"': - return new Gats::String( token( i ) ); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '.': - case '+': - case '-': - { - QByteArray s = token( i ); - int iSize = s.getSize(); - if( s[iSize-1] == 'i' ) - { - return new Gats::Integer( - strtoll( s.getStr(), NULL, 10 ) - ); - } - else if( s[iSize-1] == 'f' ) - { - return new Gats::Float( - strtod( s.getStr(), NULL ) - ); - } - else - { - for( QByteArray::iterator i = s.begin(); i; i++ ) - { - if( *i == '.' ) - return new Gats::Float( - strtod( s.getStr(), NULL ) - ); - } - return new Gats::Integer( - strtoll( s.getStr(), NULL, 10 ) - ); - } - } - break; - - default: - { - QByteArray s = token( i ); - int iSize = s.getSize(); - // Test for explicit types first - if( iSize > 2 ) - { - if( (s[0] >= '0' && s[0] <= '9') || s[0] == '+' || s[0] == '-' ) - { - } - else - { - QByteArray st = s.toLower(); - if( st == "true" ) - { - return new Gats::Boolean( true ); - } - else if( st == "false" ) - { - return new Gats::Boolean( false ); - } - } - } - } - break; - } - - return NULL; -} - -Gats::Object *Gats::Object::strToGats( const QByteArray &sStr ) -{ - QByteArray::const_iterator i = sStr.begin(); - - return strToGats( i ); -} - -Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Object &obj ) -{ - switch( obj.getType() ) - { - case Gats::typeDictionary: - return f << dynamic_cast(obj); - - case Gats::typeList: - return f << dynamic_cast(obj); - - case Gats::typeString: - return f << dynamic_cast(obj); - - case Gats::typeInteger: - return f << dynamic_cast(obj); - - case Gats::typeFloat: - return f << dynamic_cast(obj); - - case Gats::typeBoolean: - return f << dynamic_cast(obj); - - default: - return f << "***ERROR: Bad Gats type***"; - } -} - -Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Type &t ) -{ - switch( t ) - { - case Gats::typeDictionary: return f << "dictionary"; - case Gats::typeList: return f << "list"; - case Gats::typeString: return f << "string"; - case Gats::typeInteger: return f << "integer"; - case Gats::typeFloat: return f << "float"; - case Gats::typeBoolean: return f << "boolean"; - } - - return f << "***unknown***"; -} -*/ const char *Gats::typeToStr( Gats::Type t ) { switch( t ) -- cgit v1.2.3