<!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>rawcom.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> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </center> <hr><h1>rawcom.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font> 00002 <font class="comment"> * rawcom.cpp - code for class 'RawCom'- a module that reads raw commentary</font> 00003 <font class="comment"> * files: ot and nt using indexs ??.bks ??.cps ??.vss</font> 00004 <font class="comment"> */</font> 00005 00006 00007 <font class="preprocessor">#include <ctype.h></font> 00008 <font class="preprocessor">#include <stdio.h></font> 00009 <font class="preprocessor">#include <fcntl.h></font> 00010 00011 <font class="preprocessor">#ifndef __GNUC__</font> 00012 <font class="preprocessor"></font><font class="preprocessor">#include <io.h></font> 00013 <font class="preprocessor">#else</font> 00014 <font class="preprocessor"></font><font class="preprocessor">#include <unistd.h></font> 00015 <font class="preprocessor">#endif</font> 00016 <font class="preprocessor"></font> 00017 <font class="preprocessor">#include <string.h></font> 00018 <font class="preprocessor">#include <utilfuns.h></font> 00019 <font class="preprocessor">#include <rawverse.h></font> 00020 <font class="preprocessor">#include <rawcom.h></font> 00021 00022 00023 <font class="comment">/******************************************************************************</font> 00024 <font class="comment"> * RawCom Constructor - Initializes data for instance of RawCom</font> 00025 <font class="comment"> *</font> 00026 <font class="comment"> * ENT: iname - Internal name for module</font> 00027 <font class="comment"> * idesc - Name to display to user for module</font> 00028 <font class="comment"> * idisp - Display object to use for displaying</font> 00029 <font class="comment"> */</font> 00030 00031 RawCom::RawCom(<font class="keyword">const</font> <font class="keywordtype">char</font> *ipath, <font class="keyword">const</font> <font class="keywordtype">char</font> *iname, <font class="keyword">const</font> <font class="keywordtype">char</font> *idesc, <a class="code" href="class_s_w_display.html">SWDisplay</a> *idisp, SWTextEncoding encoding, SWTextDirection dir, SWTextMarkup markup, <font class="keyword">const</font> <font class="keywordtype">char</font>* ilang) 00032 : RawVerse(ipath), 00033 <a class="code" href="class_s_w_com.html">SWCom</a>(iname, idesc, idisp, encoding, dir, markup, ilang){ 00034 } 00035 00036 00037 <font class="comment">/******************************************************************************</font> 00038 <font class="comment"> * RawCom Destructor - Cleans up instance of RawCom</font> 00039 <font class="comment"> */</font> 00040 00041 RawCom::~RawCom() 00042 { 00043 } 00044 00045 00046 <font class="comment">/******************************************************************************</font> 00047 <font class="comment"> * RawCom::operator char * - Returns the correct verse when char * cast</font> 00048 <font class="comment"> * is requested</font> 00049 <font class="comment"> *</font> 00050 <font class="comment"> * RET: string buffer with verse</font> 00051 <font class="comment"> */</font> 00052 00053 <font class="keywordtype">char</font> *RawCom::getRawEntry() { 00054 <font class="keywordtype">long</font> start = 0; 00055 <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> size = 0; 00056 <a class="code" href="class_verse_key.html">VerseKey</a> *key = 0; 00057 00058 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00059 <font class="preprocessor"></font> <font class="keywordflow">try</font> { 00060 <font class="preprocessor">#endif</font> 00061 <font class="preprocessor"></font> key = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, this->key); 00062 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00063 <font class="preprocessor"></font> } 00064 <font class="keywordflow">catch</font> ( ... ) {} 00065 <font class="preprocessor">#endif</font> 00066 <font class="preprocessor"></font> <font class="keywordflow">if</font> (!key) 00067 key = <font class="keyword">new</font> <a class="code" href="class_verse_key.html">VerseKey</a>(this->key); 00068 00069 00070 findoffset(key-><a class="code" href="class_verse_key.html#a22">Testament</a>(), key-><a class="code" href="class_verse_key.html#a34">Index</a>(), &start, &size); 00071 entrySize = size; <font class="comment">// support getEntrySize call</font> 00072 00073 <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> newsize = (size + 2) * FILTERPAD; 00074 <font class="keywordflow">if</font> (newsize > entrybufallocsize) { 00075 <font class="keywordflow">if</font> (entrybuf) 00076 <font class="keyword">delete</font> [] entrybuf; 00077 entrybuf = <font class="keyword">new</font> <font class="keywordtype">char</font> [ newsize ]; 00078 entrybufallocsize = newsize; 00079 } 00080 *entrybuf = 0; 00081 00082 gettext(key-><a class="code" href="class_verse_key.html#a22">Testament</a>(), start, (size + 2), entrybuf); 00083 00084 rawFilter(entrybuf, size, key); 00085 00086 <font class="keywordflow">if</font> (!isUnicode()) 00087 preptext(entrybuf); 00088 00089 <font class="keywordflow">if</font> (key != this->key) 00090 <font class="keyword">delete</font> key; 00091 00092 <font class="keywordflow">return</font> entrybuf; 00093 } 00094 00095 00096 <font class="comment">/******************************************************************************</font> 00097 <font class="comment"> * RawCom::operator += - Increments module key a number of entries</font> 00098 <font class="comment"> *</font> 00099 <font class="comment"> * ENT: increment - Number of entries to jump forward</font> 00100 <font class="comment"> *</font> 00101 <font class="comment"> * RET: *this</font> 00102 <font class="comment"> */</font> 00103 00104 <a class="code" href="class_s_w_module.html">SWModule</a> &RawCom::operator +=(<font class="keywordtype">int</font> increment) 00105 { 00106 <font class="keywordtype">long</font> start; 00107 <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> size; 00108 <a class="code" href="class_verse_key.html">VerseKey</a> *tmpkey = 0; 00109 00110 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00111 <font class="preprocessor"></font> <font class="keywordflow">try</font> { 00112 <font class="preprocessor">#endif</font> 00113 <font class="preprocessor"></font> tmpkey = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, key); 00114 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00115 <font class="preprocessor"></font> } 00116 <font class="keywordflow">catch</font> ( ... ) {} 00117 <font class="preprocessor">#endif</font> 00118 <font class="preprocessor"></font> <font class="keywordflow">if</font> (!tmpkey) 00119 tmpkey = <font class="keyword">new</font> <a class="code" href="class_verse_key.html">VerseKey</a>(key); 00120 00121 findoffset(tmpkey-><a class="code" href="class_verse_key.html#a22">Testament</a>(), tmpkey-><a class="code" href="class_verse_key.html#a34">Index</a>(), &start, &size); 00122 00123 <a class="code" href="class_s_w_key.html">SWKey</a> lastgood = *tmpkey; 00124 <font class="keywordflow">while</font> (increment) { 00125 <font class="keywordtype">long</font> laststart = start; 00126 <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> lastsize = size; 00127 <a class="code" href="class_s_w_key.html">SWKey</a> lasttry = *tmpkey; 00128 (increment > 0) ? (*key)++ : (*key)--; 00129 <font class="keywordflow">if</font> (tmpkey != key) 00130 <font class="keyword">delete</font> tmpkey; 00131 tmpkey = 0; 00132 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00133 <font class="preprocessor"></font> <font class="keywordflow">try</font> { 00134 <font class="preprocessor">#endif</font> 00135 <font class="preprocessor"></font> tmpkey = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, key); 00136 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00137 <font class="preprocessor"></font> } 00138 <font class="keywordflow">catch</font> ( ... ) {} 00139 <font class="preprocessor">#endif</font> 00140 <font class="preprocessor"></font> <font class="keywordflow">if</font> (!tmpkey) 00141 tmpkey = <font class="keyword">new</font> <a class="code" href="class_verse_key.html">VerseKey</a>(key); 00142 00143 <font class="keywordflow">if</font> ((error = key->Error())) { 00144 *key = lastgood; 00145 <font class="keywordflow">break</font>; 00146 } 00147 <font class="keywordtype">long</font> index = tmpkey-><a class="code" href="class_s_w_key.html#a17">Index</a>(); 00148 findoffset(tmpkey->Testament(), index, &start, &size); 00149 <font class="keywordflow">if</font> ((((laststart != start) || (lastsize != size))||(!skipConsecutiveLinks)) && (start >= 0) && (size)) { 00150 increment += (increment < 0) ? 1 : -1; 00151 lastgood = *tmpkey; 00152 } 00153 } 00154 error = (error) ? KEYERR_OUTOFBOUNDS : 0; 00155 00156 <font class="keywordflow">if</font> (tmpkey != key) 00157 <font class="keyword">delete</font> tmpkey; 00158 00159 <font class="keywordflow">return</font> *<font class="keyword">this</font>; 00160 } 00161 00162 <a class="code" href="class_s_w_module.html">SWModule</a> &RawCom::setentry(<font class="keyword">const</font> <font class="keywordtype">char</font> *inbuf, <font class="keywordtype">long</font> len) { 00163 <a class="code" href="class_verse_key.html">VerseKey</a> *key = 0; 00164 <font class="comment">// see if we have a VerseKey * or decendant</font> 00165 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00166 <font class="preprocessor"></font> <font class="keywordflow">try</font> { 00167 <font class="preprocessor">#endif</font> 00168 <font class="preprocessor"></font> key = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, this->key); 00169 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00170 <font class="preprocessor"></font> } 00171 <font class="keywordflow">catch</font> ( ... ) {} 00172 <font class="preprocessor">#endif</font> 00173 <font class="preprocessor"></font> <font class="comment">// if we don't have a VerseKey * decendant, create our own</font> 00174 <font class="keywordflow">if</font> (!key) 00175 key = <font class="keyword">new</font> <a class="code" href="class_verse_key.html">VerseKey</a>(this->key); 00176 00177 settext(key-><a class="code" href="class_verse_key.html#a22">Testament</a>(), key-><a class="code" href="class_verse_key.html#a34">Index</a>(), inbuf, len); 00178 00179 <font class="keywordflow">if</font> (this->key != key) <font class="comment">// free our key if we created a VerseKey</font> 00180 <font class="keyword">delete</font> key; 00181 00182 <font class="keywordflow">return</font> *<font class="keyword">this</font>; 00183 } 00184 00185 <a class="code" href="class_s_w_module.html">SWModule</a> &RawCom::operator <<(<font class="keyword">const</font> <font class="keywordtype">char</font> *inbuf) { 00186 <a class="code" href="class_verse_key.html">VerseKey</a> *key = 0; 00187 <font class="comment">// see if we have a VerseKey * or decendant</font> 00188 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00189 <font class="preprocessor"></font> <font class="keywordflow">try</font> { 00190 <font class="preprocessor">#endif</font> 00191 <font class="preprocessor"></font> key = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, this->key); 00192 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00193 <font class="preprocessor"></font> } 00194 <font class="keywordflow">catch</font> ( ... ) {} 00195 <font class="preprocessor">#endif</font> 00196 <font class="preprocessor"></font> <font class="comment">// if we don't have a VerseKey * decendant, create our own</font> 00197 <font class="keywordflow">if</font> (!key) 00198 key = <font class="keyword">new</font> <a class="code" href="class_verse_key.html">VerseKey</a>(this->key); 00199 00200 settext(key-><a class="code" href="class_verse_key.html#a22">Testament</a>(), key-><a class="code" href="class_verse_key.html#a34">Index</a>(), inbuf); 00201 00202 <font class="keywordflow">if</font> (this->key != key) <font class="comment">// free our key if we created a VerseKey</font> 00203 <font class="keyword">delete</font> key; 00204 00205 <font class="keywordflow">return</font> *<font class="keyword">this</font>; 00206 } 00207 00208 00209 <a class="code" href="class_s_w_module.html">SWModule</a> &RawCom::operator <<(<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> *inkey) { 00210 <a class="code" href="class_verse_key.html">VerseKey</a> *destkey = 0; 00211 <font class="keyword">const</font> <a class="code" href="class_verse_key.html">VerseKey</a> *srckey = 0; 00212 <font class="comment">// see if we have a VerseKey * or decendant</font> 00213 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00214 <font class="preprocessor"></font> <font class="keywordflow">try</font> { 00215 <font class="preprocessor">#endif</font> 00216 <font class="preprocessor"></font> destkey = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, this->key); 00217 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00218 <font class="preprocessor"></font> } 00219 <font class="keywordflow">catch</font> ( ... ) {} 00220 <font class="preprocessor">#endif</font> 00221 <font class="preprocessor"></font> <font class="comment">// if we don't have a VerseKey * decendant, create our own</font> 00222 <font class="keywordflow">if</font> (!destkey) 00223 destkey = <font class="keyword">new</font> <a class="code" href="class_verse_key.html">VerseKey</a>(this->key); 00224 00225 <font class="comment">// see if we have a VerseKey * or decendant</font> 00226 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00227 <font class="preprocessor"></font> <font class="keywordflow">try</font> { 00228 <font class="preprocessor">#endif</font> 00229 <font class="preprocessor"></font> srckey = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, inkey); 00230 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00231 <font class="preprocessor"></font> } 00232 <font class="keywordflow">catch</font> ( ... ) {} 00233 <font class="preprocessor">#endif</font> 00234 <font class="preprocessor"></font> <font class="comment">// if we don't have a VerseKey * decendant, create our own</font> 00235 <font class="keywordflow">if</font> (!srckey) 00236 srckey = <font class="keyword">new</font> <a class="code" href="class_verse_key.html">VerseKey</a>(inkey); 00237 00238 linkentry(destkey-><a class="code" href="class_verse_key.html#a22">Testament</a>(), destkey-><a class="code" href="class_verse_key.html#a34">Index</a>(), srckey-><a class="code" href="class_verse_key.html#a34">Index</a>()); 00239 00240 <font class="keywordflow">if</font> (this->key != destkey) <font class="comment">// free our key if we created a VerseKey</font> 00241 <font class="keyword">delete</font> destkey; 00242 00243 <font class="keywordflow">if</font> (inkey != srckey) <font class="comment">// free our key if we created a VerseKey</font> 00244 <font class="keyword">delete</font> srckey; 00245 00246 <font class="keywordflow">return</font> *<font class="keyword">this</font>; 00247 } 00248 00249 00250 <font class="comment">/******************************************************************************</font> 00251 <font class="comment"> * RawCom::deleteEntry - deletes this entry</font> 00252 <font class="comment"> *</font> 00253 <font class="comment"> * RET: *this</font> 00254 <font class="comment"> */</font> 00255 00256 <font class="keywordtype">void</font> RawCom::deleteEntry() { 00257 00258 <a class="code" href="class_verse_key.html">VerseKey</a> *key = 0; 00259 00260 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00261 <font class="preprocessor"></font> <font class="keywordflow">try</font> { 00262 <font class="preprocessor">#endif</font> 00263 <font class="preprocessor"></font> key = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, this->key); 00264 <font class="preprocessor">#ifndef _WIN32_WCE</font> 00265 <font class="preprocessor"></font> } 00266 <font class="keywordflow">catch</font> ( ... ) {} 00267 <font class="preprocessor">#endif</font> 00268 <font class="preprocessor"></font> <font class="keywordflow">if</font> (!key) 00269 key = <font class="keyword">new</font> <a class="code" href="class_verse_key.html">VerseKey</a>(this->key); 00270 00271 settext(key-><a class="code" href="class_verse_key.html#a22">Testament</a>(), key-><a class="code" href="class_verse_key.html#a34">Index</a>(), <font class="stringliteral">""</font>); 00272 00273 <font class="keywordflow">if</font> (key != this->key) 00274 <font class="keyword">delete</font> key; 00275 } </pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:13:00 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>