32.3.1 OEParseCommandLine

OEParseCommandLine is designed for moderately to highly complex interfaces. It expects the command line to consist of key-value pairs, where the key is the name of a parameter and the value is the parameters setting. Given following example program

Chapter 32 - Example 4: cpp file

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

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

using namespace OEPlatform;
using namespace OESystem;

int main(int argc, char** argv)
{
  OEInterface itf;
  OEConfigure(itf,InterfaceData);
  OEParseCommandLine(itf,argc,argv);
  OEWriteSettings(itf,oeout,true);
  return 0;
}

and text configuration file

Chapter 32 - Example 4: txt file

!PARAMETER -x
  !TYPE float
!END

!PARAMETER -y
  !TYPE float
!END

!PARAMETER -op
  !TYPE string
!END

Here is some example output with proper command lines

> ch32-4 -op add
#Interface settings
-op  add
#-x (Not set, no default)
#-y (Not set, no default)
> ch32-4 -op add -x 5 -y -4.5
#Interface settings
-op  add
-x  5.000000
-y  -4.500000
> ch32-4 -y -4.5 -op add -x 5
#Interface settings
-op  add
-x  5.000000
-y  -4.500000
>

and improper command lines

> ch32-4 -op add -x 9d
Fatal: 9d is not a legal setting for parameter -x (specified on command line)
> ch32-4 -op add -x 5 -yy -4.5
Fatal: Unknown argument on command line -yy
> ch32-4 -op add -x 5 -y
Fatal: Parameter -y on the command line is not followed by a value

This function is described in detail in the API documentation.