diff options
Diffstat (limited to 'doc/api-documentation/html/utilstr_8cpp-source.html')
-rw-r--r-- | doc/api-documentation/html/utilstr_8cpp-source.html | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/doc/api-documentation/html/utilstr_8cpp-source.html b/doc/api-documentation/html/utilstr_8cpp-source.html new file mode 100644 index 0000000..c2b5d84 --- /dev/null +++ b/doc/api-documentation/html/utilstr_8cpp-source.html @@ -0,0 +1,166 @@ +<!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>utilstr.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>utilstr.cpp</h1><div class="fragment"><pre>00001 <font class="preprocessor">#include <string.h></font> +00002 <font class="preprocessor">#include <utilstr.h></font> +00003 <font class="preprocessor">#include <ctype.h></font> +00004 +00005 <font class="comment">/******************************************************************************</font> +00006 <font class="comment"> * stdstr - Sets/gets a string</font> +00007 <font class="comment"> *</font> +00008 <font class="comment"> * ENT: ipstr - pointer to a string pointer to set if necessary</font> +00009 <font class="comment"> * istr - string to set to *ipstr</font> +00010 <font class="comment"> * 0 - only get</font> +00011 <font class="comment"> *</font> +00012 <font class="comment"> * RET: *ipstr</font> +00013 <font class="comment"> */</font> +00014 +00015 <font class="keywordtype">char</font> *stdstr(<font class="keywordtype">char</font> **ipstr, <font class="keyword">const</font> <font class="keywordtype">char</font> *istr) { +00016 <font class="keywordflow">if</font> (istr) { +00017 <font class="keywordflow">if</font> (*ipstr) +00018 <font class="keyword">delete</font> [] *ipstr; +00019 <font class="keywordtype">int</font> len = strlen(istr) + 1; +00020 *ipstr = <font class="keyword">new</font> <font class="keywordtype">char</font> [ len ]; +00021 memcpy(*ipstr, istr, len); +00022 } +00023 <font class="keywordflow">return</font> *ipstr; +00024 } +00025 +00026 +00027 <font class="comment">/******************************************************************************</font> +00028 <font class="comment"> * strstrip - Removes leading and trailing spaces from a string</font> +00029 <font class="comment"> *</font> +00030 <font class="comment"> * ENT: istr - string pointer to strip</font> +00031 <font class="comment"> *</font> +00032 <font class="comment"> * RET: *istr</font> +00033 <font class="comment"> */</font> +00034 +00035 <font class="keywordtype">char</font> *strstrip(<font class="keywordtype">char</font> *istr) { +00036 <font class="keywordtype">char</font> *tmp = istr; +00037 <font class="keywordtype">char</font> *rtmp; +00038 +00039 <font class="keywordtype">int</font> len = strlen(istr); +00040 <font class="keywordflow">if</font> (len < 1) +00041 <font class="keywordflow">return</font> istr; +00042 rtmp = istr + (len - 1); +00043 +00044 <font class="keywordflow">while</font> ((*rtmp == <font class="charliteral">' '</font>)||(*rtmp == <font class="charliteral">'\t'</font>)||(*rtmp == 10)||(*rtmp == 13)) *(rtmp--) = 0; +00045 <font class="keywordflow">while</font> ((*tmp == <font class="charliteral">' '</font>)||(*tmp == <font class="charliteral">'\t'</font>)||(*tmp == 10)||(*tmp == 13)) tmp++; +00046 memmove(istr, tmp, (rtmp - tmp) + 1); +00047 istr[(rtmp - tmp) + 1] = 0; +00048 +00049 <font class="keywordflow">return</font> istr; +00050 } +00051 +00052 +00053 <font class="comment">/******************************************************************************</font> +00054 <font class="comment"> * stristr - Scans a string for the occurrence of a given substring, no case</font> +00055 <font class="comment"> *</font> +00056 <font class="comment"> * ENT: scans s1 for the first occurrence of the substring s2, ingnoring case</font> +00057 <font class="comment"> *</font> +00058 <font class="comment"> * RET: a pointer to the element in s1, where s2 begins (points to s2 in s1).</font> +00059 <font class="comment"> * If s2 does not occur in s1, returns null.</font> +00060 <font class="comment"> */</font> +00061 +00062 <font class="keyword">const</font> <font class="keywordtype">char</font> *stristr(<font class="keyword">const</font> <font class="keywordtype">char</font> *s1, <font class="keyword">const</font> <font class="keywordtype">char</font> *s2) { +00063 <font class="keywordtype">int</font> tLen = strlen(s2); +00064 <font class="keywordtype">int</font> cLen = strlen(s1); +00065 <font class="keywordtype">char</font> *target = <font class="keyword">new</font> <font class="keywordtype">char</font> [ tLen + 1 ]; +00066 <font class="keywordtype">int</font> i, j; +00067 <font class="keyword">const</font> <font class="keywordtype">char</font> *retVal = 0; +00068 +00069 strcpy(target, s2); +00070 <font class="keywordflow">for</font> (i = 0; i < tLen; i++) +00071 target[i] = SW_toupper(target[i]); +00072 +00073 <font class="keywordflow">for</font> (i = 0; i < (cLen - tLen)+1; i++) { +00074 <font class="keywordflow">if</font> (SW_toupper(s1[i]) == (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)*target) { +00075 <font class="keywordflow">for</font> (j = 1; j < tLen; j++) { +00076 <font class="keywordflow">if</font> (SW_toupper(s1[i+j]) != (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)target[j]) +00077 <font class="keywordflow">break</font>; +00078 } +00079 <font class="keywordflow">if</font> (j == tLen) { +00080 retVal = s1+i; +00081 <font class="keywordflow">break</font>; +00082 } +00083 } +00084 } +00085 <font class="keyword">delete</font> [] target; +00086 <font class="keywordflow">return</font> retVal; +00087 } +00088 +00089 <font class="comment">/******************************************************************************</font> +00090 <font class="comment"> * strnicmp - compares the first n bytes of 2 string ignoring case</font> +00091 <font class="comment"> *</font> +00092 <font class="comment"> * ENT: compares s1 to s2 comparing the first n byte ingnoring case</font> +00093 <font class="comment"> *</font> +00094 <font class="comment"> * RET: same as strcmp</font> +00095 <font class="comment"> */</font> +00096 +00097 <font class="keyword">const</font> <font class="keywordtype">char</font> strnicmp(<font class="keyword">const</font> <font class="keywordtype">char</font> *s1, <font class="keyword">const</font> <font class="keywordtype">char</font> *s2, <font class="keywordtype">int</font> len) { +00098 +00099 <font class="keywordtype">int</font> tLen = strlen(s2); +00100 <font class="keywordtype">int</font> cLen = strlen(s1); +00101 <font class="keywordtype">char</font> diff; +00102 <font class="keywordtype">int</font> i; +00103 <font class="keywordflow">for</font> (i = 0; ((i < len) && (i < tLen) && (i < cLen)); i++) { +00104 <font class="keywordflow">if</font> ((diff = SW_toupper(*s1) - SW_toupper(*s2))) +00105 <font class="keywordflow">return</font> diff; +00106 s1++; +00107 s2++; +00108 } +00109 <font class="keywordflow">return</font> (i < len) ? cLen - tLen : 0; +00110 } +00111 +00112 <font class="comment">/******************************************************************************</font> +00113 <font class="comment"> * strlenw - Scans a string for trailing 0x0000 and return size in BYTES</font> +00114 <font class="comment"> *</font> +00115 <font class="comment"> * ENT: target - string for which to determine size</font> +00116 <font class="comment"> *</font> +00117 <font class="comment"> * RET: length in BYTES </font> +00118 <font class="comment"> * If s2 does not occur in s1, returns null.</font> +00119 <font class="comment"> */</font> +00120 +00121 <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> strlenw(<font class="keyword">const</font> <font class="keywordtype">char</font> *s1) { +00122 <font class="keywordflow">return</font> strlen(s1); +00123 <font class="comment">// utf8 says no null in string except terminator, so below code is overkill</font> +00124 <font class="comment">/*</font> +00125 <font class="comment"> const char *ch = s1;</font> +00126 <font class="comment"> if (!*ch)</font> +00127 <font class="comment"> ch++;</font> +00128 <font class="comment"> while (*ch) {</font> +00129 <font class="comment"> ch++;</font> +00130 <font class="comment"> if (!*ch)</font> +00131 <font class="comment"> ch++;</font> +00132 <font class="comment"> }</font> +00133 <font class="comment"> return (unsigned int)(ch - s1) - 1;</font> +00134 <font class="comment">*/</font> +00135 } +00136 +00137 +00138 <font class="comment">/******************************************************************************</font> +00139 <font class="comment"> * toupperstr - converts a string to uppercase string</font> +00140 <font class="comment"> *</font> +00141 <font class="comment"> * ENT: target - string to convert</font> +00142 <font class="comment"> *</font> +00143 <font class="comment"> * RET: target</font> +00144 <font class="comment"> */</font> +00145 +00146 <font class="keywordtype">char</font> *toupperstr(<font class="keywordtype">char</font> *buf) { +00147 <font class="keywordtype">char</font> *ret = buf; +00148 <font class="keywordflow">while</font> (*buf) +00149 *buf = SW_toupper(*buf++); +00150 +00151 <font class="keywordflow">return</font> ret; +00152 } +</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:13:01 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> |