Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 

151 рядки
3.5 KiB

  1. /******************************************************************************
  2. *
  3. * file: CmdLineInterface.h
  4. *
  5. * Copyright (c) 2003, Michael E. Smoot .
  6. * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
  7. * All rights reverved.
  8. *
  9. * See the file COPYING in the top directory of this distribution for
  10. * more information.
  11. *
  12. * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  15. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  17. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  18. * DEALINGS IN THE SOFTWARE.
  19. *
  20. *****************************************************************************/
  21. #ifndef TCLAP_COMMANDLINE_INTERFACE_H
  22. #define TCLAP_COMMANDLINE_INTERFACE_H
  23. #include <string>
  24. #include <vector>
  25. #include <list>
  26. #include <iostream>
  27. #include <algorithm>
  28. namespace TCLAP {
  29. class Arg;
  30. class CmdLineOutput;
  31. class XorHandler;
  32. /**
  33. * The base class that manages the command line definition and passes
  34. * along the parsing to the appropriate Arg classes.
  35. */
  36. class CmdLineInterface
  37. {
  38. public:
  39. /**
  40. * Destructor
  41. */
  42. virtual ~CmdLineInterface() {}
  43. /**
  44. * Adds an argument to the list of arguments to be parsed.
  45. * \param a - Argument to be added.
  46. */
  47. virtual void add( Arg& a )=0;
  48. /**
  49. * An alternative add. Functionally identical.
  50. * \param a - Argument to be added.
  51. */
  52. virtual void add( Arg* a )=0;
  53. /**
  54. * Add two Args that will be xor'd.
  55. * If this method is used, add does
  56. * not need to be called.
  57. * \param a - Argument to be added and xor'd.
  58. * \param b - Argument to be added and xor'd.
  59. */
  60. virtual void xorAdd( Arg& a, Arg& b )=0;
  61. /**
  62. * Add a list of Args that will be xor'd. If this method is used,
  63. * add does not need to be called.
  64. * \param xors - List of Args to be added and xor'd.
  65. */
  66. virtual void xorAdd( std::vector<Arg*>& xors )=0;
  67. /**
  68. * Parses the command line.
  69. * \param argc - Number of arguments.
  70. * \param argv - Array of arguments.
  71. */
  72. virtual void parse(int argc, const char * const * argv)=0;
  73. /**
  74. * Parses the command line.
  75. * \param args - A vector of strings representing the args.
  76. * args[0] is still the program name.
  77. */
  78. void parse(std::vector<std::string>& args);
  79. /**
  80. * Returns the CmdLineOutput object.
  81. */
  82. virtual CmdLineOutput* getOutput()=0;
  83. /**
  84. * \param co - CmdLineOutput object that we want to use instead.
  85. */
  86. virtual void setOutput(CmdLineOutput* co)=0;
  87. /**
  88. * Returns the version string.
  89. */
  90. virtual std::string& getVersion()=0;
  91. /**
  92. * Returns the program name string.
  93. */
  94. virtual std::string& getProgramName()=0;
  95. /**
  96. * Returns the argList.
  97. */
  98. virtual std::list<Arg*>& getArgList()=0;
  99. /**
  100. * Returns the XorHandler.
  101. */
  102. virtual XorHandler& getXorHandler()=0;
  103. /**
  104. * Returns the delimiter string.
  105. */
  106. virtual char getDelimiter()=0;
  107. /**
  108. * Returns the message string.
  109. */
  110. virtual std::string& getMessage()=0;
  111. /**
  112. * Indicates whether or not the help and version switches were created
  113. * automatically.
  114. */
  115. virtual bool hasHelpAndVersion()=0;
  116. /**
  117. * Resets the instance as if it had just been constructed so that the
  118. * instance can be reused.
  119. */
  120. virtual void reset()=0;
  121. };
  122. } //namespace
  123. #endif