cxxtools::ArgIn Class Reference

Helper class for redirecting input to stdin or file using command line switch. More...

#include <cxxtools/argin.h>

Public Member Functions

 ArgIn (int &argc, char *argv[], char option)
 Constructor processes short options like: -i something.
 ArgIn (int &argc, char *argv[], const char *option)
 Constructor processes long options like: –input something".
 ArgIn (int &argc, char *argv[])
 Constructor processes normal parameters.
bool redirected () const
 returns true, if the input is read from a file.

Detailed Description

Helper class for redirecting input to stdin or file using command line switch.

Using this class it is easy to provide a command line switch to the user to read input from a file or stdin.

Examples:

int main(int argc, char* argv[])
{
cxxtools::ArgIn in(argc, argv, 'i');
double d;
while (in >> d)
{
std::cout << d*2 << std::endl;
}
}

This program reads data from stdin or a file, when provided using the -i option and doubles the value

int main(int argc, char* argv[])
{
cxxtools::ArgIn in(argc, argv);
double d;
while (in >> d)
{
std::cout << d*2 << std::endl;
}
}

This program reads data from stdin or a file, when provided as a parameter and doubles the value. This is similar to the <> operator in perl.

Constructor & Destructor Documentation

cxxtools::ArgIn::ArgIn ( int &  argc,
char *  argv[],
char  option 
)
inline

Constructor processes short options like: -i something.

cxxtools::ArgIn::ArgIn ( int &  argc,
char *  argv[],
const char *  option 
)
inline

Constructor processes long options like: –input something".

cxxtools::ArgIn::ArgIn ( int &  argc,
char *  argv[] 
)
inline

Constructor processes normal parameters.

Member Function Documentation

bool cxxtools::ArgIn::redirected ( ) const
inline

returns true, if the input is read from a file.


The documentation for this class was generated from the following file: