apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

cmndline.h
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4 
5  Command Line Class - Sophisticated command line parser
6 
7  This class provides a unified command line parser/option handliner/
8  configuration mechanism. It allows the caller to specify the option
9  set and map the option set into the configuration class or other
10  special functioning.
11 
12  Filenames are stripped from the option stream and put into their
13  own array.
14 
15  The argument descriptor array can be initialized as:
16 
17  CommandLine::Args Args[] =
18  {{'q',"quiet","apt::get::quiet",CommandLine::IntLevel},
19  {0,0,0,0}};
20 
21  The flags mean,
22  HasArg - Means the argument has a value
23  IntLevel - Means the argument is an integer level indication, the
24  following -qqqq (+3) -q5 (=5) -q=5 (=5) are valid
25  Boolean - Means it is true/false or yes/no.
26  -d (true) --no-d (false) --yes-d (true)
27  --long (true) --no-long (false) --yes-long (true)
28  -d=yes (true) -d=no (false) Words like enable, disable,
29  true false, yes no and on off are recognized in logical
30  places.
31  InvBoolean - Same as boolean but the case with no specified sense
32  (first case) is set to false.
33  ConfigFile - Means this flag should be interprited as the name of
34  a config file to read in at this point in option processing.
35  Implies HasArg.
36  ArbItem - Means the item is an arbitrary configuration string of
37  the form item=value, where item is passed directly
38  to the configuration class.
39  The default, if the flags are 0 is to use Boolean
40 
41  ##################################################################### */
42  /*}}}*/
43 #ifndef PKGLIB_CMNDLINE_H
44 #define PKGLIB_CMNDLINE_H
45 
46 #include <apt-pkg/macros.h>
47 
48 
49 class Configuration;
50 
52 {
53  public:
54  struct Args;
55  struct Dispatch;
56  struct DispatchWithHelp;
57 
58  protected:
59 
62  bool HandleOpt(int &I,int argc,const char *argv[],
63  const char *&Opt,Args *A,bool PreceedeMatch = false);
64  void static SaveInConfig(unsigned int const &argc, char const * const * const argv);
65 
66  public:
67 
68  enum AFlags
69  {
70  HasArg = (1 << 0),
71  IntLevel = (1 << 1),
72  Boolean = (1 << 2),
73  InvBoolean = (1 << 3),
74  ConfigFile = (1 << 4) | HasArg,
75  ArbItem = (1 << 5) | HasArg
76  };
77 
78  const char **FileList;
79 
80  bool Parse(int argc,const char **argv);
81  void ShowHelp();
82  unsigned int FileSize() const APT_PURE;
83  bool DispatchArg(Dispatch const * const List,bool NoMatch = true);
84 
85  static char const * GetCommand(Dispatch const * const Map,
86  unsigned int const argc, char const * const * const argv) APT_PURE;
87 
88  static CommandLine::Args MakeArgs(char ShortOpt, char const *LongOpt,
89  char const *ConfName, unsigned long Flags) APT_PURE;
90 
91  CommandLine();
92  CommandLine(Args *AList,Configuration *Conf);
93  ~CommandLine();
94 };
95 
97 {
98  char ShortOpt;
99  const char *LongOpt;
100  const char *ConfName;
101  unsigned long Flags;
102 
103  inline bool end() {return ShortOpt == 0 && LongOpt == 0;};
104  inline bool IsBoolean() {return Flags == 0 || (Flags & (Boolean|InvBoolean)) != 0;};
105 };
106 
108 {
109  const char *Match;
110  bool (*Handler)(CommandLine &);
111 };
112 
113 #endif
static bool std::string const metaIndex const *const pkgAcqMetaClearSig *const pkgAcquire::Item *const I
const char ** FileList
Definition: cmndline.h:78
Args * ArgList
Definition: cmndline.h:56
Configuration * Conf
Definition: cmndline.h:61
void ShowHelp()
#define APT_PURE
Definition: macros.h:56
#define APT_PUBLIC
Definition: macros.h:77
unsigned long Flags
Definition: cmndline.h:101
bool IsBoolean()
Definition: cmndline.h:104
const char * LongOpt
Definition: cmndline.h:99
const char * ConfName
Definition: cmndline.h:100
const char * Match
Definition: cmndline.h:109