diff options
author | KWSys Upstream <kwrobot@kitware.com> | 2016-11-09 14:12:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-11-09 14:22:56 (GMT) |
commit | 773b36e5d4af3ac040625e0ea16bcfd30fcdeb6d (patch) | |
tree | bd409d3f09f6714981a444e896e1bc08e22ee184 /CommandLineArguments.hxx.in | |
parent | 53862f04a0002894c0ef5aeb23d52495e5abe60d (diff) | |
download | CMake-773b36e5d4af3ac040625e0ea16bcfd30fcdeb6d.zip CMake-773b36e5d4af3ac040625e0ea16bcfd30fcdeb6d.tar.gz CMake-773b36e5d4af3ac040625e0ea16bcfd30fcdeb6d.tar.bz2 |
KWSys 2016-11-09 (18c65411)
Code extracted from:
http://public.kitware.com/KWSys.git
at commit 18c654114de3aa65429542f95308720bc68f9231 (master).
Upstream Shortlog
-----------------
Brad King (14):
37306a1c FStream: Quiet unused argument warning
15e90a3c Sort includes to stabilize include order w.r.t. clang-format
26509227 Copyright.txt: Add notice of copyright by contributors
fc42d3f2 Add temporary script to filter license notices
c41c1bc4 Simplify KWSys per-source license notices
1d4c0b4a Remove temporary script that filtered license notices
a4f5ef79 SystemInformation: Remove stray comment
8649a886 kwsysPrivate: Protect KWSYS_HEADER macro from clang-format
89b98af5 Configure clang-format for KWSys source tree
547dacad Add a script to run clang-format on the entire source tree
aa94be0c CONTRIBUTING: Add a section on coding style
6604c4b6 Empty commit at end of history preceding clang-format style transition
2b3e2b1c Tell Git to not export 'clang-format' infrastructure
18c65411 FStream: Include Configure.hxx before other headers
Kitware Robot (1):
6c973b46 Revise C++ coding style using clang-format
Diffstat (limited to 'CommandLineArguments.hxx.in')
-rw-r--r-- | CommandLineArguments.hxx.in | 133 |
1 files changed, 62 insertions, 71 deletions
diff --git a/CommandLineArguments.hxx.in b/CommandLineArguments.hxx.in index e4f6d02..31115e5 100644 --- a/CommandLineArguments.hxx.in +++ b/CommandLineArguments.hxx.in @@ -1,14 +1,5 @@ -/*============================================================================ - KWSys - Kitware System Library - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing#kwsys for details. */ #ifndef @KWSYS_NAMESPACE@_CommandLineArguments_hxx #define @KWSYS_NAMESPACE@_CommandLineArguments_hxx @@ -18,8 +9,7 @@ #include <string> #include <vector> -namespace @KWSYS_NAMESPACE@ -{ +namespace @KWSYS_NAMESPACE@ { class CommandLineArgumentsInternal; struct CommandLineArgumentsCallbackStructure; @@ -41,28 +31,29 @@ struct CommandLineArgumentsCallbackStructure; * the argument is specified, the variable is set to the specified value casted * to the appropriate type. For boolean (NO_ARGUMENT), the value is "1". * - * Both interfaces can be used at the same time. + * Both interfaces can be used at the same time. * * Possible argument types are: * NO_ARGUMENT - The argument takes no value : --A * CONCAT_ARGUMENT - The argument takes value after no space : --Aval - * SPACE_ARGUMENT - The argument takes value after space : --A val + * SPACE_ARGUMENT - The argument takes value after space : --A val * EQUAL_ARGUMENT - The argument takes value after equal : --A=val - * MULTI_ARGUMENT - The argument takes values after space : --A val1 val2 val3 ... + * MULTI_ARGUMENT - The argument takes values after space : --A val1 val2 + * val3 ... * * Example use: * * kwsys::CommandLineArguments arg; * arg.Initialize(argc, argv); * typedef kwsys::CommandLineArguments argT; - * arg.AddArgument("--something", argT::EQUAL_ARGUMENT, &some_variable, + * arg.AddArgument("--something", argT::EQUAL_ARGUMENT, &some_variable, * "This is help string for --something"); * if ( !arg.Parse() ) * { * std::cerr << "Problem parsing arguments" << std::endl; * res = 1; * } - * + * */ class @KWSYS_NAMESPACE@_EXPORT CommandLineArguments @@ -74,7 +65,8 @@ public: /** * Various argument types. */ - enum ArgumentTypeEnum { + enum ArgumentTypeEnum + { NO_ARGUMENT, CONCAT_ARGUMENT, SPACE_ARGUMENT, @@ -86,27 +78,28 @@ public: * Various variable types. When using the variable interface, this specifies * what type the variable is. */ - enum VariableTypeEnum { - NO_VARIABLE_TYPE = 0, // The variable is not specified - INT_TYPE, // The variable is integer (int) - BOOL_TYPE, // The variable is boolean (bool) - DOUBLE_TYPE, // The variable is float (double) - STRING_TYPE, // The variable is string (char*) - STL_STRING_TYPE, // The variable is string (char*) - VECTOR_INT_TYPE, // The variable is integer (int) - VECTOR_BOOL_TYPE, // The variable is boolean (bool) - VECTOR_DOUBLE_TYPE, // The variable is float (double) - VECTOR_STRING_TYPE, // The variable is string (char*) - VECTOR_STL_STRING_TYPE, // The variable is string (char*) + enum VariableTypeEnum + { + NO_VARIABLE_TYPE = 0, // The variable is not specified + INT_TYPE, // The variable is integer (int) + BOOL_TYPE, // The variable is boolean (bool) + DOUBLE_TYPE, // The variable is float (double) + STRING_TYPE, // The variable is string (char*) + STL_STRING_TYPE, // The variable is string (char*) + VECTOR_INT_TYPE, // The variable is integer (int) + VECTOR_BOOL_TYPE, // The variable is boolean (bool) + VECTOR_DOUBLE_TYPE, // The variable is float (double) + VECTOR_STRING_TYPE, // The variable is string (char*) + VECTOR_STL_STRING_TYPE, // The variable is string (char*) LAST_VARIABLE_TYPE }; /** * Prototypes for callbacks for callback interface. */ - typedef int(*CallbackType)(const char* argument, const char* value, - void* call_data); - typedef int(*ErrorCallbackType)(const char* argument, void* client_data); + typedef int (*CallbackType)(const char* argument, const char* value, + void* call_data); + typedef int (*ErrorCallbackType)(const char* argument, void* client_data); /** * Initialize internal data structures. This should be called before parsing. @@ -133,24 +126,24 @@ public: * argument help specifies the help string used with this option. The * callback and call_data can be skipped. */ - void AddCallback(const char* argument, ArgumentTypeEnum type, - CallbackType callback, void* call_data, const char* help); + void AddCallback(const char* argument, ArgumentTypeEnum type, + CallbackType callback, void* call_data, const char* help); /** * Add handler for argument which is going to set the variable to the * specified value. If the argument is specified, the option is casted to the * appropriate type. */ + void AddArgument(const char* argument, ArgumentTypeEnum type, bool* variable, + const char* help); + void AddArgument(const char* argument, ArgumentTypeEnum type, int* variable, + const char* help); void AddArgument(const char* argument, ArgumentTypeEnum type, - bool* variable, const char* help); + double* variable, const char* help); void AddArgument(const char* argument, ArgumentTypeEnum type, - int* variable, const char* help); - void AddArgument(const char* argument, ArgumentTypeEnum type, - double* variable, const char* help); - void AddArgument(const char* argument, ArgumentTypeEnum type, - char** variable, const char* help); + char** variable, const char* help); void AddArgument(const char* argument, ArgumentTypeEnum type, - std::string* variable, const char* help); + std::string* variable, const char* help); /** * Add handler for argument which is going to set the variable to the @@ -158,31 +151,31 @@ public: * appropriate type. This will handle the multi argument values. */ void AddArgument(const char* argument, ArgumentTypeEnum type, - std::vector<bool>* variable, const char* help); + std::vector<bool>* variable, const char* help); + void AddArgument(const char* argument, ArgumentTypeEnum type, + std::vector<int>* variable, const char* help); + void AddArgument(const char* argument, ArgumentTypeEnum type, + std::vector<double>* variable, const char* help); void AddArgument(const char* argument, ArgumentTypeEnum type, - std::vector<int>* variable, const char* help); - void AddArgument(const char* argument, ArgumentTypeEnum type, - std::vector<double>* variable, const char* help); - void AddArgument(const char* argument, ArgumentTypeEnum type, - std::vector<char*>* variable, const char* help); + std::vector<char*>* variable, const char* help); void AddArgument(const char* argument, ArgumentTypeEnum type, - std::vector<std::string>* variable, const char* help); + std::vector<std::string>* variable, const char* help); /** * Add handler for boolean argument. The argument does not take any option * and if it is specified, the value of the variable is true/1, otherwise it * is false/0. */ - void AddBooleanArgument(const char* argument, - bool* variable, const char* help); - void AddBooleanArgument(const char* argument, - int* variable, const char* help); - void AddBooleanArgument(const char* argument, - double* variable, const char* help); - void AddBooleanArgument(const char* argument, - char** variable, const char* help); - void AddBooleanArgument(const char* argument, - std::string* variable, const char* help); + void AddBooleanArgument(const char* argument, bool* variable, + const char* help); + void AddBooleanArgument(const char* argument, int* variable, + const char* help); + void AddBooleanArgument(const char* argument, double* variable, + const char* help); + void AddBooleanArgument(const char* argument, char** variable, + const char* help); + void AddBooleanArgument(const char* argument, std::string* variable, + const char* help); /** * Set the callbacks for error handling. @@ -236,14 +229,14 @@ protected: //! This is internal method that registers variable with argument void AddArgument(const char* argument, ArgumentTypeEnum type, - VariableTypeEnum vtype, void* variable, const char* help); + VariableTypeEnum vtype, void* variable, const char* help); bool GetMatchedArguments(std::vector<std::string>* matches, - const std::string& arg); + const std::string& arg); //! Populate individual variables bool PopulateVariable(CommandLineArgumentsCallbackStructure* cs, - const char* value); + const char* value); //! Populate individual variables of type ... void PopulateVariable(bool* variable, const std::string& value); @@ -253,9 +246,12 @@ protected: void PopulateVariable(std::string* variable, const std::string& value); void PopulateVariable(std::vector<bool>* variable, const std::string& value); void PopulateVariable(std::vector<int>* variable, const std::string& value); - void PopulateVariable(std::vector<double>* variable, const std::string& value); - void PopulateVariable(std::vector<char*>* variable, const std::string& value); - void PopulateVariable(std::vector<std::string>* variable, const std::string& value); + void PopulateVariable(std::vector<double>* variable, + const std::string& value); + void PopulateVariable(std::vector<char*>* variable, + const std::string& value); + void PopulateVariable(std::vector<std::string>* variable, + const std::string& value); typedef CommandLineArgumentsInternal Internal; Internal* Internals; @@ -269,8 +265,3 @@ protected: } // namespace @KWSYS_NAMESPACE@ #endif - - - - - |