mirror of
https://github.com/jarro2783/cxxopts.git
synced 2026-08-22 14:18:02 +02:00
Added parsing of general types. (#63)
Adds generic parsing of types using `operator>>`, in particular allows parsing of floats and doubles.
This commit is contained in:
committed by
jarro2783
parent
da9210d41e
commit
2aed1ce41b
@@ -49,6 +49,7 @@ int main(int argc, char* argv[])
|
||||
"thisisareallylongwordthattakesupthewholelineandcannotbebrokenataspace")
|
||||
("help", "Print help")
|
||||
("int", "An integer", cxxopts::value<int>(), "N")
|
||||
("float", "A floating point number", cxxopts::value<float>())
|
||||
("option_that_is_too_long_for_the_help", "A very long option")
|
||||
#ifdef CXXOPTS_USE_UNICODE
|
||||
("unicode", u8"A help option with non-ascii: à. Here the size of the"
|
||||
@@ -118,6 +119,11 @@ int main(int argc, char* argv[])
|
||||
std::cout << "int = " << options["int"].as<int>() << std::endl;
|
||||
}
|
||||
|
||||
if (options.count("float"))
|
||||
{
|
||||
std::cout << "float = " << options["float"].as<float>() << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "Arguments remain = " << argc << std::endl;
|
||||
|
||||
} catch (const cxxopts::OptionException& e)
|
||||
|
||||
Reference in New Issue
Block a user