File: cmd_line_parser_option.h

package info (click to toggle)
concurrentqueue 1.0.3%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,648 kB
  • sloc: cpp: 37,303; makefile: 88; ansic: 67; python: 46; sh: 18
file content (107 lines) | stat: -rw-r--r-- 2,889 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright (C) 2003  Davis E. King (davis@dlib.net)
// License: Boost Software License   See LICENSE.txt for the full license.
#ifndef DLIB_CMD_LINE_PARSER_OPTIOn_
#define DLIB_CMD_LINE_PARSER_OPTIOn_

#include <string>

namespace dlib
{

// ----------------------------------------------------------------------------------------

    template <
        typename charT
        >
    class cmd_line_parser_option
    {
        /*!
            POINTERS AND REFERENCES TO INTERNAL DATA
                None of the functions in cmd_line_parser_option will invalidate
                pointers or references to internal data when called.

            WHAT THIS OBJECT REPRESENTS
                This object represents a command line option.  
        !*/

    public:

        typedef charT char_type;
        typedef std::basic_string<charT> string_type;

        virtual ~cmd_line_parser_option (
        ) = 0;

        virtual const string_type& name (
        ) const = 0;
        /*!
            ensures
                - returns the name of this option
        !*/

        virtual const string_type& group_name (
        ) const = 0;
        /*!
            ensures
                - returns the name of the group this option is in.  If no group was set for
                  this option then this function returns "".
        !*/

        virtual const string_type& description (
        ) const = 0;
        /*!
            ensures
                - returns the description for this option
        !*/

        virtual unsigned long number_of_arguments( 
        ) const = 0;
        /*!
            ensures
                - returns the number of arguments for this option
        !*/

        virtual unsigned long count(
        ) const = 0;
        /*!
            ensures
                - returns the number of times this option appears on the command line.
        !*/

        virtual const string_type& argument (
            unsigned long arg = 0,
            unsigned long N = 0
        ) const = 0;
        /*!
            requires
                - arg < number_of_arguments()
                - N < count()
            ensures
                - returns the arg-th argument to the Nth occurrence of this 
                  option on the command line.
        !*/

        inline operator bool (
        ) const { return count() > 0; }
        /*!
            ensures
                - returns true if this option appears on the command line at all
        !*/

    protected:

        // restricted functions
        cmd_line_parser_option& operator=(const cmd_line_parser_option&){return *this;}

    };

    // destructor does nothing
    template < typename charT >
    cmd_line_parser_option<charT>::~cmd_line_parser_option() {}

// ----------------------------------------------------------------------------------------

}

#endif // DLIB_CMD_LINE_PARSER_OPTIOn_