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:
Hannah Rittich
2017-08-16 17:55:06 +10:00
committed by jarro2783
parent da9210d41e
commit 2aed1ce41b
3 changed files with 53 additions and 0 deletions
+6
View File
@@ -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)