| 75 | */ |
| 76 | |
| 77 | class CommandLineArgumentParser : public Object |
| 78 | { |
| 79 | public: |
| 80 | ITK_DISALLOW_COPY_AND_MOVE(CommandLineArgumentParser); |
| 81 | |
| 82 | /** Standard class typedefs. */ |
| 83 | using Self = CommandLineArgumentParser; |
| 84 | using Superclass = Object; |
| 85 | using Pointer = SmartPointer<Self>; |
| 86 | using ConstPointer = SmartPointer<const Self>; |
| 87 | |
| 88 | enum ReturnValue |
| 89 | { |
| 90 | PASSED, |
| 91 | FAILED, |
| 92 | HELPREQUESTED |
| 93 | }; |
| 94 | |
| 95 | /** Method for creation through the object factory. */ |
| 96 | itkNewMacro(Self); |
| 97 | |
| 98 | /** Run-time type information (and related methods). */ |
| 99 | itkOverrideGetNameOfClassMacro(CommandLineArgumentParser); |
| 100 | |
| 101 | /** Set the command line arguments in a vector of strings. */ |
| 102 | void |
| 103 | SetCommandLineArguments(int argc, char ** argv); |
| 104 | |
| 105 | /** Ensure that all required arguments have been passed. */ |
| 106 | ReturnValue |
| 107 | CheckForRequiredArguments() const; |
| 108 | |
| 109 | /** Map to store the arguments and their indices. */ |
| 110 | using IndexType = std::size_t; |
| 111 | using ArgumentMapType = std::map<std::string, IndexType>; |
| 112 | using EntryType = ArgumentMapType::value_type; |
| 113 | |
| 114 | /** Copy argv in a map. */ |
| 115 | void |
| 116 | CreateArgumentMap(); |
| 117 | |
| 118 | /** Print all arguments. */ |
| 119 | void |
| 120 | PrintAllArguments() const; |
| 121 | |
| 122 | /** Checks if an argument is given. */ |
| 123 | bool |
| 124 | ArgumentExists(const std::string & key) const; |
| 125 | |
| 126 | /** Checks if exactly one of the specified arguments is given. */ |
| 127 | bool |
| 128 | ExactlyOneExists(const std::vector<std::string> & keys) const; |
| 129 | |
| 130 | /** Mark an argument as required. */ |
| 131 | void |
| 132 | MarkArgumentAsRequired(const std::string & argument, const std::string & helpText = ""); |
| 133 | |
| 134 | /** Mark exactly one of the specified arguments as required. */ |
nothing calls this directly
no outgoing calls
no test coverage detected