00001 // This file is part of ff3d - http://www.freefem.org/ff3d 00002 // Copyright (C) 2001, 2002, 2003 Stéphane Del Pino 00003 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 2, or (at your option) 00007 // any later version. 00008 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software Foundation, 00016 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 00018 // $Id: CommandLineParser.hpp,v 1.5 2007/07/25 22:09:31 delpinux Exp $ 00019 00020 #ifndef COMMAND_LINE_PARSER_HPP 00021 #define COMMAND_LINE_PARSER_HPP 00022 00023 #include <string> 00024 #include <vector> 00025 #include <map> 00026 00027 class CommandLineOption; 00028 00038 class CommandLineParser 00039 { 00040 private: 00041 int __numberOfArguments; 00042 char** __arguments; 00044 enum OptionType { 00045 help, 00046 moreHelp, 00047 version, 00048 verbosity, 00049 noPause, 00050 noWindow 00051 }; 00052 00053 typedef std::vector<CommandLineOption*> OptionsList; 00054 OptionsList __options; 00056 typedef std::map<std::string, int> 00057 OptionsLexerType; 00059 OptionsLexerType __shortOptionsLexer; 00060 OptionsLexerType __longOptionsLexer; 00062 int __verbosity; 00064 std::string __filename; 00072 void __treatOption(const int& optionNumber, int& argumentNumber); 00073 00078 void __parse(); 00079 00080 public: 00085 void showHelp() const; 00086 00091 void showMoreHelp() const; 00092 00097 void showVersion() const; 00098 00103 void showUsage() const; 00104 00109 void showBugReport() const; 00110 00116 void showDescription() const; 00121 void showLicence() const; 00122 00127 void showCredits() const; 00128 00134 bool hasFilename() const 00135 { 00136 return (__filename.size() > 0); 00137 } 00138 00144 const std::string& filename() const 00145 { 00146 return __filename; 00147 } 00148 00154 const int& verbosityLevel() const 00155 { 00156 return __verbosity; 00157 } 00158 00165 CommandLineParser(int argc, 00166 char** argv); 00167 00172 ~CommandLineParser(); 00173 }; 00174 00175 #endif // COMMAND_LINE_PARSER_HPP
1.5.6