The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SWOptionFilter Class Referenceabstract

#include <swoptfilter.h>

+ Inheritance diagram for SWOptionFilter:
+ Collaboration diagram for SWOptionFilter:

Public Member Functions

virtual const char * getHeader () const
 
virtual const char * getOptionName ()
 
virtual const char * getOptionTip ()
 
virtual const char * getOptionValue ()
 
virtual StringList getOptionValues ()
 
bool isBoolean ()
 
virtual char processText (SWBuf &text, const SWKey *key=0, const SWModule *module=0)=0
 
virtual void setOptionValue (const char *ival)
 
 SWOptionFilter ()
 
 SWOptionFilter (const char *oName, const char *oTip, const StringList *oValues)
 
virtual ~SWOptionFilter ()
 

Protected Attributes

bool isBooleanVal
 
bool option
 
SWBuf optionValue
 
const char * optName
 
const char * optTip
 
const StringListoptValues
 

Detailed Description

Base class for all option filters.

Definition at line 47 of file swoptfilter.h.

Constructor & Destructor Documentation

SWORD_NAMESPACE_START SWOptionFilter::SWOptionFilter ( )

Definition at line 30 of file swoptfilter.cpp.

30  {
31  static StringList empty;
32  static const char *empty2 = "";
33  optName = empty2;
34  optTip = empty2;
35  optValues = &empty;
36 }
std::list< SWBuf > StringList
Definition: swmodule.cpp:91
const char * optName
Definition: swoptfilter.h:51
const char * optTip
Definition: swoptfilter.h:52
const StringList * optValues
Definition: swoptfilter.h:53
SWOptionFilter::SWOptionFilter ( const char *  oName,
const char *  oTip,
const StringList oValues 
)

Definition at line 39 of file swoptfilter.cpp.

39  {
40  optName = oName;
41  optTip = oTip;
43  if (optValues->begin() != optValues->end()) setOptionValue(*(optValues->begin()));
44  isBooleanVal = optValues->size() == 2 && (optionValue == "On" || optionValue == "Off");
45 }
static const StringList * oValues()
SWBuf optionValue
Definition: swoptfilter.h:50
static const char oName[]
const char * optName
Definition: swoptfilter.h:51
static const char oTip[]
virtual void setOptionValue(const char *ival)
Definition: swoptfilter.cpp:52
const char * optTip
Definition: swoptfilter.h:52
const StringList * optValues
Definition: swoptfilter.h:53
SWOptionFilter::~SWOptionFilter ( )
virtual

Definition at line 48 of file swoptfilter.cpp.

48  {
49 }

Member Function Documentation

virtual const char* SWFilter::getHeader ( ) const
inlinevirtualinherited

This method can supply a header associated with the processing done with this filter. A typical example is a suggested CSS style block for classed containers.

Reimplemented in OSISLaTeX, OSISXHTML, ThMLLaTeX, ThMLXHTML, TEIXHTML, GBFLaTeX, and GBFXHTML.

Definition at line 62 of file swfilter.h.

62 { return ""; }
virtual const char* SWOptionFilter::getOptionName ( )
inlinevirtual

gets the name of the option of this filter

Returns
option name

Reimplemented in UTF8Transliterator.

Definition at line 72 of file swoptfilter.h.

72 { return optName; }
const char * optName
Definition: swoptfilter.h:51
virtual const char* SWOptionFilter::getOptionTip ( )
inlinevirtual

gets a short explanation of the option of this filter; it could be presented to the user in frontend programs

Returns
option tip/explanation

Reimplemented in UTF8Transliterator.

Definition at line 78 of file swoptfilter.h.

78 { return optTip; }
const char * optTip
Definition: swoptfilter.h:52
const char * SWOptionFilter::getOptionValue ( )
virtual
Returns
The value of the current option.

Reimplemented in UTF8Transliterator.

Definition at line 62 of file swoptfilter.cpp.

62  {
63  return optionValue;
64 }
SWBuf optionValue
Definition: swoptfilter.h:50
virtual StringList SWOptionFilter::getOptionValues ( )
inlinevirtual

returns a list of the possible option values

Returns
list of option values

Reimplemented in UTF8Transliterator.

Definition at line 84 of file swoptfilter.h.

84 { return *optValues; }
const StringList * optValues
Definition: swoptfilter.h:53
bool SWOptionFilter::isBoolean ( )
inline

many options are simple Off/On boolean type, and frontends may wish to show these with checkmarks or the like to the end user. This is a convenience method to allow a frontend to check if this filter has only Off/On values

Definition at line 67 of file swoptfilter.h.

67 { return isBooleanVal; }
void SWOptionFilter::setOptionValue ( const char *  ival)
virtual

sets the value of the option of this filter, e.g maybe a strong's filter might be set to "On" / "Off" - that would mean to show or not to show the strongs in the text, see also getOptionValues()

Parameters
ivalthe new option value

Reimplemented in UTF8Transliterator.

Definition at line 52 of file swoptfilter.cpp.

52  {
53  for (StringList::const_iterator loop = optValues->begin(); loop != optValues->end(); loop++) {
54  if (!stricmp(loop->c_str(), ival)) {
55  optionValue = *loop;
56  option = (!strnicmp(ival, "On", 2)); // convenience for boolean filters
57  break;
58  }
59  }
60 }
int stricmp(const char *s1, const char *s2)
Definition: utilstr.cpp:194
SWBuf optionValue
Definition: swoptfilter.h:50
int strnicmp(const char *s1, const char *s2, int len)
Definition: utilstr.cpp:180
const StringList * optValues
Definition: swoptfilter.h:53

Member Data Documentation

bool SWOptionFilter::isBooleanVal
protected

Definition at line 55 of file swoptfilter.h.

bool SWOptionFilter::option
protected

Definition at line 54 of file swoptfilter.h.

SWBuf SWOptionFilter::optionValue
protected

Definition at line 50 of file swoptfilter.h.

const char* SWOptionFilter::optName
protected

Definition at line 51 of file swoptfilter.h.

const char* SWOptionFilter::optTip
protected

Definition at line 52 of file swoptfilter.h.

const StringList* SWOptionFilter::optValues
protected

Definition at line 53 of file swoptfilter.h.


The documentation for this class was generated from the following files: