00001 /* 00002 * wxChecksums 00003 * Copyright (C) 2003-2004 Julien Couot 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 00020 /** 00021 * \file cmdlnopt.hpp 00022 * Options passed by the command line. 00023 */ 00024 00025 #ifndef INC_CMDLNOPT_HPP 00026 #define INC_CMDLNOPT_HPP 00027 00028 //--------------------------------------------------------------------------- 00029 // For compilers that support precompilation, includes "wx.h". 00030 #include <wx/wxprec.h> 00031 00032 #ifdef __BORLANDC__ 00033 #pragma hdrstop 00034 #endif 00035 00036 #ifndef WX_PRECOMP 00037 // Include your minimal set of headers here, or wx.h 00038 #include <wx/wx.h> 00039 #endif 00040 00041 #include <wx/cmdline.h> 00042 //--------------------------------------------------------------------------- 00043 00044 00045 /** 00046 * Options passed by the command line. 00047 */ 00048 class CmdLineOptions 00049 { 00050 private: 00051 // Don't allow to create an instance out this of this class. 00052 CmdLineOptions(); 00053 00054 public: 00055 // General operations 00056 // Initializes the options. 00057 static bool init(const wxCmdLineParser& parser); 00058 00059 // Cleanup. 00060 static void cleanup(); 00061 // ---------------------------------------------------- 00062 00063 /// Action to do at the startup 00064 enum Actions 00065 { 00066 aNone = 0, 00067 aOpen, 00068 aVerify, 00069 aCreate, 00070 aAppend 00071 }; 00072 00073 /// Type of checksums' files that the application know 00074 enum CkSumsFileTypes 00075 { 00076 cftNone = 0, 00077 cftSFV, 00078 cftMD5 00079 }; 00080 // ---------------------------------------------------- 00081 00082 /// Action to do at the startup of the application. 00083 static Actions action; 00084 00085 /// Type of the checksums' file 00086 static CkSumsFileTypes createType; 00087 00088 /// List of the files given on the command line 00089 static wxArrayString files; 00090 00091 /// Name of the checksums' file to create or where the files will be added. 00092 static wxString checksumsFileName; 00093 00094 private: 00095 /// Delete temporary lists of files 00096 static bool deleteTempLists; 00097 // ---------------------------------------------------- 00098 00099 public: 00100 // Helper operations 00101 // Get the type of the checksums' file to create. 00102 static CkSumsFileTypes getchecksumsFileType(); 00103 // ---------------------------------------------------- 00104 00105 private: 00106 // Specific operations. 00107 // Look if the array of files contains a list of files, load it and delete 00108 // the file that contains the list if the deleteTempLists switch is activated. 00109 static void expandFilesList(const wxCmdLineParser& parser); 00110 00111 // Make all the names of the files in the array of files absolute. 00112 static void makeFilesListAbsolute(const wxString& cwd); 00113 00114 // Checks the compatibility of the verify switch with other options or switchs. 00115 static bool checkVerifySwitch(const wxCmdLineParser& parser); 00116 00117 // Checks the compatibility of the append option with other options or switchs. 00118 static bool checkAppendOption(const wxCmdLineParser& parser); 00119 00120 // Checks the compatibility of the create option with other options or switchs. 00121 static bool checkCreateOption(const wxCmdLineParser& parser); 00122 00123 // Checks the compatibility of the create type option with other options or switchs. 00124 static bool checkCreateTypeOption(const wxCmdLineParser& parser); 00125 00126 // If no action has been set, checks if a checksums' file must be opened. 00127 static bool checkOpenChecksumsFile(const wxCmdLineParser& parser); 00128 }; 00129 //--------------------------------------------------------------------------- 00130 00131 00132 /// Indicates when displaying the GUI. 00133 enum DisplayGUI 00134 { 00135 clgNever = 0, 00136 clgOnError, 00137 clgOnWarning, 00138 clgAlways 00139 }; 00140 00141 00142 #endif // INC_CMDLNOPT_HPP