All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Protected Member Functions
QGpCoreTools::ArgumentStdinReader Class Reference

Brief description of class still missing. More...

#include <ArgumentStdinReader.h>

Inheritance diagram for QGpCoreTools::ArgumentStdinReader:
CoordReader CurveReader DispersionReader EC8Reader EllipticityReader Group2PhaseReader HistogramReader LiveModelReader MagnetoTelluricReader Model2ParamReader ProfileReader RefraReader ShReader SignalReader SpacReader TimeReader

List of all members.

Public Member Functions

bool read (int argc, char **argv)
virtual ~ArgumentStdinReader ()

Protected Member Functions

virtual bool parse (QTextStream &s)=0

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

{}

Member Function Documentation

virtual bool QGpCoreTools::ArgumentStdinReader::parse ( QTextStream &  s) [protected, pure virtual]
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;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines