The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
swoptfilter.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * swoptfilter.cpp - SWFilter descendant and base class for all option
4  * filters
5  *
6  * $Id: swoptfilter.cpp 2980 2013-09-14 21:51:47Z scribe $
7  *
8  * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
9  * CrossWire Bible Society
10  * P. O. Box 2528
11  * Tempe, AZ 85280-2528
12  *
13  * This program is free software; you can redistribute it and/or modify it
14  * under the terms of the GNU General Public License as published by the
15  * Free Software Foundation version 2.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * General Public License for more details.
21  *
22  */
23 
24 #include <swoptfilter.h>
25 #include <utilstr.h>
26 
28 
29 
31  static StringList empty;
32  static const char *empty2 = "";
33  optName = empty2;
34  optTip = empty2;
35  optValues = &empty;
36 }
37 
38 
39 SWOptionFilter::SWOptionFilter(const char *oName, const char *oTip, const StringList *oValues) {
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 }
46 
47 
49 }
50 
51 
52 void SWOptionFilter::setOptionValue(const char *ival) {
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 }
61 
63  return optionValue;
64 }
65 
66 
#define SWORD_NAMESPACE_START
Definition: defs.h:39
static const StringList * oValues()
int stricmp(const char *s1, const char *s2)
Definition: utilstr.cpp:194
SWBuf optionValue
Definition: swoptfilter.h:50
std::list< SWBuf > StringList
Definition: swmodule.cpp:91
static const char oName[]
const char * optName
Definition: swoptfilter.h:51
static const char oTip[]
int strnicmp(const char *s1, const char *s2, int len)
Definition: utilstr.cpp:180
virtual void setOptionValue(const char *ival)
Definition: swoptfilter.cpp:52
const char * optTip
Definition: swoptfilter.h:52
const StringList * optValues
Definition: swoptfilter.h:53
#define SWORD_NAMESPACE_END
Definition: defs.h:40
virtual const char * getOptionValue()
Definition: swoptfilter.cpp:62
virtual ~SWOptionFilter()
Definition: swoptfilter.cpp:48