32.9.1 Parameters that are of type file

Parameters that are "!TYPE file" hold an OEPlatform::oeisstream object. This object holds the contents of the file specified by the user. The file is opened and read into the oeisstream at the time OEParseCommandLine or OEParseCommandLineLW is called. The following example program copy a text file to standard out.

Chapter 32 - Example 11 : cpp file

#include "oeplatform.h"
#include "oesystem.h"

//Defines static const unsigned char* array InterfaceData
#include "ch32-11.itf"

using namespace OEPlatform;
using namespace OESystem;
using namespace std;

int main(int argc, char** argv)
{
  OEInterface itf;
  OEConfigure(itf,InterfaceData);
  if (OECheckHelp(itf,argc,argv)) return 0;
  OEParseCommandLineLW(itf,argc,argv);

  string line;
  oeisstream istr = itf.Get<oeisstream>("-infile");
  while (istr.getline(line)) oeout << line << oeendl;

  return 0;
}

Chapter 32 - Example 11 : OEConfigure txt configuration file

!PARAMETER -infile
  !TYPE file
  !KEYLESS 1
  !REQUIRED yes
  !BRIEF File to send to standard out
!END

If we have a text file babytalk.txt with the following contents

OOGA
booga

The program output would be as follows

> ch32-11 babytalk.txt
OOGA
booga
>