aboutsummaryrefslogtreecommitdiffstats
path: root/doc/api-documentation/html/rawld_8cpp-source.html
diff options
context:
space:
mode:
authordanglassey <danglassey>2002-08-14 09:57:17 +0000
committerdanglassey <danglassey>2002-08-14 09:57:17 +0000
commitc9458897ebbb739d8db83c80e06512d8a612f743 (patch)
treef8c5381045887e34388cc6b26cfccc254bf766dc /doc/api-documentation/html/rawld_8cpp-source.html
downloadsword-sf-cvs-c9458897ebbb739d8db83c80e06512d8a612f743.tar.gz
*** empty log message ***
Diffstat (limited to 'doc/api-documentation/html/rawld_8cpp-source.html')
-rw-r--r--doc/api-documentation/html/rawld_8cpp-source.html218
1 files changed, 218 insertions, 0 deletions
diff --git a/doc/api-documentation/html/rawld_8cpp-source.html b/doc/api-documentation/html/rawld_8cpp-source.html
new file mode 100644
index 0000000..9f0e93c
--- /dev/null
+++ b/doc/api-documentation/html/rawld_8cpp-source.html
@@ -0,0 +1,218 @@
+<!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>rawld.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>rawld.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
+00002 <font class="comment"> * rawld.cpp - code for class 'RawLD'- a module that reads raw lexicon and</font>
+00003 <font class="comment"> * dictionary files: *.dat *.idx</font>
+00004 <font class="comment"> */</font>
+00005
+00006
+00007 <font class="preprocessor">#include &lt;ctype.h&gt;</font>
+00008 <font class="preprocessor">#include &lt;stdio.h&gt;</font>
+00009 <font class="preprocessor">#include &lt;fcntl.h&gt;</font>
+00010
+00011 <font class="preprocessor">#ifndef __GNUC__</font>
+00012 <font class="preprocessor"></font><font class="preprocessor">#include &lt;io.h&gt;</font>
+00013 <font class="preprocessor">#else</font>
+00014 <font class="preprocessor"></font><font class="preprocessor">#include &lt;unistd.h&gt;</font>
+00015 <font class="preprocessor">#endif</font>
+00016 <font class="preprocessor"></font>
+00017 <font class="preprocessor">#include &lt;string.h&gt;</font>
+00018 <font class="preprocessor">#include &lt;utilfuns.h&gt;</font>
+00019 <font class="preprocessor">#include &lt;rawstr.h&gt;</font>
+00020 <font class="preprocessor">#include &lt;rawld.h&gt;</font>
+00021
+00022
+00023 <font class="comment">/******************************************************************************</font>
+00024 <font class="comment"> * RawLD Constructor - Initializes data for instance of RawLD</font>
+00025 <font class="comment"> *</font>
+00026 <font class="comment"> * ENT: ipath - path and filename of files (no extension)</font>
+00027 <font class="comment"> * iname - Internal name for module</font>
+00028 <font class="comment"> * idesc - Name to display to user for module</font>
+00029 <font class="comment"> * idisp - Display object to use for displaying</font>
+00030 <font class="comment"> */</font>
+00031
+00032 RawLD::RawLD(<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 enc, SWTextDirection dir, SWTextMarkup mark, <font class="keyword">const</font> <font class="keywordtype">char</font>* ilang) : RawStr(ipath), <a class="code" href="class_s_w_l_d.html">SWLD</a>(iname, idesc, idisp, enc, dir, mark, ilang)
+00033 {
+00034 }
+00035
+00036
+00037 <font class="comment">/******************************************************************************</font>
+00038 <font class="comment"> * RawLD Destructor - Cleans up instance of RawLD</font>
+00039 <font class="comment"> */</font>
+00040
+00041 RawLD::~RawLD()
+00042 {
+00043 }
+00044
+00045
+00046 <font class="comment">/******************************************************************************</font>
+00047 <font class="comment"> * RawLD::strongsPad - Pads a key if it is 100% digits to 5 places</font>
+00048 <font class="comment"> *</font>
+00049 <font class="comment"> * ENT: buf - buffer to check and pad</font>
+00050 <font class="comment"> */</font>
+00051
+00052 <font class="keywordtype">void</font> RawLD::strongsPad(<font class="keywordtype">char</font> *buf)
+00053 {
+00054 <font class="keyword">const</font> <font class="keywordtype">char</font> *check;
+00055 <font class="keywordtype">int</font> size = 0;
+00056 <font class="keywordtype">int</font> len = strlen(buf);
+00057 <font class="keywordflow">if</font> ((len &lt; 5) &amp;&amp; (len &gt; 0)) {
+00058 <font class="keywordflow">for</font> (check = buf; *check; check++) {
+00059 <font class="keywordflow">if</font> (!isdigit(*check))
+00060 <font class="keywordflow">break</font>;
+00061 <font class="keywordflow">else</font> size++;
+00062 }
+00063
+00064 <font class="keywordflow">if</font> ((size == len) &amp;&amp; size)
+00065 sprintf(buf, <font class="stringliteral">"%.5d"</font>, atoi(buf));
+00066 }
+00067 }
+00068
+00069
+00070 <font class="comment">/******************************************************************************</font>
+00071 <font class="comment"> * RawLD::getEntry - Looks up entry from data file. 'Snaps' to closest</font>
+00072 <font class="comment"> * entry and sets 'entrybuf'.</font>
+00073 <font class="comment"> *</font>
+00074 <font class="comment"> * ENT: away - number of entries offset from key (default = 0)</font>
+00075 <font class="comment"> *</font>
+00076 <font class="comment"> * RET: error status</font>
+00077 <font class="comment"> */</font>
+00078
+00079 <font class="keywordtype">char</font> RawLD::getEntry(<font class="keywordtype">long</font> away)
+00080 {
+00081 <font class="keywordtype">long</font> start = 0;
+00082 <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> size = 0;
+00083 <font class="keywordtype">char</font> *idxbuf = 0;
+00084 <font class="keywordtype">char</font> retval = 0;
+00085
+00086 <font class="keywordtype">char</font> *buf = <font class="keyword">new</font> <font class="keywordtype">char</font> [ strlen(*key) + 6 ];
+00087 strcpy(buf, *key);
+00088
+00089 strongsPad(buf);
+00090
+00091 *entrybuf = 0;
+00092 <font class="keywordflow">if</font> (!(retval = findoffset(buf, &amp;start, &amp;size, away))) {
+00093 entrySize = size; <font class="comment">// support getEntrySize call</font>
+00094 <font class="keywordflow">if</font> (entrybuf)
+00095 <font class="keyword">delete</font> [] entrybuf;
+00096 entrybuf = <font class="keyword">new</font> <font class="keywordtype">char</font> [ ++size * FILTERPAD ];
+00097 idxbuf = <font class="keyword">new</font> <font class="keywordtype">char</font> [ size * FILTERPAD ];
+00098
+00099 gettext(start, size + 1, idxbuf, entrybuf);
+00100 <font class="keywordflow">if</font> (!key-&gt;Persist()) <font class="comment">// If we have our own key</font>
+00101 *key = idxbuf; <font class="comment">// reset it to entry index buffer</font>
+00102
+00103 stdstr(&amp;entkeytxt, idxbuf); <font class="comment">// set entry key text that module 'snapped' to.</font>
+00104 <font class="keyword">delete</font> [] idxbuf;
+00105 }
+00106 <font class="keywordflow">else</font> {
+00107 entrybuf = <font class="keyword">new</font> <font class="keywordtype">char</font> [ 5 ];
+00108 *entrybuf = 0;
+00109 }
+00110
+00111 <font class="keyword">delete</font> [] buf;
+00112 <font class="keywordflow">return</font> retval;
+00113 }
+00114
+00115
+00116 <font class="comment">/******************************************************************************</font>
+00117 <font class="comment"> * RawLD::operator char * - Returns the correct entry when char * cast</font>
+00118 <font class="comment"> * is requested</font>
+00119 <font class="comment"> *</font>
+00120 <font class="comment"> * RET: string buffer with entry</font>
+00121 <font class="comment"> */</font>
+00122
+00123 <font class="keywordtype">char</font> *RawLD::getRawEntry() {
+00124 <font class="keywordflow">if</font> (!getEntry() &amp;&amp; !isUnicode()) {
+00125 preptext(entrybuf);
+00126 }
+00127
+00128 <font class="keywordflow">return</font> entrybuf;
+00129 }
+00130
+00131
+00132 <font class="comment">/******************************************************************************</font>
+00133 <font class="comment"> * RawLD::operator += - Increments module key a number of entries</font>
+00134 <font class="comment"> *</font>
+00135 <font class="comment"> * ENT: increment - Number of entries to jump forward</font>
+00136 <font class="comment"> *</font>
+00137 <font class="comment"> * RET: *this</font>
+00138 <font class="comment"> */</font>
+00139
+00140 <a class="code" href="class_s_w_module.html">SWModule</a> &amp;RawLD::operator +=(<font class="keywordtype">int</font> increment)
+00141 {
+00142 <font class="keywordtype">char</font> tmperror;
+00143
+00144 <font class="keywordflow">if</font> (key-&gt;Traversable()) {
+00145 *key += increment;
+00146 error = key-&gt;Error();
+00147 increment = 0;
+00148 }
+00149
+00150 tmperror = (getEntry(increment)) ? KEYERR_OUTOFBOUNDS : 0;
+00151 error = (error)?error:tmperror;
+00152 *key = entkeytxt;
+00153 <font class="keywordflow">return</font> *<font class="keyword">this</font>;
+00154 }
+00155
+00156
+00157 <font class="comment">/******************************************************************************</font>
+00158 <font class="comment"> * RawLD::operator =(SW_POSITION) - Positions this key if applicable</font>
+00159 <font class="comment"> */</font>
+00160
+00161 <a class="code" href="class_s_w_module.html">SWModule</a> &amp;RawLD::operator =(SW_POSITION p)
+00162 {
+00163 <font class="keywordflow">if</font> (!key-&gt;Traversable()) {
+00164 <font class="keywordflow">switch</font> (p) {
+00165 <font class="keywordflow">case</font> POS_TOP:
+00166 *key = <font class="stringliteral">""</font>;
+00167 <font class="keywordflow">break</font>;
+00168 <font class="keywordflow">case</font> POS_BOTTOM:
+00169 *key = <font class="stringliteral">"zzzzzzzzz"</font>;
+00170 <font class="keywordflow">break</font>;
+00171 }
+00172 }
+00173 <font class="keywordflow">else</font> *key = p;
+00174 <font class="keywordflow">return</font> *<font class="keyword">this</font>;
+00175 }
+00176
+00177
+00178 <a class="code" href="class_s_w_module.html">SWModule</a> &amp;RawLD::setentry(<font class="keyword">const</font> <font class="keywordtype">char</font> *inbuf, <font class="keywordtype">long</font> len) {
+00179 settext(*key, inbuf, len);
+00180
+00181 <font class="keywordflow">return</font> *<font class="keyword">this</font>;
+00182 }
+00183
+00184 <a class="code" href="class_s_w_module.html">SWModule</a> &amp;RawLD::operator &lt;&lt;(<font class="keyword">const</font> <font class="keywordtype">char</font> *inbuf) {
+00185 <font class="keywordflow">return</font> setentry(inbuf, 0);
+00186 }
+00187
+00188
+00189 <a class="code" href="class_s_w_module.html">SWModule</a> &amp;RawLD::operator &lt;&lt;(<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> *inkey) {
+00190 linkentry(*key, *inkey);
+00191
+00192 <font class="keywordflow">return</font> *<font class="keyword">this</font>;
+00193 }
+00194
+00195
+00196 <font class="comment">/******************************************************************************</font>
+00197 <font class="comment"> * RawFiles::deleteEntry - deletes this entry</font>
+00198 <font class="comment"> *</font>
+00199 <font class="comment"> * RET: *this</font>
+00200 <font class="comment"> */</font>
+00201
+00202 <font class="keywordtype">void</font> RawLD::deleteEntry() {
+00203 settext(*key, <font class="stringliteral">""</font>);
+00204 }
+</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>