X-Git-Url: http://git.maemo.org/git/?p=physicsfs;a=blobdiff_plain;f=lzma%2FCPP%2FCommon%2FCommandLineParser.h;fp=lzma%2FCPP%2FCommon%2FCommandLineParser.h;h=a97f58a527b00af6dacd9e0ec6a7af027dd6d406;hp=0000000000000000000000000000000000000000;hb=1a2e54b98aaab3669eebd38facb83687c4ac7baf;hpb=0b9bdac28929054558b5d7f315403fe3399a1413 diff --git a/lzma/CPP/Common/CommandLineParser.h b/lzma/CPP/Common/CommandLineParser.h new file mode 100644 index 0000000..a97f58a --- /dev/null +++ b/lzma/CPP/Common/CommandLineParser.h @@ -0,0 +1,72 @@ +// Common/CommandLineParser.h + +#ifndef __COMMON_COMMANDLINEPARSER_H +#define __COMMON_COMMANDLINEPARSER_H + +#include "MyString.h" + +namespace NCommandLineParser { + +void SplitCommandLine(const UString &src, UString &dest1, UString &dest2); +void SplitCommandLine(const UString &s, UStringVector &parts); + +namespace NSwitchType { + enum EEnum + { + kSimple, + kPostMinus, + kLimitedPostString, + kUnLimitedPostString, + kPostChar + }; +} + +struct CSwitchForm +{ + const wchar_t *IDString; + NSwitchType::EEnum Type; + bool Multi; + int MinLen; + int MaxLen; + const wchar_t *PostCharSet; +}; + +struct CSwitchResult +{ + bool ThereIs; + bool WithMinus; + UStringVector PostStrings; + int PostCharIndex; + CSwitchResult(): ThereIs(false) {}; +}; + +class CParser +{ + int _numSwitches; + CSwitchResult *_switches; + bool ParseString(const UString &s, const CSwitchForm *switchForms); +public: + UStringVector NonSwitchStrings; + CParser(int numSwitches); + ~CParser(); + void ParseStrings(const CSwitchForm *switchForms, + const UStringVector &commandStrings); + const CSwitchResult& operator[](size_t index) const; +}; + +///////////////////////////////// +// Command parsing procedures + +struct CCommandForm +{ + wchar_t *IDString; + bool PostStringMode; +}; + +// Returns: Index of form and postString; -1, if there is no match +int ParseCommand(int numCommandForms, const CCommandForm *commandForms, + const UString &commandString, UString &postString); + +} + +#endif