+ int opt;
+ while ((opt = getopt(argc, argv, "n:h")) != -1) {
+ switch (opt) {
+ case 'n':
+ ann = optarg;
+ break;
+ case 'h':
+ cout << "Usage: " << argv[0] << " [OPTION] [FILE]" << endl
+ << endl << " -n <ann> Specifies which artificial neural network to use for identification. '" << ann << "' is used by default"
+ << endl << " -h Prints this help message"
+ << endl << endl
+ << "With no FILE, or if FILE is '-', stdin will be used"
+ << endl;
+ exit(EXIT_SUCCESS);
+ break;
+ default: /* '?' */
+ cerr << "Usage: " << argv[0] << " [-n <ann>] [-h] [FILE]" << endl;
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ istream* in;
+ ifstream file;
+ if (optind == argc || *argv[optind] == '-'){
+ in = &cin;
+ }else{
+ file.open(argv[optind]);
+ if (file.fail()){
+ cerr << "Could not open file: '" << argv[optind] << "'" << endl;
+ exit(EXIT_FAILURE);
+ }
+ in = &file;
+ }