Brief description of class still missing. More...
#include <ArgumentStdinReader.h>
Public Member Functions | |
| bool | read (int argc, char **argv) |
| virtual | ~ArgumentStdinReader () |
Protected Member Functions | |
| virtual bool | parse (QTextStream &s)=0 |
Brief description of class still missing.
Full description of class still missing
| virtual QGpCoreTools::ArgumentStdinReader::~ArgumentStdinReader | ( | ) | [inline, virtual] |
{}
| virtual bool QGpCoreTools::ArgumentStdinReader::parse | ( | QTextStream & | s | ) | [protected, pure virtual] |
Implemented in SignalReader, HistogramReader, LiveModelReader, CoordReader, CurveReader, ProfileReader, SpacReader, DispersionReader, EC8Reader, EllipticityReader, Group2PhaseReader, Model2ParamReader, RefraReader, ShReader, TimeReader, and MagnetoTelluricReader.
Referenced by read().
| bool QGpCoreTools::ArgumentStdinReader::read | ( | int | argc, |
| char ** | argv | ||
| ) |
Reads all files listed in arguments argc and argv. If there is no arguments, the stdin is read. If an error occurs, it returns false.
References QGpCoreTools::CoreApplicationPrivate::debugUserInterrupts(), QGpCoreTools::endl(), QGpCoreTools::CoreApplication::instance(), parse(), QGpCoreTools::App::stream(), QGpCoreTools::tr(), and TRACE.
Referenced by main(), and LiveModelReader::setOptions().
{
TRACE;
QTextStream sIn;
int i=1;
QFile * f;
if(i==argc) {
f=new QFile();
f->open(stdin, QIODevice::ReadOnly);
sIn.setDevice(f);
CoreApplication::instance()->debugUserInterrupts(false);
} else {
f=0;
}
while(true) {
if(f && sIn.atEnd()) {
delete f;
f=0;
// Closing file is not necessarily stdin but it does not hurt
CoreApplication::instance()->debugUserInterrupts(true);
}
if(!f) {
if(i<argc) {
f=new QFile(argv[i]);
if(!f->open(QIODevice::ReadOnly)) {
App::stream() << tr("Cannot open file %1 for reading.").arg(argv[i]) << endl;
delete f;
return false;
}
sIn.setDevice(f);
i++;
} else {
delete f;
return true;
}
}
if(!parse(sIn)) {
delete f;
return false;
}
}
return false;
}