diff --git a/README.md b/README.md index 52b27fa..144eeb2 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,8 @@ To error instead, call `p->no_unrecognized()`. - [x] `--` to stop parsing options and flags - [x] modify `argc`/`argv` (disable with `Parser::no_consume()`) - Option/Positional Argument Types - - [x] `int` + - [x] `int32_t` + - [x] `int64_t` - [x] `size_t` - [x] `float` - [x] `double` diff --git a/include/argparse/argparse.hpp b/include/argparse/argparse.hpp index a9e616a..89fcf49 100644 --- a/include/argparse/argparse.hpp +++ b/include/argparse/argparse.hpp @@ -80,7 +80,10 @@ private: void set_val(float *, const std::string &val) { // convert to float *val_ = std::stof(val); } - void set_val(int *, const std::string &val) { // convert to int + void set_val(int32_t *, const std::string &val) { // convert to int32_t + *val_ = std::stoi(val); + } + void set_val(int64_t *, const std::string &val) { // convert to int64_t *val_ = std::stoi(val); } void set_val(std::string *, const std::string &val) { // convert to string @@ -162,7 +165,10 @@ private: void set_val(float *, const std::string &val) { // convert to float *val_ = std::stof(val); } - void set_val(int *, const std::string &val) { // convert to int + void set_val(int32_t *, const std::string &val) { // convert to int32_t + *val_ = std::stoi(val); + } + void set_val(int64_t *, const std::string &val) { // convert to int64_t *val_ = std::stoi(val); } void set_val(std::string *, const std::string &val) { // convert to string @@ -248,8 +254,8 @@ public: // '--' indicates only positional arguments follow // the second '--' should be interpreted as a positional argument if (argv[i] == std::string("--")) { - optsOkay = false; - continue; + optsOkay = false; + continue; } OptionBase *opt = match_opt(argv[i]); if (opt) { diff --git a/test/test_argparse.cpp b/test/test_argparse.cpp index a549bbc..8db1f30 100644 --- a/test/test_argparse.cpp +++ b/test/test_argparse.cpp @@ -36,6 +36,7 @@ TEST_CASE("argparse") { double d; float f; int i; + int64_t i64; std::string s; p.add_flag(campi, "--campi"); p.add_positional(x); @@ -43,6 +44,7 @@ TEST_CASE("argparse") { p.add_positional(f); p.add_positional(s); p.add_positional(i); + p.add_positional(i64); REQUIRE(p.parse(argc, argv)); REQUIRE(campi == true);