tclap 1.2.1

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

OptionalUnlabeledTracker.h
Go to the documentation of this file.
1
2
3 /******************************************************************************
4 *
5 * file: OptionalUnlabeledTracker.h
6 *
7 * Copyright (c) 2005, Michael E. Smoot .
8 * All rights reverved.
9 *
10 * See the file COPYING in the top directory of this distribution for
11 * more information.
12 *
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.
20 *
21 *****************************************************************************/
22
23
24 #ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H
25 #define TCLAP_OPTIONAL_UNLABELED_TRACKER_H
26
27 #include <string>
28
29 namespace TCLAP {
30
31 class OptionalUnlabeledTracker
32 {
33
34 public:
35
36 static void check( bool req, const std::string& argName );
37
38 static void gotOptional() { alreadyOptionalRef() = true; }
39
40 static bool& alreadyOptional() { return alreadyOptionalRef(); }
41
42 private:
43
44 static bool& alreadyOptionalRef() { static bool ct = false; return ct; }
45 };
46
47
48 inline void OptionalUnlabeledTracker::check( bool req, const std::string& argName )
49 {
50 if ( OptionalUnlabeledTracker::alreadyOptional() )
51 throw( SpecificationException(
52 "You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg",
53 argName ) );
54
55 if ( !req )
56 OptionalUnlabeledTracker::gotOptional();
57 }
58
59
60 } // namespace TCLAP
61
62 #endif
TCLAP::OptionalUnlabeledTracker::check
static void check(bool req, const std::string &argName)
Definition: OptionalUnlabeledTracker.h:48
TCLAP::SpecificationException
Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.
Definition: ArgException.h:167
TCLAP::OptionalUnlabeledTracker
Definition: OptionalUnlabeledTracker.h:31
TCLAP::OptionalUnlabeledTracker::alreadyOptional
static bool & alreadyOptional()
Definition: OptionalUnlabeledTracker.h:40
TCLAP::OptionalUnlabeledTracker::gotOptional
static void gotOptional()
Definition: OptionalUnlabeledTracker.h:38
TCLAP
Definition: Arg.h:57