Option.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //---------------------------------------------------------------------------
  2. #ifndef OptionH
  3. #define OptionH
  4. #include <vector>
  5. //---------------------------------------------------------------------------
  6. enum TOptionType { otParam, otSwitch };
  7. //---------------------------------------------------------------------------
  8. class TOptions
  9. {
  10. public:
  11. __fastcall TOptions();
  12. bool __fastcall FindSwitch(const UnicodeString Switch);
  13. bool __fastcall FindSwitch(const UnicodeString Switch, UnicodeString & Value);
  14. bool __fastcall FindSwitch(const UnicodeString Switch, int & ParamsStart,
  15. int & ParamsCount);
  16. bool __fastcall FindSwitch(const UnicodeString Switch, TStrings * Params,
  17. int ParamsMax = -1);
  18. void __fastcall ParamsProcessed(int Position, int Count);
  19. UnicodeString __fastcall SwitchValue(const UnicodeString Switch, const UnicodeString Default = L"");
  20. bool __fastcall SwitchValue(const UnicodeString Switch, bool Default);
  21. bool __fastcall SwitchValue(const UnicodeString Switch, bool Default, bool DefaultOnNonExistence);
  22. bool __fastcall UnusedSwitch(UnicodeString & Switch);
  23. __property int ParamCount = { read = FParamCount };
  24. __property UnicodeString Param[int Index] = { read = GetParam };
  25. __property bool Empty = { read = GetEmpty };
  26. protected:
  27. UnicodeString FSwitchMarks;
  28. UnicodeString FSwitchValueDelimiters;
  29. void __fastcall Add(UnicodeString Option);
  30. bool __fastcall FindSwitch(const UnicodeString Switch,
  31. UnicodeString & Value, int & ParamsStart, int & ParamsCount);
  32. private:
  33. struct TOption
  34. {
  35. TOptionType Type;
  36. UnicodeString Name;
  37. UnicodeString Value;
  38. bool Used;
  39. };
  40. std::vector<TOption> FOptions;
  41. bool FNoMoreSwitches;
  42. int FParamCount;
  43. UnicodeString __fastcall GetParam(int Index);
  44. bool __fastcall GetEmpty();
  45. };
  46. //---------------------------------------------------------------------------
  47. #endif