tclap 1.2.6
OptionalUnlabeledTracker.h
Go to the documentation of this file.
1// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2
3
4
5/******************************************************************************
6 *
7 * file: OptionalUnlabeledTracker.h
8 *
9 * Copyright (c) 2005, Michael E. Smoot .
10 * All rights reserved.
11 *
12 * See the file COPYING in the top directory of this distribution for
13 * more information.
14 *
15 * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 *****************************************************************************/
24
25
26#ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H
27#define TCLAP_OPTIONAL_UNLABELED_TRACKER_H
28
29#include <string>
30#include <tclap/ArgException.h>
31
32namespace TCLAP {
33
35{
36
37 public:
38
39 static void check( bool req, const std::string& argName );
40
41 static void gotOptional() { alreadyOptionalRef() = true; }
42
43 static bool& alreadyOptional() { return alreadyOptionalRef(); }
44
45 private:
46
47 static bool& alreadyOptionalRef() { static bool ct = false; return ct; }
48};
49
50
51inline void OptionalUnlabeledTracker::check( bool req, const std::string& argName )
52{
55 "You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg",
56 argName ) );
57
58 if ( !req )
60}
61
62
63} // namespace TCLAP
64
65#endif
static void check(bool req, const std::string &argName)
Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.
Definition Arg.h:48