/* * Copyright (C) 2007-2013 Xagasoft, All rights reserved. * * This file is part of the libgats library and is released under the * terms of the license contained in the file LICENSE. */ #include "gats-qt/object.h" #include "gats-qt/integer.h" #include "gats-qt/float.h" #include "gats-qt/boolean.h" #include "gats-qt/string.h" #include "gats-qt/list.h" #include "gats-qt/dictionary.h" #include "gats-qt/null.h" #include "gats-qt/parseexception.h" #include #include Gats::Object::Object() { } Gats::Object::~Object() { } Gats::Object *Gats::Object::read( QIODevice &rIn ) { char buf; rIn.read( &buf, 1 ); Object *pObj = NULL; switch( buf ) { case 'i': pObj = new Gats::Integer(); break; case 's': pObj = new Gats::String(); break; case '0': case '1': pObj = new Gats::Boolean(); break; case 'l': pObj = new Gats::List(); break; case 'd': pObj = new Gats::Dictionary(); break; case 'f': // Normal floats case 'F': // Special float values pObj = new Gats::Float(); break; case 'n': pObj = new Gats::Null(); break; case 'e': return NULL; default: throw ParseException("Invalid Gats type discovered."); } pObj->read( rIn, buf ); return pObj; } const char *Gats::typeToStr( Gats::Type t ) { switch( t ) { case Gats::typeDictionary: return "dictionary"; case Gats::typeList: return "list"; case Gats::typeString: return "string"; case Gats::typeInteger: return "integer"; case Gats::typeFloat: return "float"; case Gats::typeBoolean: return "boolean"; case Gats::typeNull: return "null"; } return "***unknown***"; }