Skip to content
Steven Raasch edited this page Sep 15, 2015 · 2 revisions

This is yet another C++ version of the getopt function, that is, for parsing command line options and environment variables. However, unlike other versions, the design goals of this one are:

  • EASY to use
  • EASY to learn
  • mimic STL's streams
  • minimum code to type
  • smooth integration with STL types
  • Platform independant (ANSI C++)
  • EASY to extend for your own types

That is, you just construct a GetOpt_pp object with argc and argv, and then extract the options with the >> operator as an istream :)

Example: We want to receive two options, one for an int (say, named -i and --test1), and another for a float (named -f and without long option). Results in test1 and test2 vars.

int main(int argc, char* argv[])
{
        using namespace GetOpt;
	int test1 = 10;
	float test2 = 3.14f;
		
	GetOpt_pp ops(argc, argv);
	
	ops >> Option('i', "test1", test1) >> Option('f', test2); 
	
	std::cout << test1 << "\n" << test2 << "\n";
	return 0;
}

See the project's Wiki for documentation.

Current version: 2.18

NEWS

GetOpt_pp is now distributed with Boost 1.0 license, turning it suitable for some commercial projects and still remaining free software.

Donations

GetOpt_pp is maintained at FuDePAN, an NGO/NPO for bioinformatics research. If you find GetOpt_pp useful, please consider to donate so we can keep up the research and maintenance.

Coming in GetOpt_pp 3.0: environment stream for inserting and extracting env vars!

Don't miss GetOpt_pp Episode 3!

This project belongs to FuDePAN.


<wiki:gadget url="http://www.revolvermaps.com/gadget/rm2\_gadget.xml" height="180" width="180" >

Clone this wiki locally