1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
<!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.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body bgcolor="#ffffff">
<!-- Generated by Doxygen 1.2.9.1 -->
<center>
<a class="qindex" href="index.html">Main Page</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>swkey.h</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> * swkey.h - 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 <font class="comment"> * $Id: swkey_8h-source.html,v 1.4 2002/01/22 14:20:28 jansorg Exp $</font>
00007 <font class="comment"> *</font>
00008 <font class="comment"> * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)</font>
00009 <font class="comment"> * CrossWire Bible Society</font>
00010 <font class="comment"> * P. O. Box 2528</font>
00011 <font class="comment"> * Tempe, AZ 85280-2528</font>
00012 <font class="comment"> *</font>
00013 <font class="comment"> * This program is free software; you can redistribute it and/or modify it</font>
00014 <font class="comment"> * under the terms of the GNU General Public License as published by the</font>
00015 <font class="comment"> * Free Software Foundation version 2.</font>
00016 <font class="comment"> *</font>
00017 <font class="comment"> * This program is distributed in the hope that it will be useful, but</font>
00018 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00019 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00020 <font class="comment"> * General Public License for more details.</font>
00021 <font class="comment"> *</font>
00022 <font class="comment"> */</font>
00023
00024 <font class="preprocessor">#ifndef SWKEY_H</font>
00025 <font class="preprocessor"></font><font class="preprocessor">#define SWKEY_H</font>
00026 <font class="preprocessor"></font>
00027 <font class="preprocessor">#include <swobject.h></font>
00028
00029 <font class="preprocessor">#include <defs.h></font>
00030
00031 <font class="preprocessor">#define KEYERR_OUTOFBOUNDS 1</font>
00032 <font class="preprocessor"></font>
00033 <font class="preprocessor">#define SWKEY_OPERATORS \</font>
00034 <font class="preprocessor"> SWKey & operator = (const char *ikey) { setText(ikey); return *this; } \</font>
00035 <font class="preprocessor"> SWKey & operator = (const SWKey &ikey) { copyFrom(ikey); return *this; } \</font>
00036 <font class="preprocessor"> SWKey & operator = (SW_POSITION pos) { setPosition(pos); return *this; } \</font>
00037 <font class="preprocessor"> operator const char *() const { return getText(); } \</font>
00038 <font class="preprocessor"> bool operator == (const SWKey & ikey) { return equals(ikey); } \</font>
00039 <font class="preprocessor"> bool operator != (const SWKey & ikey) { return !equals(ikey); } \</font>
00040 <font class="preprocessor"> virtual bool operator > (const SWKey & ikey) { return (compare (ikey) > 0); } \</font>
00041 <font class="preprocessor"> virtual bool operator < (const SWKey & ikey) { return (compare (ikey) < 0); } \</font>
00042 <font class="preprocessor"> virtual bool operator >= (const SWKey & ikey) { return (compare (ikey) > -1); } \</font>
00043 <font class="preprocessor"> virtual bool operator <= (const SWKey & ikey) { return (compare (ikey) < 1); } \</font>
00044 <font class="preprocessor"> SWKey & operator -= (int steps) { decrement(steps); return *this; } \</font>
00045 <font class="preprocessor"> SWKey & operator += (int steps) { increment(steps); return *this; } \</font>
00046 <font class="preprocessor"> SWKey & operator++ (int) { return *this += 1; } \</font>
00047 <font class="preprocessor"> SWKey & operator-- (int) { return *this -= 1; }</font>
00048 <font class="preprocessor"></font>
00049
00050 <font class="comment">// For use with = operator to position key.</font>
00051
00052 <font class="keyword">class </font>SW_POSITION
00053 {
00054 <font class="keywordtype">char</font> pos;
00055 <font class="keyword">public</font>:
00056 SW_POSITION (<font class="keywordtype">char</font> ipos)<font class="keyword"></font>
00057 <font class="keyword"> </font>{
00058 pos = ipos;
00059 }
00060 operator char ()<font class="keyword"></font>
00061 <font class="keyword"> </font>{
00062 <font class="keywordflow">return</font> pos;
00063 }
00064 };
00065
00066 <font class="preprocessor">#define POS_TOP ((char)1)</font>
00067 <font class="preprocessor"></font><font class="preprocessor">#define POS_BOTTOM ((char)2)</font>
00068 <font class="preprocessor"></font>
00069 <font class="preprocessor">#define TOP SW_POSITION(POS_TOP)</font>
00070 <font class="preprocessor"></font><font class="preprocessor">#define BOTTOM SW_POSITION(POS_BOTTOM)</font>
00071 <font class="preprocessor"></font>
<a name="l00076"></a><a class="code" href="class_s_w_key.html">00076</a> <font class="keyword">class </font>SWDLLEXPORT <a class="code" href="class_s_w_key.html">SWKey</a>:<font class="keyword">public</font> <a class="code" href="class_s_w_object.html">SWObject</a>
00077 {
00078 <font class="keywordtype">long</font> index;
00079 <font class="keyword">static</font> <a class="code" href="class_s_w_class.html">SWClass</a> classdef;
00080 <font class="keywordtype">void</font> init ();
00081
00082 <font class="keyword">protected</font>:
00083 <font class="keywordtype">char</font> *keytext;
00084 <font class="keywordtype">char</font> persist;
00085 <font class="keywordtype">char</font> error;
00086
00087 <font class="keyword">public</font>:
00092 <a class="code" href="class_s_w_key.html#a0">SWKey</a> (<font class="keyword">const</font> <font class="keywordtype">char</font> *ikey = 0);
00093
00097 <a class="code" href="class_s_w_key.html#a0">SWKey</a> (<a class="code" href="class_s_w_key.html">SWKey</a> <font class="keyword">const</font> &k);
00098
00101 <font class="keyword">virtual</font> <a class="code" href="class_s_w_key.html#a2">~ SWKey</a> ();
00102
00107 <font class="keyword">virtual</font> <a class="code" href="class_s_w_key.html">SWKey</a> *<a class="code" href="class_s_w_key.html#a3">clone</a> () <font class="keyword">const</font>;
00108
00115 <font class="keywordtype">char</font> <a class="code" href="class_s_w_key.html#a4">Persist</a> () <font class="keyword">const</font>;
00116
00125 <font class="keywordtype">char</font> <a class="code" href="class_s_w_key.html#a4">Persist</a> (<font class="keywordtype">char</font> ikey);
00126
00131 <font class="keyword">virtual</font> <font class="keywordtype">char</font> <a class="code" href="class_s_w_key.html#a6">Error</a> ();
00132
00137 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="class_s_w_key.html#a7">setText</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *ikey);
00138
00143 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="class_s_w_key.html#a8">copyFrom</a>(<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> &ikey);
00144
00147 <font class="keyword">virtual</font> <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="class_s_w_key.html#a9">getText</a>() <font class="keyword">const</font>;
00148
00156 <font class="keyword">virtual</font> <font class="keywordtype">int</font> <a class="code" href="class_s_w_key.html#a10">compare</a> (<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> & ikey);
00157
<a name="l00163"></a><a class="code" href="class_s_w_key.html#a11">00163</a> <font class="keyword">virtual</font> <font class="keywordtype">bool</font> <a class="code" href="class_s_w_key.html#a11">equals</a>(<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> &ikey)<font class="keyword"> </font>{ <font class="keywordflow">return</font> !<a class="code" href="class_s_w_key.html#a10">compare</a>(ikey); }
00164
00165 <font class="keyword">virtual</font> <font class="keywordtype">void</font> setPosition(SW_POSITION);
00166
00172 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="class_s_w_key.html#a13">decrement</a>(<font class="keywordtype">int</font> steps = 1);
00173
00179 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="class_s_w_key.html#a14">increment</a>(<font class="keywordtype">int</font> steps = 1);
00180
00181 <font class="keyword">virtual</font> <font class="keywordtype">char</font> Traversable ()<font class="keyword"> </font>{ <font class="keywordflow">return</font> 0; }
00182
<a name="l00204"></a><a class="code" href="class_s_w_key.html#a16">00204</a> <font class="keyword">virtual</font> <font class="keywordtype">long</font> <a class="code" href="class_s_w_key.html#a16">Index</a> ()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> index; }
00205
00206 <font class="keyword">virtual</font> <font class="keywordtype">long</font> <a class="code" href="class_s_w_key.html#a16">Index</a> (<font class="keywordtype">long</font> iindex)<font class="keyword"> </font>{ index = iindex; <font class="keywordflow">return</font> index; }
00207
00208 SWKEY_OPERATORS
00209
00210 };
00211
00212
00213 <font class="preprocessor">#endif</font>
</font></pre></div><hr><address><small>Generated at Tue Jan 22 14:52:48 2002 for The Sword Project by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.gif" alt="doxygen" align="middle" border=0
width=110 height=53></a>1.2.9.1 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>,
© 1997-2001</small></address>
</body>
</html>
|