aboutsummaryrefslogblamecommitdiffstats
path: root/doc/api-documentation/html/swkey_8cpp-source.html
blob: 115e65e3d5dc826ed7a5624ff10c46ee070df959 (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>swkey.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>swkey.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> *  swkey.cpp - code for base class 'SWKey'.  SWKey is the basis for all</font>
00003 <font class="comment"> *              types of keys for indexing into modules (e.g. verse, word,</font>
00004 <font class="comment"> *              place, etc.)</font>
00005 <font class="comment"> */</font>
00006 
00007 <font class="preprocessor">#include &lt;swkey.h&gt;</font>
00008 <font class="preprocessor">#include &lt;utilfuns.h&gt;</font>
00009 <font class="preprocessor">#include &lt;string.h&gt;</font>
00010 
00011 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">char</font> *classes[] = {<font class="stringliteral">"SWKey"</font>, <font class="stringliteral">"SWObject"</font>, 0};
00012 <a class="code" href="class_s_w_class.html">SWClass</a> SWKey::classdef(classes);
00013 
00014 <font class="comment">/******************************************************************************</font>
00015 <font class="comment"> * SWKey Constructor - initializes instance of SWKey</font>
00016 <font class="comment"> *</font>
00017 <font class="comment"> * ENT: ikey - text key</font>
00018 <font class="comment"> */</font>
00019 
<a name="l00020"></a><a class="code" href="class_s_w_key.html#a0">00020</a> <a class="code" href="class_s_w_key.html#a0">SWKey::SWKey</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *ikey)
00021 {
00022         index   = 0;
00023         persist = 0;
00024         keytext = 0;
00025         error   = 0;
00026         stdstr(&amp;keytext, ikey);
00027         init();
00028 }
00029 
<a name="l00030"></a><a class="code" href="class_s_w_key.html#a1">00030</a> <a class="code" href="class_s_w_key.html#a0">SWKey::SWKey</a>(<a class="code" href="class_s_w_key.html">SWKey</a> <font class="keyword">const</font> &amp;k)
00031 {
00032         index    = k.<a class="code" href="class_s_w_key.html#o0">index</a>;
00033         persist  = k.<a class="code" href="class_s_w_key.html#n1">persist</a>;
00034         userData = k.<a class="code" href="class_s_w_key.html#m0">userData</a>;
00035         keytext  = 0;
00036         error    = k.<a class="code" href="class_s_w_key.html#n2">error</a>;
00037         stdstr(&amp;keytext, k.<a class="code" href="class_s_w_key.html#n0">keytext</a>);
00038         init();
00039 }
00040 
00041 <font class="keywordtype">void</font> SWKey::init() {
00042         myclass = &amp;classdef;
00043 }
00044 
<a name="l00045"></a><a class="code" href="class_s_w_key.html#a3">00045</a> <a class="code" href="class_s_w_key.html">SWKey</a> *<a class="code" href="class_s_w_key.html#a3">SWKey::clone</a>()<font class="keyword"> const</font>
00046 <font class="keyword"></font>{
00047         <font class="keywordflow">return</font> <font class="keyword">new</font> <a class="code" href="class_s_w_key.html#a0">SWKey</a>(*<font class="keyword">this</font>);
00048 }
00049 
00050 <font class="comment">/******************************************************************************</font>
00051 <font class="comment"> * SWKey Destructor - cleans up instance of SWKey</font>
00052 <font class="comment"> */</font>
00053 
<a name="l00054"></a><a class="code" href="class_s_w_key.html#a2">00054</a> <a class="code" href="class_s_w_key.html#a2">SWKey::~SWKey</a>() {
00055         <font class="keywordflow">if</font> (keytext)
00056                 <font class="keyword">delete</font> [] keytext;
00057 }
00058 
00059 
00060 <font class="comment">/******************************************************************************</font>
00061 <font class="comment"> * SWKey::Persist - Gets whether this object itself persists within a</font>
00062 <font class="comment"> *                      module that it was used to SetKey or just a copy.</font>
00063 <font class="comment"> *                      (1 - persists in module; 0 - a copy is attempted</font>
00064 <font class="comment"> *</font>
00065 <font class="comment"> * RET: value of persist</font>
00066 <font class="comment"> */</font>
00067 
<a name="l00068"></a><a class="code" href="class_s_w_key.html#a4">00068</a> <font class="keywordtype">char</font> <a class="code" href="class_s_w_key.html#a4">SWKey::Persist</a>()<font class="keyword"> const</font>
00069 <font class="keyword"></font>{
00070         <font class="keywordflow">return</font> persist;
00071 }
00072 
00073 
00074 <font class="comment">/******************************************************************************</font>
00075 <font class="comment"> * SWKey::Persist - Set/gets whether this object itself persists within a</font>
00076 <font class="comment"> *                      module that it was used to SetKey or just a copy.</font>
00077 <font class="comment"> *                      (1 - persists in module; 0 - a copy is attempted</font>
00078 <font class="comment"> *</font>
00079 <font class="comment"> * ENT: ipersist - value which to set persist</font>
00080 <font class="comment"> *              [-1] - only get</font>
00081 <font class="comment"> *</font>
00082 <font class="comment"> * RET: value of persist</font>
00083 <font class="comment"> */</font>
00084 
<a name="l00085"></a><a class="code" href="class_s_w_key.html#a5">00085</a> <font class="keywordtype">char</font> <a class="code" href="class_s_w_key.html#a4">SWKey::Persist</a>(<font class="keywordtype">signed</font> <font class="keywordtype">char</font> ipersist)
00086 {
00087         <font class="keywordflow">if</font> (ipersist != -1)
00088                 persist = ipersist;
00089 
00090         <font class="keywordflow">return</font> persist;
00091 }
00092 
00093 
00094 <font class="comment">/******************************************************************************</font>
00095 <font class="comment"> * SWKey::Error - Gets and clears error status</font>
00096 <font class="comment"> *</font>
00097 <font class="comment"> * RET: error status</font>
00098 <font class="comment"> */</font>
00099 
<a name="l00100"></a><a class="code" href="class_s_w_key.html#a6">00100</a> <font class="keywordtype">char</font> <a class="code" href="class_s_w_key.html#a6">SWKey::Error</a>()
00101 {
00102         <font class="keywordtype">char</font> retval = error;
00103 
00104         error = 0;
00105         <font class="keywordflow">return</font> retval;
00106 }
00107 
00108 
00109 <font class="comment">/******************************************************************************</font>
00110 <font class="comment"> * SWKey::setText Equates this SWKey to a character string</font>
00111 <font class="comment"> *</font>
00112 <font class="comment"> * ENT: ikey - other swkey object</font>
00113 <font class="comment"> */</font>
00114 
<a name="l00115"></a><a class="code" href="class_s_w_key.html#a7">00115</a> <font class="keywordtype">void</font> <a class="code" href="class_s_w_key.html#a7">SWKey::setText</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *ikey) {
00116         stdstr(&amp;keytext, ikey);
00117 }
00118 
00119 
00120 <font class="comment">/******************************************************************************</font>
00121 <font class="comment"> * SWKey::copyFrom Equates this SWKey to another SWKey object</font>
00122 <font class="comment"> *</font>
00123 <font class="comment"> * ENT: ikey - other swkey object</font>
00124 <font class="comment"> */</font>
00125 
<a name="l00126"></a><a class="code" href="class_s_w_key.html#a8">00126</a> <font class="keywordtype">void</font> <a class="code" href="class_s_w_key.html#a8">SWKey::copyFrom</a>(<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> &amp;ikey) {
00127 <font class="comment">// not desirable        Persist(ikey.Persist());</font>
00128         <a class="code" href="class_s_w_key.html#a7">setText</a>((<font class="keyword">const</font> <font class="keywordtype">char</font> *)ikey);
00129 }
00130 
00131 
00132 <font class="comment">/******************************************************************************</font>
00133 <font class="comment"> * SWKey::getText - returns text key if (char *) cast is requested</font>
00134 <font class="comment"> */</font>
00135 
<a name="l00136"></a><a class="code" href="class_s_w_key.html#a9">00136</a> <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="class_s_w_key.html#a9">SWKey::getText</a>()<font class="keyword"> const </font>{
00137         <font class="keywordflow">return</font> keytext;
00138 }
00139 
00140 
00141 <font class="comment">/******************************************************************************</font>
00142 <font class="comment"> * SWKey::compare       - Compares another VerseKey object</font>
00143 <font class="comment"> *</font>
00144 <font class="comment"> * ENT: ikey - key to compare with this one</font>
00145 <font class="comment"> *</font>
00146 <font class="comment"> * RET: &gt; 0 if this key is greater than compare key</font>
00147 <font class="comment"> *      &lt; 0</font>
00148 <font class="comment"> *        0</font>
00149 <font class="comment"> */</font>
00150 
<a name="l00151"></a><a class="code" href="class_s_w_key.html#a11">00151</a> <font class="keywordtype">int</font> <a class="code" href="class_s_w_key.html#a11">SWKey::compare</a>(<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> &amp;ikey)
00152 {
00153         <font class="keywordflow">return</font> strcmp((<font class="keyword">const</font> <font class="keywordtype">char</font> *)*<font class="keyword">this</font>, (<font class="keyword">const</font> <font class="keywordtype">char</font> *)ikey);
00154 }
00155 
00156 
00157 <font class="comment">/******************************************************************************</font>
00158 <font class="comment"> * SWKey::setPosition(SW_POSITION)      - Positions this key if applicable</font>
00159 <font class="comment"> */</font>
00160 
00161 <font class="keywordtype">void</font> SWKey::setPosition(SW_POSITION p) {
00162         <font class="keywordflow">switch</font> (p) {
00163         <font class="keywordflow">case</font> POS_TOP:
00164 <font class="comment">//              *this = "";</font>
00165                 <font class="keywordflow">break</font>;
00166         <font class="keywordflow">case</font> POS_BOTTOM:
00167 <font class="comment">//              *this = "zzzzzzzzz";</font>
00168                 <font class="keywordflow">break</font>;
00169         } 
00170 }
00171 
00172 
00173 <font class="comment">/******************************************************************************</font>
00174 <font class="comment"> * SWKey::increment     - Increments key a number of entries</font>
00175 <font class="comment"> *</font>
00176 <font class="comment"> * ENT: increment       - Number of entries to jump forward</font>
00177 <font class="comment"> *</font>
00178 <font class="comment"> * RET: *this</font>
00179 <font class="comment"> */</font>
00180 
<a name="l00181"></a><a class="code" href="class_s_w_key.html#a15">00181</a> <font class="keywordtype">void</font> <a class="code" href="class_s_w_key.html#a15">SWKey::increment</a>(<font class="keywordtype">int</font>) {
00182         error = KEYERR_OUTOFBOUNDS;
00183 }
00184 
00185 
00186 <font class="comment">/******************************************************************************</font>
00187 <font class="comment"> * SWKey::decrement     - Decrements key a number of entries</font>
00188 <font class="comment"> *</font>
00189 <font class="comment"> * ENT: decrement       - Number of entries to jump backward</font>
00190 <font class="comment"> *</font>
00191 <font class="comment"> * RET: *this</font>
00192 <font class="comment"> */</font>
00193 
<a name="l00194"></a><a class="code" href="class_s_w_key.html#a14">00194</a> <font class="keywordtype">void</font> <a class="code" href="class_s_w_key.html#a14">SWKey::decrement</a>(<font class="keywordtype">int</font>) {
00195         error = KEYERR_OUTOFBOUNDS;
00196 }
</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>