FBB::Arg(3bobcat)

Command Line Arguments
(libbobcat-dev_4.08.03-x.tar.gz)

2005-2018

NAME

FBB::Arg - A singleton class interfacing command line arguments

SYNOPSIS

#include <bobcat/arg>
Linking option: -lbobcat

DESCRIPTION

Singleton class (see Gamma et al., 1995) built around getopt()(3) and getopt_long()(3). The class handles short- and long command-line options,

NAMESPACE

FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

INHERITS FROM

-

ENUMERATION

The FBB::Arg::Type enumeration is defined by the FBB::Arg class. It has the following values intended for public use: None, Required, Optional. These values are used when constructing objects of the nested class FBB::Arg::LongOption, see below.

CONSTRUCTORS

Since the class is a Singleton, no public constructors are available. Instead, static members are offered to initialize and access the single FBB::Arg object. See below.

STATIC MEMBERS

OVERLOADED OPERATOR

NON-STATIC MEMBER FUNCTIONS

THE NESTED CLASS FBB::Arg::LongOption

Long options are defined using objects of the nested class FBB::Arg::LongOption. This class offers the following constructors: In a program, long options may be specified as follows:

EXAMPLE

The following example illustrates defining long options and shows an initialization. It is not a full-fledched example in the sense of a small runnable program.

#include <bobcat/arg>

using namespace FBB;

namespace   // the anonymous namespace can be used here
{
    Arg::LongOption longOptions[] = 
    {
        Arg::LongOption{"debug"},
        Arg::LongOption{"filenames", 'f'},
        Arg::LongOption{"help", 'h'},
        Arg::LongOption{"version", 'v'},
    };
    auto longEnd = longOptions + sizeof(longOptions) / sizeof(longOptions[0]);
}

int main(int argc, char **argv)
try
{
    Arg &arg = Arg::initialize("df:hv", 
                    longOptions, longEnd, argc, argv);

    // code using arg, etc.
}
catch(Exception const &err)     // handle exceptions
{
    cerr << err.what() << endl;
    return err.which();
}
catch(int x)
{
    return x;
}
    

FILES

bobcat/arg - defines the class interface

SEE ALSO

bobcat(7)

BUGS

None Reported.

DISTRIBUTION FILES

BOBCAT

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).