CPS 108: Getopt


You are to implement implement a wrapper around the old C library function getopt as a  C++-module that provides the same functionality, but with a spiffier object-oriented interface.  In other words, you should provide a set of classes that allows users access to standard UNIX-style command-line arguments and UNIX environment variables.

Specification

The C-library function getopt is described in the Solaris man page (or type man -s 3c getopt).

You must design and implement classes whose use is similar to the getopt function from a user's perspective, but for a user versed in C++ rather than C. This means that you should use STL vectors instead of C-style arrays, strings instead of C-style strings (0 terminated character arrays), etc. You may implement several classes as part of the implementation of the main class whose interface the user sees as providing equivalent (or better) functionality than getopt.  Additionally, you must also allow a user of your library to specify environment variables from which a program can get additional default values.  Access to these values should be similar to those for values entered on the command-line.

You must supply online HTML documentation (like man pages) that describes how to use your classes and shows some example code.

Example Code

These files are accessible on the acpub system in ~rcduvall/cps108/code/getopt The following are some examples of C++ command-line class interfaces:

Implementation

You must supply a const iterator that provide access to the values that are entered when the program is started. You can supply these iterators using makeIterator functions or you can use getopt class typedefs as is done with STL. Additionally, you should provide a class Properties that allows users to query for which properties where set and their values. You may use the documentation of the Java implementation to guide you.

You must supply static or shared/dynamic libraries for your getopt classes so that users can include your header file, link the library, and use your classes. You must supply a Makefile that will compile either libgetopt.a or libgetopt.so (static or shared libraries, respectively). Information on creating libraries is here.


Comments?