BCM WL 6.30.102.9 (r366174)
[tomato.git] / release / src-rt / linux / linux-2.6 / scripts / squashfs / lzma / C / Common / CommandLineParser.h
blob75b3589c19afe5317cc606c8d510c07d780d6290
1 // Common/CommandLineParser.h
3 #ifndef __COMMON_COMMANDLINEPARSER_H
4 #define __COMMON_COMMANDLINEPARSER_H
6 #include "Common/String.h"
8 namespace NCommandLineParser {
10 void SplitCommandLine(const UString &src, UString &dest1, UString &dest2);
11 void SplitCommandLine(const UString &s, UStringVector &parts);
13 namespace NSwitchType {
14 enum EEnum
16 kSimple,
17 kPostMinus,
18 kLimitedPostString,
19 kUnLimitedPostString,
20 kPostChar
24 struct CSwitchForm
26 const wchar_t *IDString;
27 NSwitchType::EEnum Type;
28 bool Multi;
29 int MinLen;
30 int MaxLen;
31 const wchar_t *PostCharSet;
34 struct CSwitchResult
36 bool ThereIs;
37 bool WithMinus;
38 UStringVector PostStrings;
39 int PostCharIndex;
40 CSwitchResult(): ThereIs(false) {};
43 class CParser
45 int _numSwitches;
46 CSwitchResult *_switches;
47 bool ParseString(const UString &s, const CSwitchForm *switchForms);
48 public:
49 UStringVector NonSwitchStrings;
50 CParser(int numSwitches);
51 ~CParser();
52 void ParseStrings(const CSwitchForm *switchForms,
53 const UStringVector &commandStrings);
54 const CSwitchResult& operator[](size_t index) const;
57 /////////////////////////////////
58 // Command parsing procedures
60 struct CCommandForm
62 wchar_t *IDString;
63 bool PostStringMode;
66 // Returns: Index of form and postString; -1, if there is no match
67 int ParseCommand(int numCommandForms, const CCommandForm *commandForms,
68 const UString &commandString, UString &postString);
70 struct CCommandSubCharsSet
72 wchar_t *Chars;
73 bool EmptyAllowed;
76 // Returns: indices of finded chars; -1 if there is no match
77 bool ParseSubCharsCommand(int numForms, const CCommandSubCharsSet *forms,
78 const UString &commandString, CIntVector &indices);
82 #endif