X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=tools%2Fifinfo.cpp;h=e2e522e79972a45268f3d2621e8b9671fd1d0d57;hp=5ef4a7449ea8073d35d56cd4625fbffd4f7cad25;hb=e89023477e02d9332f87cab5a7975407625dbd60;hpb=a35f9818445c3d30109ebf7d68422ca81d02aaf9 diff --git a/tools/ifinfo.cpp b/tools/ifinfo.cpp index 5ef4a74..e2e522e 100644 --- a/tools/ifinfo.cpp +++ b/tools/ifinfo.cpp @@ -7,9 +7,7 @@ ** Date Started: April 2000 ** ** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg -** -** $Id: ifinfo.cpp,v 1.2 2000/08/02 18:09:11 kevin Exp $ +** Copyright (C) 1983-2009 Kevin Rosenberg ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -46,86 +44,88 @@ static struct option my_options[] = {0, 0, 0, 0} }; -static const char* g_szIdStr = "$id$"; +static const char* g_szIdStr = "$Id$"; -void +void ifinfo_usage (const char *program) { - cout << "usage: " << fileBasename(program) << " image-filename [OPTIONS]" << endl; - cout << "Imagefile information" << endl; - cout << endl; - cout << " infile Name of input IF file" << endl; - cout << " --display Display image" << endl; - cout << " --labels Print image labels (default)" << endl; - cout << " --no-labels Do not print image labels" << endl; - cout << " --stats Print image statistics (default)" << endl; - cout << " --no-stats Do not print image statistics" << endl; - cout << " --debug Debug mode" << endl; - cout << " --verbose Verbose mode" << endl; - cout << " --version Print version" << endl; - cout << " --help Print this help message" << endl; + std::cout << "usage: " << fileBasename(program) << " image-filename [OPTIONS]\n"; + std::cout << "Imagefile information\n"; + std::cout << std::endl; + std::cout << " infile Name of input IF file\n"; + std::cout << " --display Display image\n"; + std::cout << " --labels Print image labels (default)\n"; + std::cout << " --no-labels Do not print image labels\n"; + std::cout << " --stats Print image statistics (default)\n"; + std::cout << " --no-stats Do not print image statistics\n"; + std::cout << " --debug Debug mode\n"; + std::cout << " --verbose Verbose mode\n"; + std::cout << " --version Print version\n"; + std::cout << " --help Print this help message\n"; } -int +int ifinfo_main (int argc, char *const argv[]) { ImageFile *im = NULL; - string in_file; + std::string in_file; int opt_verbose = 0; int opt_stats = 1; int opt_labels = 1; int opt_debug = 0; - + UNUSED(opt_verbose); + UNUSED(opt_debug); + while (1) { int c = getopt_long (argc, argv, "", my_options, NULL); - + if (c == -1) - break; - + break; + switch (c) - { - case O_LABELS: - opt_labels = 1; - break; - case O_STATS: - opt_stats = 1; - break; - case O_NO_LABELS: - opt_labels = 0; - break; - case O_NO_STATS: - opt_stats = 0; - break; - case O_VERBOSE: - opt_verbose = 1; - break; - case O_DEBUG: - opt_debug = 0; - break; + { + case O_LABELS: + opt_labels = 1; + break; + case O_STATS: + opt_stats = 1; + break; + case O_NO_LABELS: + opt_labels = 0; + break; + case O_NO_STATS: + opt_stats = 0; + break; + case O_VERBOSE: + opt_verbose = 1; + break; + case O_DEBUG: + opt_debug = 0; + break; case O_VERSION: #ifdef VERSION - cout << "Version " << VERSION << endl; + std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl; #else - cout << "Unknown version number" << endl; + std::cout << "Unknown version number\n"; #endif - return (0); - case O_HELP: - case '?': - ifinfo_usage(argv[0]); - return (0); - default: - ifinfo_usage(argv[0]); - return (1); - } + return (0); + case O_HELP: + case '?': + ifinfo_usage(argv[0]); + return (0); + default: + ifinfo_usage(argv[0]); + return (1); + } } if (optind + 1 != argc) { ifinfo_usage (argv[0]); return (1); } - + in_file = argv[optind]; im = new ImageFile (); @@ -134,19 +134,25 @@ ifinfo_main (int argc, char *const argv[]) return (1); } - if (opt_labels) - im->printLabels (cout); + if (opt_labels) + im->printLabels (std::cout); if (opt_stats) { - cout << "Size: (" << im->nx() << "," << im->ny() << ")" << endl; - im->printStatistics (cout); + std::cout << "Size: (" << im->nx() << "," << im->ny() << ")\n"; + std::cout << "Data type: "; + if (im->dataType() == Array2dFile::DATA_TYPE_COMPLEX) + std::cout << "Complex\n"; + else + std::cout << "Real\n"; + + im->printStatistics (std::cout); } return (0); } #ifndef NO_MAIN -int +int main (int argc, char *const argv[]) { int retval = 1; @@ -154,9 +160,9 @@ main (int argc, char *const argv[]) try { retval = ifinfo_main(argc, argv); } catch (exception e) { - cerr << "Exception: " << e.what() << endl; + std::cerr << "Exception: " << e.what() << std::endl; } catch (...) { - cerr << "Unknown exception" << endl; + std::cerr << "Unknown exception\n"; } return (retval);