OSISVariants Class Reference

#include <osisvariants.h>

Inheritance diagram for OSISVariants:
Inheritance graph
[legend]
Collaboration diagram for OSISVariants:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual const char * getHeader () const
virtual const char * getOptionName ()
virtual const char * getOptionTip ()
virtual const char * getOptionValue ()
virtual StringList getOptionValues ()
 OSISVariants ()
virtual char processText (SWBuf &text, const SWKey *key=0, const SWModule *module=0)
virtual void setOptionValue (const char *ival)
virtual ~OSISVariants ()

Protected Attributes

SWBuf optionValue
const StringListoptValues

Private Attributes

char option
StringList options

Static Private Attributes

static const char all [] = "All Readings"
static const char optName [] = "Textual Variants"
static const char optTip [] = "Switch between Textual Variants modes"
static const char primary [] = "Primary Reading"
static const char secondary [] = "Secondary Reading"

Detailed Description

This Filter shows/hides textual variants

Definition at line 31 of file osisvariants.h.


Constructor & Destructor Documentation

OSISVariants::OSISVariants (  ) 

Definition at line 37 of file osisvariants.cpp.

00037                            {
00038     option = false;
00039     options.push_back(primary);
00040     options.push_back(secondary);
00041     options.push_back(all);
00042 }

OSISVariants::~OSISVariants (  )  [virtual]

Definition at line 45 of file osisvariants.cpp.

00045                             {
00046 }


Member Function Documentation

virtual const char* SWFilter::getHeader (  )  const [inline, virtual, inherited]

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 GBFXHTML, OSISXHTML, and ThMLXHTML.

Definition at line 58 of file swfilter.h.

00058 { return ""; }

virtual const char* OSISVariants::getOptionName (  )  [inline, virtual]

gets the name of the option of this filter

Returns:
option name

Reimplemented from SWOptionFilter.

Definition at line 46 of file osisvariants.h.

00046 { return optName; }

virtual const char* OSISVariants::getOptionTip (  )  [inline, virtual]

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 from SWOptionFilter.

Definition at line 47 of file osisvariants.h.

00047 { return optTip; }

const char * OSISVariants::getOptionValue (  )  [virtual]
Returns:
The value of the current option.

Reimplemented from SWOptionFilter.

Definition at line 55 of file osisvariants.cpp.

00056 {
00057         if (option == 0) {
00058             return primary;
00059     }
00060     else if (option == 1) {
00061             return secondary;
00062     }
00063     else {
00064             return all;
00065     }
00066 }

virtual StringList OSISVariants::getOptionValues (  )  [inline, virtual]

returns a list of the possible option values

Returns:
list of option values

Reimplemented from SWOptionFilter.

Definition at line 50 of file osisvariants.h.

00050 { return options; }

char OSISVariants::processText ( SWBuf text,
const SWKey key = 0,
const SWModule module = 0 
) [virtual]

This method processes and appropriately modifies the text given it for a particular filter task

Parameters:
text The text to be filtered/converted
key Current key That was used.
module Current module.
Returns:
0

Implements SWFilter.

Definition at line 68 of file osisvariants.cpp.

00069 {
00070         if (option == 0 || option == 1) { //we want primary or variant only
00071         bool intoken = false;
00072         bool hide = false;
00073         bool invar = false;
00074         
00075         SWBuf token;
00076         SWBuf orig = text;
00077         const char *from = orig.c_str();
00078 
00079         //we use a fixed comparision string to make sure the loop is as fast as the original two blocks with almost the same code
00080         //const char* variantCompareString = (option == 0) ? "div type=\"variant\" class=\"1\"" : "div type=\"variant\" class=\"2\"";
00081         
00082         for (text = ""; *from; from++) {
00083             if (*from == '<') {
00084                 intoken = true;
00085                 token = "";
00086                 continue;
00087             }
00088             else if (*from == '>') {    // process tokens
00089                 intoken = false;
00090                 
00091                 if (!strncmp(token.c_str(), "seg ", 4)) { //only one of the variants
00092                     invar = true;
00093                     hide = true;
00094                     continue;
00095                 }
00096                 if (!strncmp(token.c_str(), "div type=\"variant\"", 18)) {
00097                     invar = true;
00098                     continue;
00099                 }
00100                 if (!strncmp(token.c_str(), "/div", 4)) {
00101                     hide = false;
00102                     if (invar) {
00103                         invar = false;
00104                         continue;
00105                     }
00106                 }
00107                 if (!hide) {
00108                     text += '<';
00109                     text.append(token);
00110                     text += '>';
00111                 }
00112 
00113                 continue;
00114             }
00115             if (intoken) {
00116                 token += *from;
00117             }
00118             else if (!hide) {
00119                 text += *from;
00120             }
00121         }
00122 
00123     }
00124 
00125     return 0;
00126 }

void OSISVariants::setOptionValue ( const char *  ival  )  [virtual]

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

Parameters:
ival the new option value

Reimplemented from SWOptionFilter.

Definition at line 48 of file osisvariants.cpp.

00049 {
00050     if (!stricmp(ival, primary)) option = 0;
00051         else if (!stricmp(ival, secondary)) option = 1;
00052         else option = 2;
00053 }


Member Data Documentation

const char OSISVariants::all = "All Readings" [static, private]

Definition at line 36 of file osisvariants.h.

char OSISVariants::option [private]

Reimplemented from SWOptionFilter.

Definition at line 32 of file osisvariants.h.

Definition at line 40 of file osisvariants.h.

SWBuf SWOptionFilter::optionValue [protected, inherited]

Definition at line 40 of file swoptfilter.h.

const char OSISVariants::optName = "Textual Variants" [static, private]

Reimplemented from SWOptionFilter.

Definition at line 38 of file osisvariants.h.

const char OSISVariants::optTip = "Switch between Textual Variants modes" [static, private]

Reimplemented from SWOptionFilter.

Definition at line 39 of file osisvariants.h.

const StringList* SWOptionFilter::optValues [protected, inherited]

Definition at line 43 of file swoptfilter.h.

SWORD_NAMESPACE_START const char OSISVariants::primary = "Primary Reading" [static, private]

Definition at line 34 of file osisvariants.h.

const char OSISVariants::secondary = "Secondary Reading" [static, private]

Definition at line 35 of file osisvariants.h.


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

Generated on 18 Mar 2013 for The SWORD Project by  doxygen 1.6.1