123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- #ifndef cmCommandArgumentsHelper_h
- #define cmCommandArgumentsHelper_h
- #include "cmConfigure.h"
- #include <set>
- #include <string>
- #include <vector>
- class cmCommandArgumentGroup;
- class cmCommandArgumentsHelper;
- class cmCommandArgument
- {
- public:
- cmCommandArgument(cmCommandArgumentsHelper* args, const char* key,
- cmCommandArgumentGroup* group = nullptr);
- virtual ~cmCommandArgument() {}
-
- void Follows(const cmCommandArgument* arg);
-
- void FollowsGroup(const cmCommandArgumentGroup* group);
-
- bool WasFound() const { return this->WasActive; }
-
-
-
-
- void Activate();
-
- bool Consume(const std::string& arg);
-
- bool MayFollow(const cmCommandArgument* current) const;
-
- bool KeyMatches(const std::string& key) const;
-
- void ApplyOwnGroup();
-
- void Reset();
- private:
- const char* Key;
- std::set<const cmCommandArgument*> ArgumentsBefore;
- cmCommandArgumentGroup* Group;
- bool WasActive;
- bool ArgumentsBeforeEmpty;
- unsigned int CurrentIndex;
- virtual bool DoConsume(const std::string& arg, unsigned int index) = 0;
- virtual void DoReset() = 0;
- };
- class cmCAStringVector : public cmCommandArgument
- {
- public:
- cmCAStringVector(cmCommandArgumentsHelper* args, const char* key,
- cmCommandArgumentGroup* group = nullptr);
-
- const std::vector<std::string>& GetVector() const { return this->Vector; }
-
- void SetIgnore(const char* ignore) { this->Ignore = ignore; }
- private:
- std::vector<std::string> Vector;
- unsigned int DataStart;
- const char* Ignore;
- cmCAStringVector();
- bool DoConsume(const std::string& arg, unsigned int index) override;
- void DoReset() override;
- };
- class cmCAString : public cmCommandArgument
- {
- public:
- cmCAString(cmCommandArgumentsHelper* args, const char* key,
- cmCommandArgumentGroup* group = nullptr);
-
- const std::string& GetString() const { return this->String; }
- const char* GetCString() const { return this->String.c_str(); }
- private:
- std::string String;
- unsigned int DataStart;
- bool DoConsume(const std::string& arg, unsigned int index) override;
- void DoReset() override;
- cmCAString();
- };
- class cmCAEnabler : public cmCommandArgument
- {
- public:
- cmCAEnabler(cmCommandArgumentsHelper* args, const char* key,
- cmCommandArgumentGroup* group = nullptr);
-
- bool IsEnabled() const { return this->Enabled; }
- private:
- bool Enabled;
- bool DoConsume(const std::string& arg, unsigned int index) override;
- void DoReset() override;
- cmCAEnabler();
- };
- class cmCADisabler : public cmCommandArgument
- {
- public:
- cmCADisabler(cmCommandArgumentsHelper* args, const char* key,
- cmCommandArgumentGroup* group = nullptr);
-
- bool IsEnabled() const { return this->Enabled; }
- private:
- bool Enabled;
- bool DoConsume(const std::string& arg, unsigned int index) override;
- void DoReset() override;
- cmCADisabler();
- };
- class cmCommandArgumentGroup
- {
- friend class cmCommandArgument;
- public:
- cmCommandArgumentGroup() {}
-
- void Follows(const cmCommandArgument* arg);
-
- void FollowsGroup(const cmCommandArgumentGroup* group);
- private:
- std::vector<cmCommandArgument*> ContainedArguments;
- };
- class cmCommandArgumentsHelper
- {
- public:
-
- void Parse(const std::vector<std::string>* args,
- std::vector<std::string>* unconsumedArgs);
-
- void AddArgument(cmCommandArgument* arg);
- private:
- std::vector<cmCommandArgument*> Arguments;
- };
- #endif
|