Skip to content

Instantly share code, notes, and snippets.

@matt-42
Last active September 9, 2016 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matt-42/f3502830f96b6b6ce5a36440c8bceb7b to your computer and use it in GitHub Desktop.
Save matt-42/f3502830f96b6b6ce5a36440c8bceb7b to your computer and use it in GitHub Desktop.
Prototype of the iod option parser
#include "iod/parse_options.hh"
#include "symbols.hh"
using namespace s;
int main(int argc, char* argv[])
{
auto options = iod::parse_options(argc, argv,
_size | _s = int(20),
_elts | _e = std::vector<int>(),
_opt | _o = optional(int(3))
);
std::cout << options.size << " " << options.opt << " " << options.elts.size() << std::endl;
// Fill global variables
auto options = iod::parse_options(argc, argv,
_size | _s = &a_int_var,
_elts | _e = &a_vector,
_opt | _o = &another_var
);
// Positional arguments
auto options = iod::parse_options(argc, argv,
_size | _s = int(20),
_elts | _e = std::vector<int>(),
_opt | _o = optional(int(3)),
[ _size, _opt ]
);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment