Annotation of elwix/tools/oldlzma/SRC/Common/CommandLineParser.h, revision 1.1

1.1     ! misho       1: // Common/CommandLineParser.h
        !             2: 
        !             3: #ifndef __COMMON_COMMANDLINEPARSER_H
        !             4: #define __COMMON_COMMANDLINEPARSER_H
        !             5: 
        !             6: #include "Common/String.h"
        !             7: 
        !             8: namespace NCommandLineParser {
        !             9: 
        !            10: void SplitCommandLine(const UString &src, UString &dest1, UString &dest2);
        !            11: void SplitCommandLine(const UString &s, UStringVector &parts);
        !            12: 
        !            13: namespace NSwitchType {
        !            14:   enum EEnum
        !            15:   { 
        !            16:     kSimple,
        !            17:     kPostMinus,
        !            18:     kLimitedPostString,
        !            19:     kUnLimitedPostString,
        !            20:     kPostChar
        !            21:   };
        !            22: }
        !            23: 
        !            24: struct CSwitchForm
        !            25: {
        !            26:   const wchar_t *IDString;
        !            27:   NSwitchType::EEnum Type;
        !            28:   bool Multi;
        !            29:   int MinLen;
        !            30:   int MaxLen;
        !            31:   const wchar_t *PostCharSet;
        !            32: };
        !            33: 
        !            34: struct CSwitchResult
        !            35: {
        !            36:   bool ThereIs;
        !            37:   bool WithMinus;
        !            38:   UStringVector PostStrings;
        !            39:   int PostCharIndex;
        !            40:   CSwitchResult(): ThereIs(false) {};
        !            41: };
        !            42:   
        !            43: class CParser
        !            44: {
        !            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;
        !            55: };
        !            56: 
        !            57: /////////////////////////////////
        !            58: // Command parsing procedures
        !            59: 
        !            60: struct CCommandForm
        !            61: {
        !            62:   wchar_t *IDString;
        !            63:   bool PostStringMode;
        !            64: };
        !            65: 
        !            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);
        !            69: 
        !            70: struct CCommandSubCharsSet
        !            71: {
        !            72:   wchar_t *Chars;
        !            73:   bool EmptyAllowed;
        !            74: };
        !            75: 
        !            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);
        !            79: 
        !            80: }
        !            81: 
        !            82: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>