⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commandoption.hpp

📁 gps源代码
💻 HPP
📖 第 1 页 / 共 2 页
字号:
   protected:         /// Default Constructor      CommandOptionWithArg() {}   };      /// A CommandOption that requires a string argument.   class CommandOptionWithAnyArg : public CommandOptionWithArg   {   public:         /// Constructor      CommandOptionWithAnyArg(const char shOpt,                               const std::string& loOpt,                               const std::string& desc,                              const bool required = false)            : CommandOptionWithArg(stdType, shOpt, loOpt, desc, required)         {}         /// Destructor      virtual ~CommandOptionWithAnyArg() {}   protected:         /// Default Constructor      CommandOptionWithAnyArg() {}   };      /// A CommandOption that requires a string argument.   class CommandOptionWithStringArg : public CommandOptionWithArg   {   public:         /// Constructor      CommandOptionWithStringArg(const char shOpt,                                  const std::string& loOpt,                                  const std::string& desc,                                 const bool required = false)            : CommandOptionWithArg(stdType, shOpt, loOpt, desc, required)         {}         /// Destructor      virtual ~CommandOptionWithStringArg() {}      virtual std::string checkArguments();         /// Returns a string with the argument format.       virtual std::string getArgString() const      { return "<alpha>"; }   protected:         /// Default Constructor      CommandOptionWithStringArg() {}   };      /// A CommandOption that requires a numeric argument.   class CommandOptionWithNumberArg : public CommandOptionWithArg   {   public:         /// Constructor      CommandOptionWithNumberArg(const char shOpt,                                  const std::string& loOpt,                                  const std::string& desc,                                 const bool required = false)            : CommandOptionWithArg(stdType, shOpt, loOpt, desc, required)         {}         /// Destructor      virtual ~CommandOptionWithNumberArg() {}      virtual std::string checkArguments();         /// Returns a string with the argument format.       virtual std::string getArgString() const      { return "NUM"; }   protected:         /// Default Constructor      CommandOptionWithNumberArg() {}   };      /**       * It only makes sense to have a single one of these set. It is       * the option that takes the rest of the command line options       * that are not part of any other options.  e.g. "strace -ofile       * command arg1 arg2". The "command arg1 arg2" part is placed in       * objects of this class.       *        * @short CommandOption to take the rest of the command line       */   class CommandOptionRest : public CommandOptionWithArg   {   public:         /**          * CommandOptionRest contructor.  This sets the CommandOptionType          * for this object to trailingType.          *          * @param desc short description of the option          * @param required true if option is required          */      CommandOptionRest(const std::string& desc,                        const bool required = false)            : CommandOptionWithArg(trailingType, 0, "", desc, required)      {}               /// Destructor      virtual ~CommandOptionRest() {}            virtual std::string checkArguments();   protected:         /// Default Constructor      CommandOptionRest() {}   };      /**       * This is a special "command option" which is really a       * meta-option to make sure at least one of a set of real       * options has been used.       * \warning There's nothing to prevent you from, say, adding       * another meta-option to the list of mutually exclusive options       * contained in a CommandOptionOneOf instance (or even itself),       * but the behavior if you try this is undefined.       */   class CommandOptionOneOf : public CommandOption   {   public:         /**          * CommandOptionOneOf contructor.  This sets the CommandOptionType          * for this object to metaType.          */      CommandOptionOneOf()            : CommandOption(noArgument, metaType, 0, "", "")      {}               /// Destructor      virtual ~CommandOptionOneOf() {}      virtual std::string checkArguments();         /// Add an option to the list of mutually exclusive options      void addOption(CommandOption* opt)      { optionVec.push_back(opt); }         /// @return the command option that was used (NULL if none).      CommandOption* whichOne() const;         protected:      CommandOptionVec optionVec;   };      /**       * This is a special "command option" which is really a       * meta-option to make sure that if one of a set of real options       * has been used, all of the set are used.       * \warning There's nothing to prevent you from, say, adding       * another meta-option to the list of mutually exclusive options       * contained in a CommandOptionAllOf instance (or even itself),       * but the behavior if you try this is undefined.       */   class CommandOptionAllOf : public CommandOptionOneOf   {   public:         /**          * CommandOptionAllOf contructor.  This sets the CommandOptionType          * for this object to metaType.          */      CommandOptionAllOf()      {}               /// Destructor      virtual ~CommandOptionAllOf() {}      virtual std::string checkArguments();         /// returns the sum of all encapsulated option counts if all are in use, zero otherwise.      virtual unsigned long getCount() const;   private:         // hide this as it doesn't make sense for this class      CommandOption* whichOne() const;   };      /**       * This is a special "command option" which is really a       * meta-option to enforce mutual exclusion between a set of real       * options.       * \warning There's nothing to prevent you from, say, adding       * another mutex to the list of mutually exclusive options       * contained in a CommandOptionMutex instance (or even itself),       * but the behavior if you try this is undefined.       */   class CommandOptionMutex : public CommandOptionOneOf   {   public:         /**          * CommandOptionMutex contructor.  This sets the CommandOptionType          * for this object to metaType.          *          * @param required true if option is required.  This makes          * CommandOptionMutex do CommandOptionOneOf-type checking in          * addition to the exclusion (i.e. it checks to make sure at          * least one option was specified).          */      CommandOptionMutex(const bool required = false)            : doOneOfChecking(required)      {}               /// Destructor      virtual ~CommandOptionMutex() {}      virtual std::string checkArguments();   protected:      bool doOneOfChecking;   };      /**       * This is a special "command option" which is really a       * meta-option to make sure that a required option is set where       * the requirement is based on another option (that is, if you       * specify one, you must have specified another).       * \warning There's nothing to prevent you from using other meta       * options as requirements, but the behavior if you try this is       * undefined.       */   class CommandOptionDependent : public CommandOption   {   public:         /**          * CommandOptionDependent contructor.  This sets the          * CommandOptionType for this object to metaType.  During          * command line option validation, if \c child is set, \c          * parent is checked to make sure it is also set.          *          * @param parent Command option that must be used if...          * @param child ...is used.          */      CommandOptionDependent(const CommandOption* parent,                             const CommandOption* child)            : CommandOption(noArgument, metaType, 0, "", ""),              requiree(parent), requirer(child)      {}         /// Destructor      virtual ~CommandOptionDependent() {}      virtual std::string checkArguments();   protected:         /// Default Constructor      CommandOptionDependent() {}      const CommandOption *requiree, *requirer;   };      /**       * This is a special "command option" which is really a       * meta-option to group other options together for use in other       * meta-options.  This particular meta-option allows a group of       * options to be specified in other meta-options.  This option       * is considered "set" if any of the member options are set.       * This class and CommandOptionGroupAnd are designed to make up       * for the fact that the verification meta-options are not       * designed to work in other verification meta-options.       */   class CommandOptionGroupOr : public CommandOptionOneOf   {   public:         /**          * CommandOptionGroupOr contructor.  Does nothing explicitly.          */      CommandOptionGroupOr()      {}               /// Destructor.      virtual ~CommandOptionGroupOr() {}         /// Do not do any checking.      virtual std::string checkArguments() { return std::string(); }         /// returns the sum of all encapsulated option counts.      virtual unsigned long getCount() const;         /// return a string containing the aggregated option strings      virtual std::string getOptionString() const;   };      /**       * This is a special "command option" which is really a       * meta-option to group other options together for use in other       * meta-options.  This particular meta-option allows a group of       * options to be specified in other meta-options.  This option       * is considered "set" iff all of the member options are set.       * This class and CommandOptionGroupAnd are designed to make up       * for the fact that the verification meta-options are not       * designed to work in other verification meta-options.       */   class CommandOptionGroupAnd : public CommandOptionGroupOr   {   public:         /**          * CommandOptionGroupAnd contructor.  Does nothing explicitly.          */      CommandOptionGroupAnd()      {}               /// Destructor.      virtual ~CommandOptionGroupAnd() {}         /// returns the sum of all encapsulated option counts if all are in use, zero otherwise.      virtual unsigned long getCount() const;   };      //@}   } // namespace gpstk#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -