tclap 1.4.0
OptionalUnlabeledTracker.h
Go to the documentation of this file.
1// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2
3/******************************************************************************
4 *
5 * file: OptionalUnlabeledTracker.h
6 *
7 * Copyright (c) 2005, Michael E. Smoot .
8 * All rights reserved.
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#ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H
24#define TCLAP_OPTIONAL_UNLABELED_TRACKER_H
25
26#include <tclap/ArgException.h>
27
28#include <string>
29
30namespace TCLAP {
31
32// Legacy static helper retained for source compatibility. Built-in positional
33// arguments are validated at registration by their CmdLine, not by this helper.
35public:
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
42private:
43 static bool &alreadyOptionalRef() {
44 static bool ct = false;
45 return ct;
46 }
47};
48
50 const std::string &argName) {
53 "You can't specify ANY Unlabeled Arg following an optional "
54 "Unlabeled Arg",
55 argName));
56
58}
59
60} // namespace TCLAP
61
62#endif // TCLAP_OPTIONAL_UNLABELED_TRACKER_H
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:52