1 // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
3 /******************************************************************************
5 * file: VersionVisitor.h
7 * Copyright (c) 2003, Michael E. Smoot .
10 * See the file COPYING in the top directory of this distribution for
13 * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 * DEALINGS IN THE SOFTWARE.
21 *****************************************************************************/
24 #ifndef TCLAP_VERSION_VISITOR_H
25 #define TCLAP_VERSION_VISITOR_H
27 #include <tclap/CmdLineInterface.h>
28 #include <tclap/CmdLineOutput.h>
29 #include <tclap/Visitor.h>
34 * A Visitor that will call the version method of the given CmdLineOutput
35 * for the specified CmdLine object and then exit.
37 class VersionVisitor: public Visitor
41 * Prevent accidental copying
43 VersionVisitor(const VersionVisitor& rhs);
44 VersionVisitor& operator=(const VersionVisitor& rhs);
49 * The CmdLine of interest.
51 CmdLineInterface* _cmd;
62 * \param cmd - The CmdLine the output is generated for.
63 * \param out - The type of output.
65 VersionVisitor( CmdLineInterface* cmd, CmdLineOutput** out )
66 : Visitor(), _cmd( cmd ), _out( out ) { }
69 * Calls the version method of the output object using the
73 (*_out)->version(*_cmd);
74 throw ExitException(0);