Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > a74ec78bdb789d910d054e3918f3f007 > files > 540

libsword1-devel-1.5.5-2mdk.ppc.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>thmlscripref.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </center>
<hr><h1>thmlscripref.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> *</font>
00003 <font class="comment"> * thmlscripref -       SWFilter decendant to hide or show scripture references</font>
00004 <font class="comment"> *                      in a ThML module.</font>
00005 <font class="comment"> */</font>
00006 
00007 
00008 <font class="preprocessor">#include &lt;stdlib.h&gt;</font>
00009 <font class="preprocessor">#include &lt;string.h&gt;</font>
00010 <font class="preprocessor">#include &lt;thmlscripref.h&gt;</font>
00011 <font class="preprocessor">#ifndef __GNUC__</font>
00012 <font class="preprocessor"></font><font class="preprocessor">#else</font>
00013 <font class="preprocessor"></font><font class="preprocessor">#include &lt;unixstr.h&gt;</font>
00014 <font class="preprocessor">#endif</font>
00015 <font class="preprocessor"></font>
00016 
00017 <font class="keyword">const</font> <font class="keywordtype">char</font> ThMLScripref::on[] = <font class="stringliteral">"On"</font>;
00018 <font class="keyword">const</font> <font class="keywordtype">char</font> ThMLScripref::off[] = <font class="stringliteral">"Off"</font>;
00019 <font class="keyword">const</font> <font class="keywordtype">char</font> ThMLScripref::optName[] = <font class="stringliteral">"Scripture Cross-references"</font>;
00020 <font class="keyword">const</font> <font class="keywordtype">char</font> ThMLScripref::optTip[] = <font class="stringliteral">"Toggles Scripture Cross-references On and Off if they exist"</font>;
00021 
00022 
00023 ThMLScripref::ThMLScripref() {
00024         option = <font class="keyword">false</font>;
00025         options.push_back(on);
00026         options.push_back(off);
00027 }
00028 
00029 
00030 ThMLScripref::~ThMLScripref() {
00031 }
00032 
00033 <font class="keywordtype">void</font> ThMLScripref::setOptionValue(<font class="keyword">const</font> <font class="keywordtype">char</font> *ival)
00034 {
00035         option = (!stricmp(ival, on));
00036 }
00037 
00038 <font class="keyword">const</font> <font class="keywordtype">char</font> *ThMLScripref::getOptionValue()
00039 {
00040         <font class="keywordflow">return</font> (option) ? on:off;
00041 }
00042 
00043 <font class="keywordtype">char</font> ThMLScripref::ProcessText(<font class="keywordtype">char</font> *text, <font class="keywordtype">int</font> maxlen, <font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> *key, <font class="keyword">const</font> <a class="code" href="class_s_w_module.html">SWModule</a> *module)
00044 {
00045         <font class="keywordflow">if</font> (!option) {  <font class="comment">// if we don't want scriprefs</font>
00046                 <font class="keywordtype">char</font> *to, *from, token[2048]; <font class="comment">// cheese.  Fix.</font>
00047                 <font class="keywordtype">int</font> tokpos = 0;
00048                 <font class="keywordtype">bool</font> intoken = <font class="keyword">false</font>;
00049                 <font class="keywordtype">int</font> len;
00050                 <font class="keywordtype">bool</font> hide = <font class="keyword">false</font>;
00051 
00052                 len = strlen(text) + 1; <font class="comment">// shift string to right of buffer</font>
00053                 <font class="keywordflow">if</font> (len &lt; maxlen) {
00054                         memmove(&amp;text[maxlen - len], text, len);
00055                         from = &amp;text[maxlen - len];
00056                 }
00057                 <font class="keywordflow">else</font>    from = text;    <font class="comment">// -------------------------------</font>
00058 
00059                 <font class="keywordflow">for</font> (to = text; *from; from++) {
00060                         <font class="keywordflow">if</font> (*from == <font class="charliteral">'&lt;'</font>) {
00061                                 intoken = <font class="keyword">true</font>;
00062                                 tokpos = 0;
00063                                 token[0] = 0;
00064                                 token[1] = 0;
00065                                 token[2] = 0;
00066                                 <font class="keywordflow">continue</font>;
00067                         }
00068                         <font class="keywordflow">if</font> (*from == <font class="charliteral">'&gt;'</font>) {     <font class="comment">// process tokens</font>
00069                                 intoken = <font class="keyword">false</font>;
00070                                 <font class="keywordflow">if</font> (!strnicmp(token, <font class="stringliteral">"scripRef"</font>, 8)) {
00071                                   hide = <font class="keyword">true</font>;
00072                                   <font class="keywordflow">continue</font>;
00073                                 }
00074                                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (!strnicmp(token, <font class="stringliteral">"/scripRef"</font>, 9)) {
00075                                   hide = <font class="keyword">false</font>;
00076                                   <font class="keywordflow">continue</font>;
00077                                 }
00078 
00079                                 <font class="comment">// if not a scripref token, keep token in text</font>
00080                                 <font class="keywordflow">if</font> (!hide) {
00081                                         *to++ = <font class="charliteral">'&lt;'</font>;
00082                                         <font class="keywordflow">for</font> (<font class="keywordtype">char</font> *tok = token; *tok; tok++)
00083                                                 *to++ = *tok;
00084                                         *to++ = <font class="charliteral">'&gt;'</font>;
00085                                 }
00086                                 <font class="keywordflow">continue</font>;
00087                         }
00088                         <font class="keywordflow">if</font> (intoken) {
00089                                 <font class="keywordflow">if</font> (tokpos &lt; 2045)
00090                                         token[tokpos++] = *from;
00091                                         token[tokpos+2] = 0;
00092                         }
00093                         <font class="keywordflow">else</font>    {
00094                                 <font class="keywordflow">if</font> (!hide) {
00095                                         *to++ = *from;
00096                                 }
00097                         }
00098                 }
00099                 *to++ = 0;
00100                 *to = 0;
00101         }
00102         <font class="keywordflow">return</font> 0;
00103 }
</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:13:01 2002 for The Sword Project by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>