xref: /third_party/lzma/CPP/Common/CommandLineParser.h (revision 370b324c)
  • Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/lzma/CPP/Common/
1// Common/CommandLineParser.h
2
3#ifndef ZIP7_INC_COMMON_COMMAND_LINE_PARSER_H
4#define ZIP7_INC_COMMON_COMMAND_LINE_PARSER_H
5
6#include "MyString.h"
7
8namespace NCommandLineParser {
9
10bool SplitCommandLine(const UString &src, UString &dest1, UString &dest2);
11void SplitCommandLine(const UString &s, UStringVector &parts);
12
13namespace NSwitchType
14{
15  enum EEnum
16  {
17    kSimple,
18    kMinus,
19    kString,
20    kChar
21  };
22}
23
24struct CSwitchForm
25{
26  const char *Key;
27  Byte Type;
28  bool Multi;
29  Byte MinLen;
30  // int MaxLen;
31  const char *PostCharSet;
32};
33
34struct CSwitchResult
35{
36  bool ThereIs;
37  bool WithMinus;
38  int PostCharIndex;
39  UStringVector PostStrings;
40
41  CSwitchResult(): ThereIs(false) {}
42};
43
44class CParser
45{
46  CSwitchResult *_switches;
47
48  bool ParseString(const UString &s, const CSwitchForm *switchForms, unsigned numSwitches);
49public:
50  UStringVector NonSwitchStrings;
51  int StopSwitchIndex;  // NonSwitchStrings[StopSwitchIndex+] are after "--"
52  AString ErrorMessage;
53  UString ErrorLine;
54
55  CParser();
56  ~CParser();
57  bool ParseStrings(const CSwitchForm *switchForms, unsigned numSwitches, const UStringVector &commandStrings);
58  const CSwitchResult& operator[](unsigned index) const { return _switches[index]; }
59};
60
61}
62
63#endif
64

Indexes created Thu Nov 07 10:32:03 CST 2024