00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef PKGLIB_CMNDLINE_H
00045 #define PKGLIB_CMNDLINE_H
00046
00047
00048
00049 #include <apt-pkg/configuration.h>
00050
00051 class CommandLine
00052 {
00053 public:
00054 struct Args;
00055 struct Dispatch;
00056
00057 protected:
00058
00059 Args *ArgList;
00060 Configuration *Conf;
00061 bool HandleOpt(int &I,int argc,const char *argv[],
00062 const char *&Opt,Args *A,bool PreceedeMatch = false);
00063 void static SaveInConfig(unsigned int const &argc, char const * const * const argv);
00064
00065 public:
00066
00067 enum AFlags
00068 {
00069 HasArg = (1 << 0),
00070 IntLevel = (1 << 1),
00071 Boolean = (1 << 2),
00072 InvBoolean = (1 << 3),
00073 ConfigFile = (1 << 4) | HasArg,
00074 ArbItem = (1 << 5) | HasArg
00075 };
00076
00077 const char **FileList;
00078
00079 bool Parse(int argc,const char **argv);
00080 void ShowHelp();
00081 unsigned int FileSize() const;
00082 bool DispatchArg(Dispatch *List,bool NoMatch = true);
00083
00084 CommandLine(Args *AList,Configuration *Conf);
00085 ~CommandLine();
00086 };
00087
00088 struct CommandLine::Args
00089 {
00090 char ShortOpt;
00091 const char *LongOpt;
00092 const char *ConfName;
00093 unsigned long Flags;
00094
00095 inline bool end() {return ShortOpt == 0 && LongOpt == 0;};
00096 inline bool IsBoolean() {return Flags == 0 || (Flags & (Boolean|InvBoolean)) != 0;};
00097 };
00098
00099 struct CommandLine::Dispatch
00100 {
00101 const char *Match;
00102 bool (*Handler)(CommandLine &);
00103 };
00104
00105 #endif