/usr/lib/petscdir/3.4.2/include/sieve/ALE_args.hh is in libpetsc3.4.2-dev 3.4.2.dfsg1-8.1+b1.
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 | #ifndef included_ALE_args_hh
#define included_ALE_args_hh
// This should be included indirectly -- only by including ALE.hh
#include <vector>
#include <string>
#include <boost/program_options.hpp>
namespace ALE {
//
struct AnyArg {
typedef ::boost::program_options::value_semantic value_semantic;
typedef value_semantic* value_semantic_ptr;
// cast operator
virtual operator value_semantic_ptr() const = 0;
virtual ~AnyArg(){};
};
//
// Arg<T> is the type of object that can be added to ArgDB and
// ultimately holds an argument of type T.
//
template<typename T>
struct Arg : public AnyArg {
typedef typename AnyArg::value_semantic value_semantic;
typedef value_semantic* value_semantic_ptr;
protected:
::boost::program_options::typed_value<T>* _dtor;
public:
Arg(T* storage = NULL) : _dtor(new ::boost::program_options::typed_value<T>(storage)){};
virtual ~Arg() {} // we do not delete _dtor since it's destroyed
//when the ::boost::program_options::options_description container is destroyed
//
// cast operator
virtual operator value_semantic_ptr() const {
return this->_dtor;
};
// forwarding methods
Arg& DEFAULT(const T& v) {
this->_dtor->default_value(v);
return *this;
};
Arg& IS_MULTIPLACED() {// may be defined in multiple places on the command line
this->_dtor->composing();
return *this;
};
Arg& IS_A_FLAG() { // no value expected
this->_dtor->zero_token();
return *this;
};
Arg& IS_A_LIST() {// multiple tokens per value
this->_dtor->multi_token();
return *this;
};
};// struct Arg
//
// The return type of ArgDB dereference:
// ArgValue val = argDB["arg"];
// ArgValue val can be cast to the type compatible with Arg<T>,
// if the following description of "arg" was used:
// argDB("arg", "arg help", Arg<T>);
//
struct ArgValue : ::boost::program_options::variable_value {
typedef ::boost::program_options::variable_value super;
public:
ArgValue(const super& val) : super(val) {};
// cast
template<typename T>
operator const T&() {
return super::as<T>();
}
//
template<typename T>
operator T& () {
return super::as<T>();
}
};// struct ArgValue
//
class ArgDB : public ::boost::program_options::variables_map {
protected:
typedef ::boost::program_options::variables_map super;
string _name;
ALE::Obj< ::boost::program_options::options_description> _descs;
public:
// Basic
ArgDB(const string& name) :
_name(name), _descs(new ::boost::program_options::options_description(name))
{};
//
ArgDB(const ArgDB& argDB, int argc, char **argv) :
_name(argDB.name()),_descs(new ::boost::program_options::options_description(_name))
{
(*this)(argDB);
this->parse(argc,argv);
};
// Printing
friend std::ostream& operator<<(std::ostream& os, const ArgDB& argDB) {
os << *(argDB._descs) << "\n";
return os;
}
// Main
//
ArgDB& operator()(const ArgDB& argDB) {
this->_descs->add(*(argDB._descs));
return *this;
};
//
ArgDB& operator()(const string& name, const string& helpLine) {
this->_descs->add_options()(name.c_str(), helpLine.c_str());
return *this;
};
ArgDB& operator()(const string& name, const string& helpLine, const AnyArg& descriptor) {
this->_descs->add_options()(name.c_str(), descriptor, helpLine.c_str());
return *this;
};
ArgDB& operator()(const string& name, const AnyArg& descriptor) {
this->_descs->add_options()(name.c_str(), descriptor);
return *this;
};
//
ArgDB& parse(int argc, char **argv) {
::boost::program_options::basic_command_line_parser<char> parser(argc, argv);
#if BOOST_VERSION >= 103300 // works beginning from Boost V1.33.0
parser.allow_unregistered().options(*(this->_descs));
#endif
::boost::program_options::store(parser.run(), *this);
return *this;
};
//
ArgValue operator[](const string& str) const {return super::operator[](str);};
//
// Aux
//
const string& name() const {return this->_name;};
//
ArgDB& rename(const string& name) {
this->_name = name;
Obj< ::boost::program_options::options_description> tmp = this->_descs;
this->_descs = new ::boost::program_options::options_description(name);
this->_descs->add(tmp);
return *this;
};
};// class ArgDB
} // namespace ALE
#endif
|