aboutsummaryrefslogblamecommitdiffstats
path: root/doc/api-documentation/html/gbfhtmlhref_8cpp-source.html
blob: 07a0d60b6d41f9de8351a8b4f64d08c60743a445 (plain) (tree)

































































































































































                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
<!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>gbfhtmlhref.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>gbfhtmlhref.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/***************************************************************************</font>
00002 <font class="comment">                          gbfhtmlhref.cpp  -   GBF to HTML filter with hrefs </font>
00003 <font class="comment">                                for strongs and morph tags</font>
00004 <font class="comment">                             -------------------</font>
00005 <font class="comment">    begin                    : 2001-09-03</font>
00006 <font class="comment">    copyright            : 2001 by CrossWire Bible Society</font>
00007 <font class="comment"> ***************************************************************************/</font>
00008 
00009 <font class="comment">/***************************************************************************</font>
00010 <font class="comment"> *                                                                         *</font>
00011 <font class="comment"> *   This program is free software; you can redistribute it and/or modify  *</font>
00012 <font class="comment"> *   it under the terms of the GNU General Public License as published by  *</font>
00013 <font class="comment"> *   the Free Software Foundation; either version 2 of the License, or     *</font>
00014 <font class="comment"> *   (at your option) any later version.                                   *</font>
00015 <font class="comment"> *                                                                         *</font>
00016 <font class="comment"> ***************************************************************************/</font>
00017 
00018 <font class="preprocessor">#include &lt;stdlib.h&gt;</font>
00019 <font class="preprocessor">#include &lt;string.h&gt;</font>
00020 <font class="preprocessor">#include &lt;gbfhtmlhref.h&gt;</font>
00021 
00022 GBFHTMLHREF::GBFHTMLHREF() {
00023         setTokenStart(<font class="stringliteral">"&lt;"</font>);
00024         setTokenEnd(<font class="stringliteral">"&gt;"</font>);
00025         
00026         setTokenCaseSensitive(<font class="keyword">true</font>);
00027 
00028         addTokenSubstitute(<font class="stringliteral">"Rf"</font>, <font class="stringliteral">")&lt;/small&gt;&lt;/font&gt;"</font>);
00029         addTokenSubstitute(<font class="stringliteral">"Rx"</font>, <font class="stringliteral">"&lt;/a&gt;"</font>);
00030         addTokenSubstitute(<font class="stringliteral">"FI"</font>, <font class="stringliteral">"&lt;i&gt;"</font>); <font class="comment">// italics begin</font>
00031         addTokenSubstitute(<font class="stringliteral">"Fi"</font>, <font class="stringliteral">"&lt;/i&gt;"</font>);
00032         addTokenSubstitute(<font class="stringliteral">"FB"</font>, <font class="stringliteral">"&lt;n&gt;"</font>); <font class="comment">// bold begin</font>
00033         addTokenSubstitute(<font class="stringliteral">"Fb"</font>, <font class="stringliteral">"&lt;/n&gt;"</font>);
00034         addTokenSubstitute(<font class="stringliteral">"FR"</font>, <font class="stringliteral">"&lt;font color=\"#FF0000\"&gt;"</font>); <font class="comment">// words of Jesus begin</font>
00035         addTokenSubstitute(<font class="stringliteral">"Fr"</font>, <font class="stringliteral">"&lt;/font&gt;"</font>);
00036         addTokenSubstitute(<font class="stringliteral">"FU"</font>, <font class="stringliteral">"&lt;u&gt;"</font>); <font class="comment">// underline begin</font>
00037         addTokenSubstitute(<font class="stringliteral">"Fu"</font>, <font class="stringliteral">"&lt;/u&gt;"</font>);
00038         addTokenSubstitute(<font class="stringliteral">"FO"</font>, <font class="stringliteral">"&lt;cite&gt;"</font>); <font class="comment">//  Old Testament quote begin</font>
00039         addTokenSubstitute(<font class="stringliteral">"Fo"</font>, <font class="stringliteral">"&lt;/cite&gt;"</font>);
00040         addTokenSubstitute(<font class="stringliteral">"FS"</font>, <font class="stringliteral">"&lt;sup&gt;"</font>); <font class="comment">// Superscript begin// Subscript begin</font>
00041         addTokenSubstitute(<font class="stringliteral">"Fs"</font>, <font class="stringliteral">"&lt;/sup&gt;"</font>);
00042         addTokenSubstitute(<font class="stringliteral">"FV"</font>, <font class="stringliteral">"&lt;sub&gt;"</font>); <font class="comment">// Subscript begin</font>
00043         addTokenSubstitute(<font class="stringliteral">"Fv"</font>, <font class="stringliteral">"&lt;/sub&gt;"</font>);
00044         addTokenSubstitute(<font class="stringliteral">"TT"</font>, <font class="stringliteral">"&lt;big&gt;"</font>); <font class="comment">// Book title begin</font>
00045         addTokenSubstitute(<font class="stringliteral">"Tt"</font>, <font class="stringliteral">"&lt;/big&gt;"</font>);
00046         addTokenSubstitute(<font class="stringliteral">"PP"</font>, <font class="stringliteral">"&lt;cite&gt;"</font>); <font class="comment">//  poetry  begin</font>
00047         addTokenSubstitute(<font class="stringliteral">"Pp"</font>, <font class="stringliteral">"&lt;/cite&gt;"</font>);
00048         addTokenSubstitute(<font class="stringliteral">"Fn"</font>, <font class="stringliteral">"&lt;/font&gt;"</font>); <font class="comment">//  font  end</font>
00049         addTokenSubstitute(<font class="stringliteral">"CL"</font>, <font class="stringliteral">"&lt;br /&gt;"</font>); <font class="comment">//  new line</font>
00050         addTokenSubstitute(<font class="stringliteral">"CM"</font>, <font class="stringliteral">"&lt;!P&gt;&lt;br /&gt;"</font>); <font class="comment">//  paragraph &lt;!P&gt; is a non showing comment that can be changed in the front end to &lt;P&gt; if desired</font>
00051         addTokenSubstitute(<font class="stringliteral">"CG"</font>, <font class="stringliteral">""</font>); <font class="comment">//  ???</font>
00052         addTokenSubstitute(<font class="stringliteral">"CT"</font>, <font class="stringliteral">""</font>); <font class="comment">// ???</font>
00053         addTokenSubstitute(<font class="stringliteral">"JR"</font>, <font class="stringliteral">"&lt;div align=\"right\"&gt;"</font>); <font class="comment">// right align begin</font>
00054         addTokenSubstitute(<font class="stringliteral">"JC"</font>, <font class="stringliteral">"&lt;div align=\"center\"&gt;"</font>); <font class="comment">// center align begin</font>
00055         addTokenSubstitute(<font class="stringliteral">"JL"</font>, <font class="stringliteral">"&lt;/div&gt;"</font>); <font class="comment">// align end</font>
00056         
00057 }
00058 
00059 
<a name="l00060"></a><a class="code" href="class_g_b_f_h_t_m_l_h_r_e_f.html#b0">00060</a> <font class="keywordtype">bool</font> <a class="code" href="class_g_b_f_h_t_m_l_h_r_e_f.html#b0">GBFHTMLHREF::handleToken</a>(<font class="keywordtype">char</font> **buf, <font class="keyword">const</font> <font class="keywordtype">char</font> *token, DualStringMap &amp;userData) {
00061         <font class="keyword">const</font> <font class="keywordtype">char</font> *tok;
00062 
00063         <font class="keywordflow">if</font> (!substituteToken(buf, token)) {
00064                 <font class="keywordflow">if</font> (!strncmp(token, <font class="stringliteral">"WG"</font>, 2) || !strncmp(token, <font class="stringliteral">"WH"</font>, 2)) { <font class="comment">// strong's numbers</font>
00065                         <a class="code" href="class_s_w_basic_filter.html#b12">pushString</a>(buf, <font class="stringliteral">" &lt;small&gt;&lt;em&gt;&amp;lt;&lt;a href=\"#"</font>);
00066                         <font class="keywordflow">for</font> (tok = token+1; *tok; tok++)
00067                                 <font class="comment">//if(token[i] != '\"')</font>
00068                                         *(*buf)++ = *tok;
00069                         *(*buf)++ = <font class="charliteral">'\"'</font>;
00070                         *(*buf)++ = <font class="charliteral">'&gt;'</font>;
00071                         <font class="keywordflow">for</font> (tok = token + 2; *tok; tok++)
00072                                 <font class="comment">//if(token[i] != '\"')</font>
00073                                         *(*buf)++ = *tok;
00074                         <a class="code" href="class_s_w_basic_filter.html#b12">pushString</a>(buf, <font class="stringliteral">"&lt;/a&gt;&amp;gt;&lt;/em&gt;&lt;/small&gt;"</font>);
00075                 }
00076 
00077                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (!strncmp(token, <font class="stringliteral">"WTG"</font>, 3) || !strncmp(token, <font class="stringliteral">"WTH"</font>, 3)) { <font class="comment">// strong's numbers tense</font>
00078                         <a class="code" href="class_s_w_basic_filter.html#b12">pushString</a>(buf, <font class="stringliteral">" &lt;small&gt;&lt;em&gt;(&lt;A HREF=\"#"</font>);
00079                         <font class="keywordflow">for</font> (tok = token + 2; *tok; tok++)
00080                                 <font class="keywordflow">if</font>(*tok != <font class="charliteral">'\"'</font>)
00081                                         *(*buf)++ = *tok;
00082                         *(*buf)++ = <font class="charliteral">'\"'</font>;
00083                         *(*buf)++ = <font class="charliteral">'&gt;'</font>;
00084                         <font class="keywordflow">for</font> (tok = token + 3; *tok; tok++)
00085                                 <font class="keywordflow">if</font>(*tok != <font class="charliteral">'\"'</font>)
00086                                         *(*buf)++ = *tok;
00087                         <a class="code" href="class_s_w_basic_filter.html#b12">pushString</a>(buf, <font class="stringliteral">"&lt;/a&gt;)&lt;/em&gt;&lt;/small&gt;"</font>);
00088                 }
00089 
00090                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (!strncmp(token, <font class="stringliteral">"WT"</font>, 2) &amp;&amp; strncmp(token, <font class="stringliteral">"WTH"</font>, 3) &amp;&amp; strncmp(token, <font class="stringliteral">"WTG"</font>, 3)) { <font class="comment">// morph tags</font>
00091                         <a class="code" href="class_s_w_basic_filter.html#b12">pushString</a>(buf, <font class="stringliteral">" &lt;small&gt;&lt;em&gt;(&lt;a href=\"M"</font>);
00092                         <font class="keywordflow">for</font> (tok = token + 2; *tok; tok++)
00093                                 <font class="keywordflow">if</font>(*tok != <font class="charliteral">'\"'</font>)
00094                                         *(*buf)++ = *tok;
00095                         *(*buf)++ = <font class="charliteral">'\"'</font>;
00096                         *(*buf)++ = <font class="charliteral">'&gt;'</font>;
00097                         <font class="keywordflow">for</font> (tok = token + 2; *tok; tok++)                              
00098                                 <font class="keywordflow">if</font>(*tok != <font class="charliteral">'\"'</font>)                        
00099                                         *(*buf)++ = *tok;               
00100                         <a class="code" href="class_s_w_basic_filter.html#b12">pushString</a>(buf, <font class="stringliteral">"&lt;/a&gt;)&lt;/em&gt;&lt;/small&gt;"</font>);
00101                 }
00102 
00103                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (!strncmp(token, <font class="stringliteral">"RX"</font>, 2)) {
00104                         <a class="code" href="class_s_w_basic_filter.html#b12">pushString</a>(buf, <font class="stringliteral">"&lt;a href=\""</font>);
00105                         <font class="keywordflow">for</font> (tok = token + 3; *tok; tok++) {
00106                           <font class="keywordflow">if</font>(*tok != <font class="charliteral">'&lt;'</font> &amp;&amp; *tok+1 != <font class="charliteral">'R'</font> &amp;&amp; *tok+2 != <font class="charliteral">'x'</font>) {
00107                             *(*buf)++ = *tok;
00108                           }
00109                           <font class="keywordflow">else</font> {
00110                             <font class="keywordflow">break</font>;
00111                           }
00112                         }
00113                         *(*buf)++ = <font class="charliteral">'\"'</font>;
00114                         *(*buf)++ = <font class="charliteral">'&gt;'</font>;
00115                 }
00116 
00117                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (!strncmp(token, <font class="stringliteral">"RB"</font>, 2)) {
00118                         <a class="code" href="class_s_w_basic_filter.html#b12">pushString</a>(buf, <font class="stringliteral">"&lt;i&gt;"</font>);
00119                         userData[<font class="stringliteral">"hasFootnotePreTag"</font>] = <font class="stringliteral">"true"</font>;
00120                 }
00121 
00122                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (!strncmp(token, <font class="stringliteral">"RF"</font>, 2)) {
00123                         <font class="keywordflow">if</font>(userData[<font class="stringliteral">"hasFootnotePreTag"</font>] == <font class="stringliteral">"true"</font>) {
00124                                 userData[<font class="stringliteral">"hasFootnotePreTag"</font>] = <font class="stringliteral">"false"</font>;
00125                                 <a class="code" href="class_s_w_basic_filter.html#b12">pushString</a>(buf, <font class="stringliteral">"&lt;/i&gt; "</font>);
00126                         }
00127                         <a class="code" href="class_s_w_basic_filter.html#b12">pushString</a>(buf, <font class="stringliteral">"&lt;font color=\"#800000\"&gt;&lt;small&gt; ("</font>);
00128                 }
00129 
00130                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (!strncmp(token, <font class="stringliteral">"FN"</font>, 2)) {
00131                         <a class="code" href="class_s_w_basic_filter.html#b12">pushString</a>(buf, <font class="stringliteral">"&lt;font face=\""</font>);
00132                         <font class="keywordflow">for</font> (tok = token + 2; *tok; tok++)                              
00133                                 <font class="keywordflow">if</font>(*tok != <font class="charliteral">'\"'</font>)                        
00134                                         *(*buf)++ = *tok;
00135                         *(*buf)++ = <font class="charliteral">'\"'</font>;
00136                         *(*buf)++ = <font class="charliteral">'&gt;'</font>;
00137                 }
00138 
00139                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (!strncmp(token, <font class="stringliteral">"CA"</font>, 2)) {    <font class="comment">// ASCII value</font>
00140                         *(*buf)++ = (char)atoi(&amp;token[2]);
00141                 }
00142                 
00143                 <font class="keywordflow">else</font> {
00144                         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00145                 }
00146         }
00147         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00148 }
</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:12:59 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>