• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

tests/file/file.cpp

Go to the documentation of this file.
00001 #include <QApplication>
00002 
00003 #include "DGVFile.h"
00004 
00005 const string filename = "out_test.txt";
00006 
00007 void printLine(QStringList &strs);
00008 
00009 int main(int argc, char *argv[])
00010 {
00011         QApplication app(argc,argv);
00012         DGVFile file;
00013 
00014     cerr << ">| File Class Test" << endl;
00015     cerr << ">| Copyright Shekhar S. Chandra, 2008" << endl;
00016     cerr << ">| Original file: " << filename << endl;
00017 
00019         if(!file.open(filename.c_str(),"w"))
00020     {
00021         cerr << "ERROR: Opening file." << endl;
00022         app.exit();
00023     }
00024 
00025         QString text;
00026 
00027         text = "#This is a test file for DGVFile class";
00028         cerr << text.toStdString() << endl;
00029         file.writeLine(text);
00030         text = "This is some data";
00031         cerr << text.toStdString() << endl;
00032         file.writeLine(text);
00033         text = "This is data with # comments";
00034         cerr << text.toStdString() << endl;
00035         file.writeLine(text);
00036         text = "More data";
00037         cerr << text.toStdString() << endl;
00038         file.writeLine(text);
00039         file.close();
00040 
00042     cerr << ">| Read written file:" << endl;
00043     if(!file.open(filename.c_str(),"r"))
00044     {
00045         cerr << "ERROR: Opening file." << endl;
00046         app.exit();
00047     }
00048 
00049     QStringList line;
00050     while(!file.atEnd())
00051     {
00052         line = file.readNextLine();
00053         printLine(line);
00054     }
00055         file.close();
00056 
00057         app.exit();
00058 }
00059 
00060 void printLine(QStringList &strs)
00061 {
00062     //cerr << "Size: " << strs.size() << endl;
00063     for(int j = 0; j < strs.size(); j ++)
00064         cerr << "'" << strs[j].toStdString() << "' ";
00065     if(strs.size() != 0)
00066         cerr << endl;
00067 }

Generated on Wed Sep 8 2010 01:36:51 for DGV by  doxygen 1.7.1