Commit 7f9fbba5 authored by Davis King's avatar Davis King

Turned the cmd_line_parser into a single implementation component (from the

user perspective anyway).
parent f7165919
......@@ -19,13 +19,19 @@
namespace dlib
{
// ----------------------------------------------------------------------------------------
template <
typename charT
>
class cmd_line_parser
class impl_cmd_line_parser
{
cmd_line_parser() {}
/*!
This class is basically just a big templated typedef for building
a complete command line parser type out of all the parts it needs.
!*/
impl_cmd_line_parser() {}
typedef typename sequence<std::basic_string<charT> >::kernel_2a sequence_2a;
typedef typename sequence<std::basic_string<charT>*>::kernel_2a psequence_2a;
......@@ -33,36 +39,34 @@ namespace dlib
public:
//----------- kernels ---------------
// kernel_1a
typedef cmd_line_parser_kernel_1<charT,map_1a_string,sequence_2a,psequence_2a>
kernel_1a;
typedef cmd_line_parser_kernel_c<kernel_1a>
kernel_1a_c;
typedef cmd_line_parser_kernel_1<charT,map_1a_string,sequence_2a,psequence_2a> kernel_1a;
typedef cmd_line_parser_kernel_c<kernel_1a> kernel_1a_c;
typedef cmd_line_parser_print_1<kernel_1a_c> print_1a_c;
typedef cmd_line_parser_check_c<cmd_line_parser_check_1<print_1a_c> > check_1a_c;
};
// ----------------------------------------------------------------------------------------
//----------- extensions ---------------
// print_1 extend kernel_1a
typedef cmd_line_parser_print_1<kernel_1a>
print_1a;
typedef cmd_line_parser_print_1<kernel_1a_c>
print_1a_c;
// check_1 extend print_1a
typedef cmd_line_parser_check_1<print_1a>
check_1a;
typedef cmd_line_parser_check_c<cmd_line_parser_check_1<print_1a_c> >
check_1a_c;
template <
typename charT
>
class cmd_line_parser : public impl_cmd_line_parser<charT>::check_1a_c
{
public:
// These typedefs are here for backwards compatibility with previous versions of dlib.
typedef cmd_line_parser kernel_1a;
typedef cmd_line_parser kernel_1a_c;
typedef cmd_line_parser print_1a;
typedef cmd_line_parser print_1a_c;
typedef cmd_line_parser check_1a;
typedef cmd_line_parser check_1a_c;
};
// ----------------------------------------------------------------------------------------
typedef cmd_line_parser<char>::check_1a_c command_line_parser;
typedef cmd_line_parser<wchar_t>::check_1a_c wcommand_line_parser;
typedef cmd_line_parser<char> command_line_parser;
typedef cmd_line_parser<wchar_t> wcommand_line_parser;
// ----------------------------------------------------------------------------------------
......
......@@ -3,7 +3,7 @@
#ifndef DLIB_CMD_LINE_PARSER_CHECk_1_
#define DLIB_CMD_LINE_PARSER_CHECk_1_
#include "cmd_line_parser_check_abstract.h"
#include "cmd_line_parser_kernel_abstract.h"
#include <sstream>
#include <string>
#include "../string.h"
......
This diff is collapsed.
......@@ -3,7 +3,7 @@
#ifndef DLIB_CMD_LINE_PARSER_PRINt_1_
#define DLIB_CMD_LINE_PARSER_PRINt_1_
#include "cmd_line_parser_print_abstract.h"
#include "cmd_line_parser_kernel_abstract.h"
#include "../algs.h"
#include "../string.h"
#include <iostream>
......
// Copyright (C) 2005 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_CMD_LINE_PARSER_PRINt_ABSTRACT_
#ifdef DLIB_CMD_LINE_PARSER_PRINt_ABSTRACT_
#include "cmd_line_parser_kernel_abstract.h"
#include <iosfwd>
namespace dlib
{
template <
typename clp_base
>
class cmd_line_parser_print : public clp_base
{
/*!
REQUIREMENTS ON CLP_BASE
clp_base is an implementation of cmd_line_parser/cmd_line_parser_kernel_abstract.h
POINTERS AND REFERENCES TO INTERNAL DATA
The print_options() function may invalidate pointers or references to
internal data.
WHAT THIS EXTENSION DOES FOR CMD_LINE_PARSER
This gives a cmd_line_parser object the ability to print its options
in a nice format that fits into a console screen.
!*/
public:
void print_options (
std::basic_ostream<typename clp_base::char_type>& out
) const;
/*!
ensures
- prints all the command line options to out.
- #at_start() == true
throws
- any exception.
if an exception is thrown then #at_start() == true but otherwise
it will have no effect on the state of #*this.
!*/
};
template <
typename clp_base
>
inline void swap (
cmd_line_parser_print<clp_base>& a,
cmd_line_parser_print<clp_base>& b
) { a.swap(b); }
/*!
provides a global swap function
!*/
}
#endif // DLIB_CMD_LINE_PARSER_PRINt_ABSTRACT_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment