Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

omgserialisable.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           omgserialisable.cpp  -  description
00003                              -------------------
00004     begin                : March 2006
00005     copyright            : (C) 2003 by Tim Sutton
00006     email                : tim@linfiniti.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "omgserialisable.h"
00019 #include <QFile>
00020 #include <QString>
00021 #include <QTextStream>
00022 
00023 OmgSerialisable::OmgSerialisable()
00024 {
00025 }
00026 OmgSerialisable::~OmgSerialisable()
00027 {
00028 }
00029 bool OmgSerialisable::toXml(QString theFileName) const
00030 {
00031   bool myResult = false;
00032   QFile myFile( theFileName );
00033   if ( myFile.open( QIODevice::WriteOnly ) )
00034   {
00035     QTextStream myQTextStream( &myFile );
00036     myQTextStream << this->toXml();
00037     myFile.close();
00038     myResult=true;
00039   }
00040   else
00041   {
00042     //@TODO Error handler!
00043     myResult=false;
00044   }
00045   return myResult ;
00046 
00047 }
00048 
00049 bool OmgSerialisable::fromXmlFile(QString theFileName) 
00050 {
00051   bool myResult = false;
00052   QFile myFile( theFileName );
00053   if ( myFile.open( QIODevice::ReadOnly ) )
00054   {
00055     myResult=this->fromXml(myFile.readAll());
00056     myFile.close();
00057   }
00058   else
00059   {
00060     qDebug("Failed to open "  + theFileName.toLocal8Bit() + 
00061         " for deserialisation ");
00062     //@TODO Error handler!
00063     myResult=false;
00064   }
00065   return myResult ;
00066 }
00067 

Generated on Mon Apr 28 15:09:08 2008 for openModellerDesktop by  doxygen 1.4.1-20050210