1 // Copyright (C) 2003  Davis E. King (davis@dlib.net)
2 // License: Boost Software License   See LICENSE.txt for the full license.
3 #ifndef DLIB_CMD_LINE_PARSEr_
4 #define DLIB_CMD_LINE_PARSEr_
5 
6 #include "cmd_line_parser/cmd_line_parser_kernel_1.h"
7 #include "cmd_line_parser/cmd_line_parser_kernel_c.h"
8 #include "cmd_line_parser/cmd_line_parser_print_1.h"
9 #include "cmd_line_parser/cmd_line_parser_check_1.h"
10 #include "cmd_line_parser/cmd_line_parser_check_c.h"
11 #include <string>
12 #include "cmd_line_parser/get_option.h"
13 
14 #include "map.h"
15 #include "sequence.h"
16 
17 
18 
19 namespace dlib
20 {
21 
22 // ----------------------------------------------------------------------------------------
23 
24     template <
25         typename charT
26         >
27     class impl_cmd_line_parser
28     {
29         /*!
30             This class is basically just a big templated typedef for building
31             a complete command line parser type out of all the parts it needs.
32         !*/
33 
impl_cmd_line_parser()34         impl_cmd_line_parser() {}
35 
36         typedef typename sequence<std::basic_string<charT> >::kernel_2a sequence_2a;
37         typedef typename sequence<std::basic_string<charT>*>::kernel_2a psequence_2a;
38         typedef typename map<std::basic_string<charT>,void*>::kernel_1a map_1a_string;
39 
40     public:
41 
42         typedef cmd_line_parser_kernel_1<charT,map_1a_string,sequence_2a,psequence_2a> kernel_1a;
43         typedef cmd_line_parser_kernel_c<kernel_1a> kernel_1a_c;
44         typedef cmd_line_parser_print_1<kernel_1a_c> print_1a_c;
45         typedef cmd_line_parser_check_c<cmd_line_parser_check_1<print_1a_c> > check_1a_c;
46     };
47 
48 // ----------------------------------------------------------------------------------------
49 
50     template <
51         typename charT
52         >
53     class cmd_line_parser : public impl_cmd_line_parser<charT>::check_1a_c
54     {
55     public:
56 
57         // These typedefs are here for backwards compatibility with previous versions of dlib.
58         typedef cmd_line_parser kernel_1a;
59         typedef cmd_line_parser kernel_1a_c;
60         typedef cmd_line_parser print_1a;
61         typedef cmd_line_parser print_1a_c;
62         typedef cmd_line_parser check_1a;
63         typedef cmd_line_parser check_1a_c;
64     };
65 
66     template <
67         typename charT
68         >
swap(cmd_line_parser<charT> & a,cmd_line_parser<charT> & b)69     inline void swap (
70         cmd_line_parser<charT>& a,
71         cmd_line_parser<charT>& b
72     ) { a.swap(b); }
73 
74 // ----------------------------------------------------------------------------------------
75 
76     typedef cmd_line_parser<char> command_line_parser;
77     typedef cmd_line_parser<wchar_t> wcommand_line_parser;
78 
79 // ----------------------------------------------------------------------------------------
80 
81 }
82 
83 #endif // DLIB_CMD_LINE_PARSEr_
84 
85