blob: 50e8c1641022d8676ae08fca81bc2d3d2324fdf2 (
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>hrefcom.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>hrefcom.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> * hrefcom.cpp - code for class 'HREFCom'- a module that produces HTML HREFs</font>
00003 <font class="comment"> * pointing to actual text desired. Uses standard</font>
00004 <font class="comment"> * files: ot and nt using indexs ??.bks ??.cps ??.vss</font>
00005 <font class="comment"> */</font>
00006
00007
00008 <font class="preprocessor">#include <ctype.h></font>
00009 <font class="preprocessor">#include <stdio.h></font>
00010 <font class="preprocessor">#include <fcntl.h></font>
00011
00012 <font class="preprocessor">#ifndef __GNUC__</font>
00013 <font class="preprocessor"></font><font class="preprocessor">#include <io.h></font>
00014 <font class="preprocessor">#else</font>
00015 <font class="preprocessor"></font><font class="preprocessor">#include <unistd.h></font>
00016 <font class="preprocessor">#endif</font>
00017 <font class="preprocessor"></font>
00018 <font class="preprocessor">#include <string.h></font>
00019 <font class="preprocessor">#include <utilfuns.h></font>
00020 <font class="preprocessor">#include <rawverse.h></font>
00021 <font class="preprocessor">#include <hrefcom.h></font>
00022
00023
00024 <font class="comment">/******************************************************************************</font>
00025 <font class="comment"> * HREFCom Constructor - Initializes data for instance of HREFCom</font>
00026 <font class="comment"> *</font>
00027 <font class="comment"> * ENT: iname - Internal name for module</font>
00028 <font class="comment"> * iprefix - string to prepend to each HREF (e.g. "file://mods/com/jfb/")</font>
00029 <font class="comment"> * idesc - Name to display to user for module</font>
00030 <font class="comment"> * idisp - Display object to use for displaying</font>
00031 <font class="comment"> */</font>
00032
00033 HREFCom::HREFCom(<font class="keyword">const</font> <font class="keywordtype">char</font> *ipath, <font class="keyword">const</font> <font class="keywordtype">char</font> *iprefix, <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) : RawVerse(ipath), <a class="code" href="class_s_w_com.html">SWCom</a>(iname, idesc, idisp)
00034 {
00035 prefix = 0;
00036 stdstr(&prefix, iprefix);
00037 }
00038
00039
00040 <font class="comment">/******************************************************************************</font>
00041 <font class="comment"> * HREFCom Destructor - Cleans up instance of HREFCom</font>
00042 <font class="comment"> */</font>
00043
00044 HREFCom::~HREFCom()
00045 {
00046 <font class="keywordflow">if</font> (prefix)
00047 <font class="keyword">delete</font> [] prefix;
00048 }
00049
00050
00051 <font class="comment">/******************************************************************************</font>
00052 <font class="comment"> * HREFCom::operator char * - Returns the correct verse when char * cast</font>
00053 <font class="comment"> * is requested</font>
00054 <font class="comment"> *</font>
00055 <font class="comment"> * RET: string buffer with verse</font>
00056 <font class="comment"> */</font>
00057
00058 <font class="keywordtype">char</font> *HREFCom::getRawEntry() {
00059 <font class="keywordtype">long</font> start;
00060 <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> size;
00061 <font class="keywordtype">char</font> *tmpbuf;
00062 <a class="code" href="class_verse_key.html">VerseKey</a> *key = 0;
00063
00064 <font class="preprocessor">#ifndef _WIN32_WCE</font>
00065 <font class="preprocessor"></font> <font class="keywordflow">try</font> {
00066 <font class="preprocessor">#endif</font>
00067 <font class="preprocessor"></font> key = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, this->key);
00068 <font class="preprocessor">#ifndef _WIN32_WCE</font>
00069 <font class="preprocessor"></font> }
00070 <font class="keywordflow">catch</font> ( ... ) {}
00071 <font class="preprocessor">#endif</font>
00072 <font class="preprocessor"></font> <font class="keywordflow">if</font> (!key)
00073 key = <font class="keyword">new</font> <a class="code" href="class_verse_key.html">VerseKey</a>(this->key);
00074
00075 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);
00076 entrySize = size; <font class="comment">// support getEntrySize call</font>
00077
00078 <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> newsize = ((size + 2) + strlen(prefix)) * FILTERPAD;
00079 <font class="keywordflow">if</font> (newsize > entrybufallocsize) {
00080 <font class="keywordflow">if</font> (entrybuf)
00081 <font class="keyword">delete</font> [] entrybuf;
00082 entrybuf = <font class="keyword">new</font> <font class="keywordtype">char</font> [ newsize ];
00083 entrybufallocsize = newsize;
00084 }
00085 tmpbuf = <font class="keyword">new</font> <font class="keywordtype">char</font> [ size + 10 ];
00086
00087 gettext(key-><a class="code" href="class_verse_key.html#a22">Testament</a>(), start, size + 2, tmpbuf);
00088 sprintf(entrybuf, <font class="stringliteral">"%s%s"</font>, prefix, tmpbuf);
00089 preptext(entrybuf);
00090
00091 <font class="keyword">delete</font> [] tmpbuf;
00092
00093 <font class="keywordflow">if</font> (key != this->key)
00094 <font class="keyword">delete</font> key;
00095
00096 <font class="keywordflow">return</font> entrybuf;
00097 }
</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>
|