Last active
September 9, 2016 10:56
-
-
Save matt-42/f3502830f96b6b6ce5a36440c8bceb7b to your computer and use it in GitHub Desktop.
Prototype of the iod option parser
This file contains 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
#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