/usr/include/mia-2.0/mia/core/cmdoption.hh is in libmia-2.0-dev 2.0.13-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | /* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2013 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef mia_core_cmdoption_hh
#define mia_core_cmdoption_hh
#include <string>
#include <memory>
#include <iostream>
#include <mia/core/defines.hh>
#include <mia/core/handlerbase.hh>
#include <libxml++/libxml++.h>
NS_MIA_BEGIN
class CCmdOption;
/// Class to provide a maping from short option names to options
typedef std::map<char, CCmdOption *> CShortoptionMap;
/// Class to provide a maping from long option names to options
typedef std::map<std::string, CCmdOption *> CLongoptionMap;
/**
\ingroup cmdline
\brief The base class for all command line options.
The base class of all possible command line options. It defines the interface
of the options as well as some basic functionality to create help strings.
*/
class EXPORT_CORE CCmdOption {
public:
/// readability constant to show that an option is not required
static const bool not_required;
/// readability constant to show that an option is required
static const bool required;
/** The constructor
\param short_opt the short option character
\param long_opt the long option name
\param long_help a long help string
\param short_help help to print out when only usage information is requested
\param required set to true if the option must be set by the user
*/
CCmdOption(char short_opt, const char *long_opt, const char *long_help,
const char *short_help, bool required);
/// ensure virtual destruction
virtual ~CCmdOption();
/** Add this option to the given option maps
\param sm a \a CShortoptionMap to add this option to
\param lm a \a CLongoptionMap to add this option to
*/
void add_option(CShortoptionMap& sm, CLongoptionMap& lm);
/** \returns how many arguments after the option argument on the command
line will be used by this option
*/
size_t get_needed_args() const;
/** Writes out the value of the option to an output stream
\param os the output stream to write this options value to
*/
void write_value(std::ostream& os) const;
/** Set the value of the option parameter based on the input string
\param str_value the string value to be vonverted to the option value
*/
void set_value(const char *str_value);
/// \returns the long name of the option
const char *get_long_option() const;
/// \returns the long name of the option
char get_short_option() const;
/** Print the short help of the option to an output stream
\param os the output stream
*/
void print_short_help(std::ostream& os) const;
/** Print the help of the option to an output stream
\param os the output stream
*/
void get_opt_help(std::ostream& os)const;
/** Print the long option name of the option to an output stream
\param os the output stream
*/
void get_long_help(std::ostream& os)const;
/// \returns the options value as string
const std::string get_value_as_string() const;
/// @returns true if the option is a required option and hasn't been set
bool is_required() const;
/// \returns the long help string
const char *long_help() const;
/**
Returns help string tailered for the XML help creation system and adds
used plug-in handlers to the helper map
\param parent the parent xml node to which to add documentation
\param[in,out] handler_map the map of possibely recoursively called plug-in handlers
\returns the text relate to the help
\remark the text should probably be added to the parent node instead.
*/
std::string get_long_help_xml(xmlpp::Element& parent, HandlerHelpMap& handler_map) const;
/** This function must be called after the parameter was set through a string in order to handle
complex initialization like done for factory based command line parameters
*/
void post_set();
protected:
/// clear the "required" flag
void clear_required();
/**
write the long help string to a stream
\param os the output stream
*/
virtual void do_get_long_help(std::ostream& os) const;
private:
const char *get_short_help() const;
virtual void do_add_option(CShortoptionMap& sm, CLongoptionMap& lm);
virtual void do_print_short_help(std::ostream& os) const;
virtual void do_get_opt_help(std::ostream& os) const;
virtual bool do_set_value(const char *str_value) = 0;
virtual size_t do_get_needed_args() const;
virtual void do_write_value(std::ostream& os) const = 0;
virtual const std::string do_get_value_as_string() const;
virtual void do_post_set();
virtual void do_get_long_help_xml(std::ostream& os, xmlpp::Element& parent, HandlerHelpMap& handler_map) const;
char m_short_opt;
const char *m_long_opt;
const char *m_long_help;
const char *m_short_help;
bool m_flags;
};
/// a shared pointer definition of the Option
typedef std::shared_ptr<CCmdOption > PCmdOption;
NS_MIA_END
#endif
|