other-licenses/7zstub/src/Common/CommandLineParser.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/other-licenses/7zstub/src/Common/CommandLineParser.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +// Common/CommandLineParser.h
     1.5 +
     1.6 +#ifndef __COMMON_COMMANDLINEPARSER_H
     1.7 +#define __COMMON_COMMANDLINEPARSER_H
     1.8 +
     1.9 +#include "Common/String.h"
    1.10 +
    1.11 +namespace NCommandLineParser {
    1.12 +
    1.13 +void SplitCommandLine(const UString &src, UString &dest1, UString &dest2);
    1.14 +void SplitCommandLine(const UString &s, UStringVector &parts);
    1.15 +
    1.16 +namespace NSwitchType {
    1.17 +  enum EEnum
    1.18 +  { 
    1.19 +    kSimple,
    1.20 +    kPostMinus,
    1.21 +    kLimitedPostString,
    1.22 +    kUnLimitedPostString,
    1.23 +    kPostChar
    1.24 +  };
    1.25 +}
    1.26 +
    1.27 +struct CSwitchForm
    1.28 +{
    1.29 +  const wchar_t *IDString;
    1.30 +  NSwitchType::EEnum Type;
    1.31 +  bool Multi;
    1.32 +  int MinLen;
    1.33 +  int MaxLen;
    1.34 +  const wchar_t *PostCharSet;
    1.35 +};
    1.36 +
    1.37 +struct CSwitchResult
    1.38 +{
    1.39 +  bool ThereIs;
    1.40 +  bool WithMinus;
    1.41 +  UStringVector PostStrings;
    1.42 +  int PostCharIndex;
    1.43 +  CSwitchResult(): ThereIs(false) {};
    1.44 +};
    1.45 +  
    1.46 +class CParser
    1.47 +{
    1.48 +  int _numSwitches;
    1.49 +  CSwitchResult *_switches;
    1.50 +  bool ParseString(const UString &s, const CSwitchForm *switchForms); 
    1.51 +public:
    1.52 +  UStringVector NonSwitchStrings;
    1.53 +  CParser(int numSwitches);
    1.54 +  ~CParser();
    1.55 +  void ParseStrings(const CSwitchForm *switchForms, 
    1.56 +    const UStringVector &commandStrings);
    1.57 +  const CSwitchResult& operator[](size_t index) const;
    1.58 +};
    1.59 +
    1.60 +/////////////////////////////////
    1.61 +// Command parsing procedures
    1.62 +
    1.63 +struct CCommandForm
    1.64 +{
    1.65 +  wchar_t *IDString;
    1.66 +  bool PostStringMode;
    1.67 +};
    1.68 +
    1.69 +// Returns: Index of form and postString; -1, if there is no match
    1.70 +int ParseCommand(int numCommandForms, const CCommandForm *commandForms, 
    1.71 +    const UString &commandString, UString &postString);
    1.72 +
    1.73 +}
    1.74 +
    1.75 +#endif

mercurial