/usr/include/pstoedit/poptions.h is in libpstoedit-dev 3.60-1build2.
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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | #ifndef _POPTIONS_H
#define _POPTIONS_H
/*
poptions.h : This file is part of pstoedit
program option handling
Copyright (C) 1993 - 2011 Wolfgang Glunz, wglunz35_AT_pstoedit.net
This program 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 2 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 this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef cppcomp_h
#include "cppcomp.h"
#endif
#include I_iostream
#include I_ostream
#include I_istream
USESTD
enum baseTypeIDs { int_ty, double_ty, bool_ty, char_ty };
class DLLEXPORT IntValueExtractor {
public:
static bool getvalue(const char *optname, const char *instring, unsigned int ¤targ, int &result);
static const char *gettypename() ;
static unsigned int gettypeID();
};
class DLLEXPORT DoubleValueExtractor {
public:
static bool getvalue(const char *optname, const char *instring, unsigned int ¤targ, double &result) ;
static const char *gettypename() ;
static unsigned int gettypeID();
};
class DLLEXPORT CharacterValueExtractor {
public:
static bool getvalue(const char *optname, const char *instring, unsigned int ¤targ, char &result) ;
static const char *gettypename() ;
static unsigned int gettypeID();
};
class DLLEXPORT BoolBaseExtractor {
public:
static const char *gettypename();
static unsigned int gettypeID();
};
//lint -esym(1790,BoolBaseExtractor)
class DLLEXPORT BoolInvertingExtractor : public BoolBaseExtractor {
public:
static bool getvalue(const char *optname, const char *instring, unsigned int ¤targ, bool &result) ;
};
class DLLEXPORT BoolFalseExtractor : public BoolBaseExtractor{
public:
static bool getvalue(const char *optname, const char *instring, unsigned int ¤targ, bool &result) ;
};
class DLLEXPORT BoolTrueExtractor : public BoolBaseExtractor{
public:
static bool getvalue(const char *optname, const char *instring, unsigned int ¤targ, bool &result);
};
class DLLEXPORT OptionBase {
public:
OptionBase(bool optional_p,const char *flag_p, const char *argname_p, int propsheet_p, const char *description_p, const char * TeXhelp_p):
flag(flag_p),
argname(argname_p),
propsheet(propsheet_p),
description(description_p),
TeXhelp(TeXhelp_p),
optional(optional_p),
membername(""){ // membername is set during "add" because it was simpler to grab the membername during the add
};
virtual ~OptionBase() { membername = 0; }
virtual ostream & writevalue(ostream & out) const = 0;
void toString(class RSString &) const;
virtual bool copyvalue(const char *optname, const char *valuestring, unsigned int ¤targ) = 0;
virtual bool copyvalue_simple(const char *valuestring) = 0;
// virtual bool copyvalue_simple(bool boolvalue) = 0;
virtual const char *gettypename() const = 0;
virtual unsigned int gettypeID() const = 0;
virtual void * GetAddrOfValue() = 0; // will return real type instead of void
//lint -esym(1540,OptionBase::flag) // not freed
//lint -esym(1540,OptionBase::description) // not freed
const char * const flag; // -bf
const char * const argname; // a meaningfull name of the argument (if not a boolean option)
int propsheet; // the number of the propertysheet to place this option on
const char * const description; // help text
const char * const TeXhelp;
bool optional;
const char * membername;
private:
OptionBase(); // disabled
OptionBase(const OptionBase&); // disabled
const OptionBase& operator=(const OptionBase&); // disabled
};
template <class ValueType, class ExtractorType >
class OptionT : public OptionBase {
public:
OptionT < ValueType, ExtractorType > (bool optional_p, const char *flag_p, const char *argname_p, int propsheet_p, const char *description_p, const char * TeXhelp_p, const ValueType & initialvalue) :
OptionBase(optional_p,flag_p, argname_p, propsheet_p, description_p,TeXhelp_p),
value(initialvalue) {
};
OptionT < ValueType, ExtractorType > (bool optional_p, const char *flag_p, const char *argname_p, int propsheet_p, const char *description_p, const char * TeXhelp_p ) :
OptionBase(optional_p,flag_p, argname_p, propsheet_p, description_p, TeXhelp_p)
{
//lint -esym(1401,*::value) // not initialized - we use the default ctor here
};
virtual ostream & writevalue(ostream & out) const;
virtual bool copyvalue(const char *optname, const char *valuestring, unsigned int ¤targ) {
return ExtractorType::getvalue(optname, valuestring, currentarg, value);
}
bool copyvalue_simple(const char *valuestring) {
unsigned int num = 0;
return copyvalue("no name because of copyvalue_simple",valuestring,num);
}
#if 0
bool copyvalue_simple(bool boolvalue ) {
// value = boolvalue;
// unsigned int num = 0;
// we cannot just use the "extractor" since that works like the option has given on the commandline
// but copyvalue_simple is called for all options - but that does not mean that all options are
// "put on the virtual commandline" - clear ?
// return copyvalue("no name because of copyvalue_simple","",num);
value = boolvalue;
return true; // wogl FIXME
}
#endif
virtual const char *gettypename() const {
return ExtractorType::gettypename();
}
virtual unsigned int gettypeID() const {
return ExtractorType::gettypeID();
}
//lint -save -esym(1539,OptionBase::optional) // not assigned a value
//lint -e(1763)
ValueType & operator()() { return value; }
const ValueType & operator()() const { return value; }
operator ValueType () const { return value; }
/* const ValueType & */ void operator =(const ValueType & arg) {
/* return */ value = arg;
//lint -esym(1539,OptionBase::propsheet) // not assigned in op=
//lint -esym(1539,OptionBase::membername) // not assigned in op=
} // cannot return a reference, because char*::operator= doesn't
//lint -restore
bool operator !=(const ValueType & arg) const { return value != arg; }
bool operator ==(const ValueType & arg) const { return value == arg; }
bool operator !() const { return !value ; }
virtual void * GetAddrOfValue() { return &value;}
ValueType value;
private:
OptionT();// disabled
OptionT(const OptionT&);// disabled
const OptionT& operator=(const OptionT&); // disabled
};
template <class ValueType, class ExtractorType >
ostream & OptionT<ValueType, ExtractorType>::writevalue(ostream & out) const {
out << value;
return out;
}
class DLLEXPORT ProgramOptions {
public:
ProgramOptions() : unhandledCounter(0), optcount(0) { unhandledOptions[0]=0;alloptions[0]=0; };
virtual ~ProgramOptions() {}
unsigned int parseoptions(ostream & outstr, unsigned int argc, const char * const*argv) ;
// unsigned int sheet: -1 indicates "all"
void showhelp(ostream & outstr, bool forTeX, bool withdescription, int sheet = -1) const ;
void dumpunhandled(ostream & outstr) const ;
void showvalues(ostream & outstr, bool withdescription = true) const ;
const OptionBase * const * getOptionConstIterator() const { return &alloptions[0]; }
OptionBase * const * getOptionIterator() const { return &alloptions[0]; }
unsigned int numberOfOptions() const { return optcount; }
virtual bool hideFromDoku(const OptionBase& /* opt */ ) const { return false; } // some options may be hidden, i.e. debug only options
protected:
void add(OptionBase * op, const char * const membername) ;
public:
unsigned int unhandledCounter;
const char *unhandledOptions[100];
private:
unsigned int optcount;
OptionBase *alloptions[100];
private:
ProgramOptions(const ProgramOptions&); // disabled
const ProgramOptions& operator =(const ProgramOptions&); // disabled
};
#endif
|