Created
September 15, 2012 17:02
-
-
Save philtomson/3728841 to your computer and use it in GitHub Desktop.
Using boost::program_options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//To compile: | |
//g++ -I /usr/include/boost -o op_parser op_parser.cpp /usr/lib64/libboost_program_options-mt.a | |
#include <iostream> | |
#include "boost/program_options.hpp" | |
namespace po = boost::program_options; | |
using namespace std; | |
int main(int argc, char** argv){ | |
string list_file; | |
string verilog_file; | |
po::options_description desc("Allowed options"); | |
desc.add_options() | |
("help", "produce help message") | |
("list_file", po::value<string>(), "list file to read") | |
("v", po::value<string>(), "single verilog file") | |
; | |
po::variables_map vm; | |
po::store(po::parse_command_line(argc, argv, desc), vm); | |
po::notify(vm); | |
if(vm.count("help")) { | |
cout << desc << "\n"; | |
return 1; | |
} | |
if(vm.count("list_file")) { | |
list_file = vm["list_file"].as<string>(); | |
cout << "list file is: " << list_file << ".\n"; | |
} else { | |
cout << "list_file was not set.\n"; | |
} | |
if(vm.count("v")){ | |
verilog_file = vm["v"].as<string>(); | |
cout << "verilog file is: " << verilog_file << ".\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment