From f94eb9045fadb589c1f394def89dff3653b596b3 Mon Sep 17 00:00:00 2001 From: Davis King Date: Sat, 11 Feb 2012 13:15:17 -0500 Subject: [PATCH] Simplified code a little --- examples/compress_stream_ex.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/examples/compress_stream_ex.cpp b/examples/compress_stream_ex.cpp index 0f6059a1a..a8bbb9980 100644 --- a/examples/compress_stream_ex.cpp +++ b/examples/compress_stream_ex.cpp @@ -109,21 +109,13 @@ int main(int argc, char** argv) return 0; } - // Make some references to the options inside the parser. This is just - // for convenience so we don't have to type out the longer form below. - const clp::option_type& option_c = parser.option("c"); - const clp::option_type& option_d = parser.option("d"); - const clp::option_type& option_in = parser.option("in"); - const clp::option_type& option_out = parser.option("out"); - // Figure out what the compression level should be. If the user didn't supply // this command line option then a value of 2 will be used. int compression_level = get_option(parser,"l",2); - // make sure one of the c or d options was given - if (!option_c && !option_d) + if (!parser.option("c") && !parser.option("d")) { cout << "Error in command line:\n You must specify either the c option or the d option.\n"; cout << "\nTry the -h option for more information." << endl; @@ -136,9 +128,9 @@ int main(int argc, char** argv) // check if the user told us the input file and if they did then // get the file name - if (option_in) + if (parser.option("in")) { - in_file = option_in.argument(); + in_file = parser.option("in").argument(); } else { @@ -150,9 +142,9 @@ int main(int argc, char** argv) // check if the user told us the output file and if they did then // get the file name - if (option_out) + if (parser.option("out")) { - out_file = option_out.argument(); + out_file = parser.option("out").argument(); } else { @@ -182,7 +174,7 @@ int main(int argc, char** argv) // now perform the actual compression or decompression. - if (option_c) + if (parser.option("c")) { // save the compression level to the output file serialize(compression_level, fout);