1/* 2 * Copyright 2014, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * All Rights Reserved. Distributed under the terms of the MIT License. 4 */ 5 6 7#include "CommonOptions.h" 8 9#include <getopt.h> 10#include <stdio.h> 11#include <stdlib.h> 12 13 14CommonOptions::CommonOptions() 15 : 16 fDebugLevel(0) 17{ 18} 19 20 21CommonOptions::~CommonOptions() 22{ 23} 24 25 26bool 27CommonOptions::HandleOption(int option) 28{ 29 switch (option) { 30 case OPTION_DEBUG: 31 { 32 char* end; 33 fDebugLevel = strtol(optarg, &end, 0); 34 if (end == optarg) { 35 fprintf(stderr, 36 "*** invalid argument for option --debug\n"); 37 exit(1); 38 } 39 return true; 40 } 41 42 default: 43 return false; 44 } 45} 46