From 025d4bf37b32e2295556e4498db82af4ff69f715 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 30 May 2015 20:30:14 -0500 Subject: [PATCH] added documentation to arguments.h --- .gitignore | 4 ++-- .gitmodules | 3 --- stim/parser/arguments.h | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 81 insertions(+), 11 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitignore b/.gitignore index 2920afa..d26bcc9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -html/* -latex/* \ No newline at end of file +stim/html/* +stim/latex/* \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c41e968..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "stim"] - path = stim - url = https://github.com/dmayerich/stim.git diff --git a/stim/parser/arguments.h b/stim/parser/arguments.h index 576ae33..0898835 100644 --- a/stim/parser/arguments.h +++ b/stim/parser/arguments.h @@ -237,6 +237,48 @@ namespace stim{ unsigned int index; }; + /**The arglist class implements command line arguments. + Example: + + 1) Create an arglist instance: + + stim::arglist args; + + 2) Test to see if ANSI output is supported (arguments will use color if it is). Generally, Windows consoles don't support ANSI. + + #ifdef _WIN32 + args.set_ansi(false); + #endif + + 3) Add arguments: + + args.add("help", "prints this help"); + args.add("foo", "foo takes a single integer value", "", "[intval]"); + args.add("bar", "bar takes two floating point values", "", "[value1], [value2]"); + + 4) You generally want to immediately test for help and output available arguments: + + if(args["help"].is_set()) + std::cout<(col_width, opt.col_width()); } + ///Specifies a section name that can be used to organize parameters in the output. + + /// @param _name is the name of the section, which will be displayed to the user void section(std::string _name) { argsection s; @@ -283,7 +337,7 @@ namespace stim{ sections.push_back(s); } - //output the options (generally in response to --help) + ///Outputs supported arguments. If ANSI support is available, they will be color-coded. Generally this is called in response to "--help" std::string str() { std::stringstream ss; @@ -312,6 +366,9 @@ namespace stim{ return ss.str(); } + ///Retrieves the index for a supported argument, given that argument's name. + + /// @param _name is the name of the requested argument int index(std::string _name) { unsigned int i = find(opts.begin(), opts.end(), _name) - opts.begin(); @@ -322,6 +379,10 @@ namespace stim{ return (int)i; } + ///Sets an argument to a specified value + + /// @param _name is the name of the argument to be set + /// @param _value is the value that it is given void set(std::string _name, std::string _value) { int i = index(_name); @@ -336,7 +397,10 @@ namespace stim{ std::cout<<"ERROR - option not recognized: "<<_name<