tclap
1.2.5
include
tclap
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
31
namespace
TCLAP
{
32
33
class
OptionalUnlabeledTracker
34
{
35
36
public
:
37
38
static
void
check
(
bool
req,
const
std::string& argName );
39
40
static
void
gotOptional
() { alreadyOptionalRef() =
true
; }
41
42
static
bool
&
alreadyOptional
() {
return
alreadyOptionalRef(); }
43
44
private
:
45
46
static
bool
& alreadyOptionalRef() {
static
bool
ct =
false
;
return
ct; }
47
};
48
49
50
inline
void
OptionalUnlabeledTracker::check
(
bool
req,
const
std::string& argName )
51
{
52
if
(
OptionalUnlabeledTracker::alreadyOptional
() )
53
throw
(
SpecificationException
(
54
"You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg"
,
55
argName ) );
56
57
if
( !req )
58
OptionalUnlabeledTracker::gotOptional
();
59
}
60
61
62
}
// namespace TCLAP
63
64
#endif
TCLAP::OptionalUnlabeledTracker::check
static void check(bool req, const std::string &argName)
Definition:
OptionalUnlabeledTracker.h:68
TCLAP::OptionalUnlabeledTracker::alreadyOptional
static bool & alreadyOptional()
Definition:
OptionalUnlabeledTracker.h:78
TCLAP::OptionalUnlabeledTracker::gotOptional
static void gotOptional()
Definition:
OptionalUnlabeledTracker.h:76
TCLAP::SpecificationException
Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.
Definition:
ArgException.h:187
TCLAP
Definition:
Arg.h:48
Generated by
1.8.17