advgetopt: Main Page

advgetopt  2.0.1
Parse complex command line arguments and configuration files in C++.
advgetopt Documentation

The advanced getopt library to handle your command line tools seemlessly.

The library offers an advanced way to parse command line arguments, an environment variable, and configuration files in a seamless manner. The advgetopt::getopt class is what is used everywhere for that purpose.

The class can be used in a very restrictive mode, meaning that all the parameters must clearly be defined by the application. It can also be used in a dynamic way where the parameters are dynamically added to the list of available options.

The library supports multiple levels in your options. The simplest is to use a scope operator like so:

level1::level2::level3::etc = 123
Note
The library understands the scope operator (::), the period (.), and the slash (/) as level separator. So the following are equivalent. Internally, all are changed to the scope operator (::).
level1::level2::level3::etc = 123
level1.level2.level3.etc = 123
level1/level2/level3/etc = 123

The labels in a .ini format (i.e. [name] defines sections) are viewed as a first level. That name automatically get prepended to the parameters appearing under them. Additional levels can be added by using the scope operator, again.

[level1]
level2::level3::etc = 123

Support for other formats may be added later. For example, we could read XML and JSON files. Right now, we are focused on Unix configuration files and pretty much never even need two levels.

The library is capable of writing your configuration back to file. It will know when a value was modified and only the modified values get saved to the read/write configuration file(s). (Either the user file or the system file under the \<proc>.d/... sub-path.)

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.

Syndicate content

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly