aboutsummaryrefslogtreecommitdiff
path: root/CPP/Common/CommandLineParser.h
diff options
context:
space:
mode:
authorIgor Pavlov <87184205+ip7z@users.noreply.github.com>2021-12-27 00:00:00 +0000
committerIgor Pavlov <87184205+ip7z@users.noreply.github.com>2022-03-18 15:35:13 +0500
commitf19f813537c7aea1c20749c914e756b54a9c3cf5 (patch)
tree816ba62ca7c0fa19f2eb46d9e9d6f7dd7c3a744d /CPP/Common/CommandLineParser.h
parent98e06a519b63b81986abe76d28887f6984a7732b (diff)
download7zip-21.07.tar.gz
7zip-21.07.tar.bz2
7zip-21.07.zip
'21.07'21.07
Diffstat (limited to 'CPP/Common/CommandLineParser.h')
-rw-r--r--CPP/Common/CommandLineParser.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/CPP/Common/CommandLineParser.h b/CPP/Common/CommandLineParser.h
new file mode 100644
index 0000000..fbd4fa5
--- /dev/null
+++ b/CPP/Common/CommandLineParser.h
@@ -0,0 +1,63 @@
1// Common/CommandLineParser.h
2
3#ifndef __COMMON_COMMAND_LINE_PARSER_H
4#define __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