add int64_t
This commit is contained in:
@@ -156,7 +156,8 @@ To error instead, call `p->no_unrecognized()`.
|
|||||||
- [x] `--` to stop parsing options and flags
|
- [x] `--` to stop parsing options and flags
|
||||||
- [x] modify `argc`/`argv` (disable with `Parser::no_consume()`)
|
- [x] modify `argc`/`argv` (disable with `Parser::no_consume()`)
|
||||||
- Option/Positional Argument Types
|
- Option/Positional Argument Types
|
||||||
- [x] `int`
|
- [x] `int32_t`
|
||||||
|
- [x] `int64_t`
|
||||||
- [x] `size_t`
|
- [x] `size_t`
|
||||||
- [x] `float`
|
- [x] `float`
|
||||||
- [x] `double`
|
- [x] `double`
|
||||||
|
@@ -80,7 +80,10 @@ private:
|
|||||||
void set_val(float *, const std::string &val) { // convert to float
|
void set_val(float *, const std::string &val) { // convert to float
|
||||||
*val_ = std::stof(val);
|
*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);
|
*val_ = std::stoi(val);
|
||||||
}
|
}
|
||||||
void set_val(std::string *, const std::string &val) { // convert to string
|
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
|
void set_val(float *, const std::string &val) { // convert to float
|
||||||
*val_ = std::stof(val);
|
*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);
|
*val_ = std::stoi(val);
|
||||||
}
|
}
|
||||||
void set_val(std::string *, const std::string &val) { // convert to string
|
void set_val(std::string *, const std::string &val) { // convert to string
|
||||||
|
@@ -36,6 +36,7 @@ TEST_CASE("argparse") {
|
|||||||
double d;
|
double d;
|
||||||
float f;
|
float f;
|
||||||
int i;
|
int i;
|
||||||
|
int64_t i64;
|
||||||
std::string s;
|
std::string s;
|
||||||
p.add_flag(campi, "--campi");
|
p.add_flag(campi, "--campi");
|
||||||
p.add_positional(x);
|
p.add_positional(x);
|
||||||
@@ -43,6 +44,7 @@ TEST_CASE("argparse") {
|
|||||||
p.add_positional(f);
|
p.add_positional(f);
|
||||||
p.add_positional(s);
|
p.add_positional(s);
|
||||||
p.add_positional(i);
|
p.add_positional(i);
|
||||||
|
p.add_positional(i64);
|
||||||
REQUIRE(p.parse(argc, argv));
|
REQUIRE(p.parse(argc, argv));
|
||||||
|
|
||||||
REQUIRE(campi == true);
|
REQUIRE(campi == true);
|
||||||
|
Reference in New Issue
Block a user