28 | int main(int argc, char** argv) { 29 | ArgumentList args(argc, argv); 30 | bool verbose = args.getSwitch("-v"); 31 | // get all other switches 32 | QString outputfile = args.getSwitchArg("-o", "default.out"); 33 | qout << args[0]; // prints the name of the executable 34 | qout << args[1]; // prints the first unswitched argument 35 | someObject.processEveryFile(args); 36 | } 37 |38 | 39 | @author S. Alan Ezust sae@mcs.suffolk.edu 40 | @since qt 3.2.1 41 | 42 | */ 43 | 44 | class ArgumentList : public QStringList { 45 | public: 46 | /** 47 | retrieve argument list from the qApp->argc() and argv() methods. 48 | Only works if a @ref QApplication(argc, argv) was already created. 49 | */ 50 | ArgumentList(); 51 | 52 | /** 53 | @param argc number of arguments 54 | @param argv an array of command line arguments, as supplied 55 | to main(). 56 | @see argsToStringList() 57 | */ 58 | 59 | ArgumentList(int argc, char* argv[]) { 60 | argsToStringlist(argc, argv); 61 | } 62 | 63 | ArgumentList(const QStringList& argumentList): 64 | QStringList(argumentList) {} 65 | 66 | 67 | /** 68 | finds and removes a switch from the string list, if it exists. 69 | @param option the switch to search for 70 | @return true if the switch was found 71 | */ 72 | bool getSwitch(QString option); 73 | 74 | /** 75 | finds/removes a switch and its accompanying argument 76 | from the string list, if the switch is found. Does nothing if the 77 | switch is not found. 78 | @param option the switch to search for 79 | @param defaultReturnValue the return value if option is not found in the stringlist 80 | @return the argument following option, or defaultValue if the option 81 | is not found. 82 | */ 83 | QString getSwitchArg(QString option, 84 | QString defaultRetVal=QString()); 85 | private: 86 | /** 87 | (Re)loads argument lists into this object. This function is private because 88 | it is part of the implementation of the class and not intended to be used by 89 | client code. 90 | */ 91 | void argsToStringlist(int argc, char* argv[]); 92 | }; 93 | #endif 94 | -------------------------------------------------------------------------------- /src/constants.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSTANTS_H 2 | #define CONSTANTS_H 3 | 4 | #include
") + tr("A Qt5-based pkgng front-end,") + " " + 61 | tr("licensed under the terms of") + " "; 62 | 63 | html += 64 | QString("LGPL v2.1.
") + 65 | QString("") + strForMoreInfo + " " + 66 | QString("https://tintaescura.com/projects/octopkg.