]> git.tdb.fi Git - libs/core.git/blobdiff - examples/z.cpp
Add move semantics to Variant
[libs/core.git] / examples / z.cpp
index 54f0eb7d336249c010ccb5911103f8bb88b7ee4a..5f793c40cbdf08b68ac0316857ff8718856683da 100644 (file)
@@ -24,15 +24,16 @@ public:
 };
 
 Z::Z(int argc, char **argv):
-       input_file(0)
+       input_file(nullptr)
 {
+       string input_fn;
        GetOpt getopt;
        getopt.add_option('d', "decompress", decompress, GetOpt::NO_ARG);
+       getopt.add_argument("filename", input_fn, GetOpt::OPTIONAL_ARG);
        getopt(argc, argv);
 
-       const vector<string> &args = getopt.get_args();
-       if(!args.empty())
-               input_file = new IO::File(args[0]);
+       if(!input_fn.empty())
+               input_file = new IO::File(input_fn);
 
        input = (input_file ? static_cast<IO::Base *>(input_file) : static_cast<IO::Base *>(&IO::cin));
        output = &IO::cout;