HelpVisitor.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
  2. /******************************************************************************
  3. *
  4. * file: HelpVisitor.h
  5. *
  6. * Copyright (c) 2003, Michael E. Smoot .
  7. * All rights reserved.
  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_HELP_VISITOR_H
  22. #define TCLAP_HELP_VISITOR_H
  23. #include <tclap/CmdLineInterface.h>
  24. #include <tclap/CmdLineOutput.h>
  25. #include <tclap/Visitor.h>
  26. namespace TCLAP {
  27. /**
  28. * A Visitor object that calls the usage method of the given CmdLineOutput
  29. * object for the specified CmdLine object.
  30. */
  31. class HelpVisitor: public Visitor
  32. {
  33. private:
  34. /**
  35. * Prevent accidental copying.
  36. */
  37. HelpVisitor(const HelpVisitor& rhs);
  38. HelpVisitor& operator=(const HelpVisitor& rhs);
  39. protected:
  40. /**
  41. * The CmdLine the output will be generated for.
  42. */
  43. CmdLineInterface* _cmd;
  44. /**
  45. * The output object.
  46. */
  47. CmdLineOutput** _out;
  48. public:
  49. /**
  50. * Constructor.
  51. * \param cmd - The CmdLine the output will be generated for.
  52. * \param out - The type of output.
  53. */
  54. HelpVisitor(CmdLineInterface* cmd, CmdLineOutput** out)
  55. : Visitor(), _cmd( cmd ), _out( out ) { }
  56. /**
  57. * Calls the usage method of the CmdLineOutput for the
  58. * specified CmdLine.
  59. */
  60. void visit() { (*_out)->usage(*_cmd); throw ExitException(0); }
  61. };
  62. }
  63. #endif