StdString.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. // $Id: StdString.h 101 2006-11-25 00:47:51Z gigaherz $
  2. /* StdString - std::string convenience wrapper. */
  3. // =============================================================================
  4. // FILE: StdString.h
  5. // AUTHOR: Joe O'Leary (with outside help noted in comments)
  6. // REMARKS:
  7. // This header file declares the CStdStr template. This template derives
  8. // the Standard C++ Library basic_string<> template and add to it the
  9. // the following conveniences:
  10. // - The full MFC RString set of functions (including implicit cast)
  11. // - writing to/reading from COM IStream interfaces
  12. // - Functional objects for use in STL algorithms
  13. #ifndef STDSTRING
  14. #define STDSTRING
  15. // Standard headers needed
  16. #include <string> // basic_string
  17. #include <algorithm> // for_each, etc.
  18. #include <functional> // for StdStringLessNoCase, et al
  19. #include <cstdarg>
  20. #include <cstdio>
  21. #include <cctype>
  22. #include <cstdlib>
  23. #include <cstdarg>
  24. #ifdef _MSC_VER
  25. #ifdef va_copy
  26. #undef va_copy
  27. #endif
  28. #define va_copy(a,b) (a=b)
  29. #define snprintf _snprintf
  30. #endif
  31. // =============================================================================
  32. // INLINE FUNCTIONS ON WHICH CSTDSTRING RELIES
  33. //
  34. // Usually for generic text mapping, we rely on preprocessor macro definitions
  35. // to map to string functions. However the CStdStr<> template cannot use
  36. // macro-based generic text mappings because its character types do not get
  37. // resolved until template processing which comes AFTER macro processing. In
  38. // other words, UNICODE is of little help to us in the CStdStr template
  39. //
  40. // Therefore, to keep the CStdStr declaration simple, we have these inline
  41. // functions. The template calls them often. Since they are inline (and NOT
  42. // exported when this is built as a DLL), they will probably be resolved away
  43. // to nothing.
  44. //
  45. // Without these functions, the CStdStr<> template would probably have to broken
  46. // out into two, almost identical classes. Either that or it would be a huge,
  47. // convoluted mess, with tons of "if" statements all over the place checking the
  48. // size of template parameter CT.
  49. //
  50. // In several cases, you will see two versions of each function. One version is
  51. // the more portable, standard way of doing things, while the other is the
  52. // non-standard, but often significantly faster Visual C++ way.
  53. // =============================================================================
  54. namespace StdString
  55. {
  56. // -----------------------------------------------------------------------------
  57. // sslen: strlen/wcslen wrappers
  58. // -----------------------------------------------------------------------------
  59. template<typename CT>
  60. inline int
  61. sslen(const CT* pT)
  62. {
  63. return pT == NULL ? 0 : std::basic_string<CT>::traits_type::length(pT);
  64. }
  65. inline int
  66. sslen(const std::string &s)
  67. {
  68. return s.length();
  69. }
  70. // -----------------------------------------------------------------------------
  71. // sstolower/sstoupper -- convert characters to upper/lower case
  72. // -----------------------------------------------------------------------------
  73. inline char
  74. sstoupper(char ch)
  75. {
  76. return (ch >= 'a' && ch <= 'z')? char(ch + 'A' - 'a'): ch;
  77. }
  78. inline char
  79. sstolower(char ch)
  80. {
  81. return (ch >= 'A' && ch <= 'Z')? char(ch + 'a' - 'A'): ch;
  82. }
  83. // -----------------------------------------------------------------------------
  84. // ssasn: assignment functions -- assign "sSrc" to "sDst"
  85. // -----------------------------------------------------------------------------
  86. inline void
  87. ssasn(std::string &sDst, const std::string &sSrc)
  88. {
  89. if (sDst.c_str() != sSrc.c_str())
  90. {
  91. sDst.erase();
  92. sDst.assign(sSrc);
  93. }
  94. }
  95. inline void
  96. ssasn(std::string &sDst, const char* pA)
  97. {
  98. // Watch out for NULLs, as always.
  99. if (pA == NULL)
  100. {
  101. sDst.erase();
  102. }
  103. else
  104. sDst.assign(pA);
  105. }
  106. inline void
  107. ssasn(std::string &sDst, const int nNull)
  108. {
  109. sDst.erase();
  110. }
  111. // -----------------------------------------------------------------------------
  112. // ssadd: string object concatenation -- add second argument to first
  113. // -----------------------------------------------------------------------------
  114. inline void
  115. ssadd(std::string &sDst, const std::string &sSrc)
  116. {
  117. if (&sDst == &sSrc)
  118. {
  119. sDst.reserve(2 * sDst.size());
  120. }
  121. sDst.append(sSrc.c_str());
  122. }
  123. inline void
  124. ssadd(std::string &sDst, const char* pA)
  125. {
  126. if (pA)
  127. {
  128. // If the string being added is our internal string or a part of our
  129. // internal string, then we must NOT do any reallocation without
  130. // first copying that string to another object (since we're using a
  131. // direct pointer)
  132. if (pA >= sDst.c_str() && pA <= sDst.c_str() + sDst.length())
  133. {
  134. if (sDst.capacity() <= sDst.size() + sslen(pA))
  135. {
  136. sDst.append(std::string(pA));
  137. }
  138. else
  139. {
  140. sDst.append(pA);
  141. }
  142. }
  143. else
  144. {
  145. sDst.append(pA);
  146. }
  147. }
  148. }
  149. // -----------------------------------------------------------------------------
  150. // ssicmp: comparison (case insensitive )
  151. // -----------------------------------------------------------------------------
  152. template<typename CT>
  153. inline int
  154. ssicmp(const CT* pA1, const CT* pA2)
  155. {
  156. CT f;
  157. CT l;
  158. do
  159. {
  160. f = sstolower(*(pA1++));
  161. l = sstolower(*(pA2++));
  162. }
  163. while ((f) && (f == l));
  164. return (int)(f - l);
  165. }
  166. // -----------------------------------------------------------------------------
  167. // ssupr/sslwr: Uppercase/Lowercase conversion functions
  168. // -----------------------------------------------------------------------------
  169. template<typename CT>
  170. inline void
  171. sslwr(CT* pT, size_t nLen)
  172. {
  173. for (CT* p = pT; static_cast<size_t>(p - pT) < nLen; ++p)
  174. {
  175. *p = (CT)sstolower(*p);
  176. }
  177. }
  178. template<typename CT>
  179. inline void
  180. ssupr(CT* pT, size_t nLen)
  181. {
  182. for (CT* p = pT; static_cast<size_t>(p - pT) < nLen; ++p)
  183. {
  184. *p = (CT)sstoupper(*p);
  185. }
  186. }
  187. // -----------------------------------------------------------------------------
  188. // vsprintf/vswprintf or _vsnprintf/_vsnwprintf equivalents. In standard
  189. // builds we can't use _vsnprintf/_vsnwsprintf because they're MS extensions.
  190. // -----------------------------------------------------------------------------
  191. inline int
  192. ssvsprintf(char* pA, size_t nCount, const char* pFmtA, va_list vl)
  193. {
  194. return vsnprintf(pA, nCount, pFmtA, vl);
  195. }
  196. // Now we can define the template (finally!)
  197. // =============================================================================
  198. // TEMPLATE: CStdStr
  199. // template<typename CT> class CStdStr : public std::basic_string<CT>
  200. //
  201. // REMARKS:
  202. // This template derives from basic_string<CT> and adds some MFC RString-
  203. // like functionality
  204. //
  205. // Basically, this is my attempt to make Standard C++ library strings as
  206. // easy to use as the MFC RString class.
  207. //
  208. // Note that although this is a template, it makes the assumption that the
  209. // template argument (CT, the character type) is either char or wchar_t.
  210. // =============================================================================
  211. template<typename CT>
  212. class CStdStr;
  213. template<typename CT>
  214. inline CStdStr<CT>
  215. operator+(const CStdStr<CT> &str1, const CStdStr<CT> &str2)
  216. {
  217. CStdStr<CT> strRet(str1);
  218. strRet.append(str2);
  219. return strRet;
  220. }
  221. template<typename CT>
  222. inline CStdStr<CT>
  223. operator+(const CStdStr<CT> &str, CT t)
  224. {
  225. // this particular overload is needed for disabling reference counting
  226. // though it's only an issue from line 1 to line 2
  227. CStdStr<CT> strRet(str); // 1
  228. strRet.append(1, t); // 2
  229. return strRet;
  230. }
  231. template<typename CT>
  232. inline CStdStr<CT>
  233. operator+(const CStdStr<CT> &str, const char* pA)
  234. {
  235. return CStdStr<CT>(str) + CStdStr<CT>(pA);
  236. }
  237. template<typename CT>
  238. inline CStdStr<CT>
  239. operator+(const char* pA, const CStdStr<CT> &str)
  240. {
  241. CStdStr<CT> strRet(pA);
  242. strRet.append(str);
  243. return strRet;
  244. }
  245. template<typename CT>
  246. class CStdStr : public std::basic_string<CT>
  247. {
  248. // Typedefs for shorter names. Using these names also appears to help
  249. // us avoid some ambiguities that otherwise arise on some platforms
  250. typedef typename std::basic_string<CT> MYBASE; // my base class
  251. typedef CStdStr<CT> MYTYPE; // myself
  252. typedef typename MYBASE::const_pointer PCMYSTR; // const char*
  253. typedef typename MYBASE::pointer PMYSTR; // char*
  254. typedef typename MYBASE::iterator MYITER; // my iterator type
  255. typedef typename MYBASE::const_iterator MYCITER; // you get the idea...
  256. typedef typename MYBASE::reverse_iterator MYRITER;
  257. typedef typename MYBASE::size_type MYSIZE;
  258. typedef typename MYBASE::value_type MYVAL;
  259. typedef typename MYBASE::allocator_type MYALLOC;
  260. public:
  261. // CStdStr inline constructors
  262. CStdStr()
  263. {
  264. }
  265. CStdStr(const MYTYPE& str) : MYBASE(str)
  266. {
  267. }
  268. CStdStr(const std::string& str)
  269. {
  270. ssasn(*this, str);
  271. }
  272. CStdStr(PCMYSTR pT, MYSIZE n)
  273. : MYBASE(pT, n)
  274. {
  275. }
  276. CStdStr(const char* pA)
  277. {
  278. *this = pA;
  279. }
  280. CStdStr(MYCITER first, MYCITER last)
  281. : MYBASE(first, last)
  282. {
  283. }
  284. CStdStr(MYSIZE nSize, MYVAL ch, const MYALLOC& al=MYALLOC())
  285. : MYBASE(nSize, ch, al)
  286. {
  287. }
  288. MYTYPE& operator=(const MYTYPE& str)
  289. {
  290. ssasn(*this, str);
  291. return *this;
  292. }
  293. MYTYPE& operator=(const std::string& str)
  294. {
  295. ssasn(*this, str);
  296. return *this;
  297. }
  298. MYTYPE& operator=(const char* pA)
  299. {
  300. ssasn(*this, pA);
  301. return *this;
  302. }
  303. MYTYPE& operator=(CT t)
  304. {
  305. this->assign(1, t);
  306. return *this;
  307. }
  308. // -------------------------------------------------------------------------
  309. // CStdStr inline concatenation.
  310. // -------------------------------------------------------------------------
  311. MYTYPE& operator+=(const MYTYPE& str)
  312. {
  313. ssadd(*this, str);
  314. return *this;
  315. }
  316. MYTYPE& operator+=(const std::string& str)
  317. {
  318. ssadd(*this, str);
  319. return *this;
  320. }
  321. MYTYPE& operator+=(const char* pA)
  322. {
  323. ssadd(*this, pA);
  324. return *this;
  325. }
  326. MYTYPE& operator+=(CT t)
  327. {
  328. this->append(1, t);
  329. return *this;
  330. }
  331. // addition operators -- global friend functions.
  332. friend MYTYPE operator+ <>(const MYTYPE& str1, const MYTYPE& str2);
  333. friend MYTYPE operator+ <>(const MYTYPE& str, CT t);
  334. friend MYTYPE operator+ <>(const MYTYPE& str, const char* sz);
  335. friend MYTYPE operator+ <>(const char* pA, const MYTYPE& str);
  336. // -------------------------------------------------------------------------
  337. // Case changing functions
  338. // -------------------------------------------------------------------------
  339. MYTYPE& MakeUpper()
  340. {
  341. // Strictly speaking, this would be about the most portable way
  342. // std::transform(begin(),
  343. // end(),
  344. // begin(),
  345. // std::bind2nd(SSToUpper<CT>(), std::locale()));
  346. // But practically speaking, this works faster
  347. if ( !this->empty() )
  348. ssupr(GetBuf(), this->size());
  349. return *this;
  350. }
  351. MYTYPE& MakeLower()
  352. {
  353. // Strictly speaking, this would be about the most portable way
  354. // std::transform(begin(),
  355. // end(),
  356. // begin(),
  357. // std::bind2nd(SSToLower<CT>(), std::locale()));
  358. // But practically speaking, this works faster
  359. if ( !this->empty() )
  360. sslwr(GetBuf(), this->size());
  361. return *this;
  362. }
  363. // -------------------------------------------------------------------------
  364. // CStdStr -- Direct access to character buffer. In the MS' implementation,
  365. // the at() function that we use here also calls _Freeze() providing us some
  366. // protection from multithreading problems associated with ref-counting.
  367. // -------------------------------------------------------------------------
  368. CT* GetBuf(int nMinLen=-1)
  369. {
  370. if ( static_cast<int>(this->size()) < nMinLen )
  371. this->resize(static_cast<MYSIZE>(nMinLen));
  372. return this->empty() ? const_cast<CT*>(this->data()) : &(this->at(0));
  373. }
  374. void RelBuf(int nNewLen=-1)
  375. {
  376. this->resize(static_cast<MYSIZE>(nNewLen > -1 ? nNewLen : sslen(this->c_str())));
  377. }
  378. // -------------------------------------------------------------------------
  379. // FUNCTION: CStdStr::Format
  380. // void _cdecl Formst(CStdStringA& const char* szFormat, ...)
  381. // void _cdecl Format(const char* szFormat);
  382. //
  383. // DESCRIPTION:
  384. // This function does sprintf/wsprintf style formatting on CStdStringA
  385. // objects. It looks a lot like MFC's RString::Format. Some people
  386. // might even call this identical. Fortunately, these people are now
  387. // dead.
  388. //
  389. // PARAMETERS:
  390. // nId - ID of string resource holding the format string
  391. // szFormat - a const char* holding the format specifiers
  392. // argList - a va_list holding the arguments for the format specifiers.
  393. //
  394. // RETURN VALUE: None.
  395. // -------------------------------------------------------------------------
  396. // formatting (using wsprintf style formatting)
  397. // If they want a Format() function that safely handles string objects
  398. // without casting
  399. void Format(const CT* szFmt, ...)
  400. {
  401. va_list argList;
  402. va_start(argList, szFmt);
  403. FormatV(szFmt, argList);
  404. va_end(argList);
  405. }
  406. #define MAX_FMT_TRIES 5 // #of times we try
  407. #define FMT_BLOCK_SIZE 2048 // # of bytes to increment per try
  408. #define BUFSIZE_1ST 256
  409. #define BUFSIZE_2ND 512
  410. #define STD_BUF_SIZE 1024
  411. // -------------------------------------------------------------------------
  412. // FUNCTION: FormatV
  413. // void FormatV(const char* szFormat, va_list, argList);
  414. //
  415. // DESCRIPTION:
  416. // This function formats the string with sprintf style format-specs.
  417. // It makes a general guess at required buffer size and then tries
  418. // successively larger buffers until it finds one big enough or a
  419. // threshold (MAX_FMT_TRIES) is exceeded.
  420. //
  421. // PARAMETERS:
  422. // szFormat - a const char* holding the format of the output
  423. // argList - a Microsoft specific va_list for variable argument lists
  424. //
  425. // RETURN VALUE:
  426. // -------------------------------------------------------------------------
  427. void FormatV(const CT* szFormat, va_list argList)
  428. {
  429. static bool bExactSizeSupported;
  430. static bool bInitialized = false;
  431. if( !bInitialized )
  432. {
  433. /* Some systems return the actual size required when snprintf
  434. * doesn't have enough space. This lets us avoid wasting time
  435. * iterating, and wasting memory. */
  436. bInitialized = true;
  437. char ignore;
  438. bExactSizeSupported = ( snprintf( &ignore, 0, "Hello World" ) == 11 );
  439. }
  440. if( bExactSizeSupported )
  441. {
  442. va_list tmp;
  443. va_copy( tmp, argList );
  444. char ignore;
  445. int iNeeded = ssvsprintf( &ignore, 0, szFormat, tmp );
  446. va_end(tmp);
  447. char *buf = GetBuffer( iNeeded+1 );
  448. ssvsprintf( buf, iNeeded+1, szFormat, argList );
  449. ReleaseBuffer( iNeeded );
  450. return;
  451. }
  452. int nChars = FMT_BLOCK_SIZE;
  453. int nTry = 1;
  454. do
  455. {
  456. // Grow more than linearly (e.g. 512, 1536, 3072, etc)
  457. char *buf = GetBuffer(nChars);
  458. int nUsed = ssvsprintf(buf, nChars-1, szFormat, argList);
  459. if(nUsed == -1)
  460. {
  461. nChars += ((nTry+1) * FMT_BLOCK_SIZE);
  462. ReleaseBuffer();
  463. continue;
  464. }
  465. /* OK */
  466. ReleaseBuffer(nUsed);
  467. break;
  468. } while ( nTry++ < MAX_FMT_TRIES );
  469. }
  470. // -------------------------------------------------------------------------
  471. // RString Facade Functions:
  472. //
  473. // The following methods are intended to allow you to use this class as a
  474. // drop-in replacement for CString.
  475. // -------------------------------------------------------------------------
  476. int CompareNoCase(PCMYSTR szThat) const
  477. {
  478. return ssicmp(this->c_str(), szThat);
  479. }
  480. bool EqualsNoCase(PCMYSTR szThat) const
  481. {
  482. return CompareNoCase(szThat) == 0;
  483. }
  484. // -------------------------------------------------------------------------
  485. // GetXXXX -- Direct access to character buffer
  486. // -------------------------------------------------------------------------
  487. CT* GetBuffer(int nMinLen=-1)
  488. {
  489. return GetBuf(nMinLen);
  490. }
  491. MYTYPE Left(int nCount) const
  492. {
  493. // Range check the count.
  494. nCount = std::max(0, std::min(nCount, static_cast<int>(this->size())));
  495. return this->substr(0, static_cast<MYSIZE>(nCount));
  496. }
  497. void MakeReverse()
  498. {
  499. std::reverse(this->begin(), this->end());
  500. }
  501. void ReleaseBuffer(int nNewLen=-1)
  502. {
  503. RelBuf(nNewLen);
  504. }
  505. int Replace(CT chOld, CT chNew)
  506. {
  507. int nReplaced = 0;
  508. for ( MYITER iter=this->begin(); iter != this->end(); iter++ )
  509. {
  510. if ( *iter == chOld )
  511. {
  512. *iter = chNew;
  513. nReplaced++;
  514. }
  515. }
  516. return nReplaced;
  517. }
  518. int Replace(PCMYSTR szOld, PCMYSTR szNew)
  519. {
  520. int nReplaced = 0;
  521. MYSIZE nIdx = 0;
  522. MYSIZE nOldLen = sslen(szOld);
  523. if ( 0 == nOldLen )
  524. return 0;
  525. static const CT ch = CT(0);
  526. MYSIZE nNewLen = sslen(szNew);
  527. PCMYSTR szRealNew = szNew == 0 ? &ch : szNew;
  528. while ( (nIdx=this->find(szOld, nIdx)) != MYBASE::npos )
  529. {
  530. replace(this->begin()+nIdx, this->begin()+nIdx+nOldLen, szRealNew);
  531. nReplaced++;
  532. nIdx += nNewLen;
  533. }
  534. return nReplaced;
  535. }
  536. MYTYPE Right(int nCount) const
  537. {
  538. // Range check the count.
  539. nCount = std::max(0, std::min(nCount, static_cast<int>(this->size())));
  540. return this->substr(this->size()-static_cast<MYSIZE>(nCount));
  541. }
  542. // Array-indexing operators. Required because we defined an implicit cast
  543. // to operator const CT* (Thanks to Julian Selman for pointing this out)
  544. CT& operator[](int nIdx)
  545. {
  546. return MYBASE::operator[](static_cast<MYSIZE>(nIdx));
  547. }
  548. const CT& operator[](int nIdx) const
  549. {
  550. return MYBASE::operator[](static_cast<MYSIZE>(nIdx));
  551. }
  552. CT& operator[](unsigned int nIdx)
  553. {
  554. return MYBASE::operator[](static_cast<MYSIZE>(nIdx));
  555. }
  556. const CT& operator[](unsigned int nIdx) const
  557. {
  558. return MYBASE::operator[](static_cast<MYSIZE>(nIdx));
  559. }
  560. CT& operator[](long unsigned int nIdx){
  561. return MYBASE::operator[](static_cast<MYSIZE>(nIdx));
  562. }
  563. const CT& operator[](long unsigned int nIdx) const {
  564. return MYBASE::operator[](static_cast<MYSIZE>(nIdx));
  565. }
  566. operator const CT*() const
  567. {
  568. return this->c_str();
  569. }
  570. };
  571. // =============================================================================
  572. // END OF CStdStr INLINE FUNCTION DEFINITIONS
  573. // =============================================================================
  574. // Now typedef our class names based upon this humongous template
  575. typedef CStdStr<char> CStdString; // a better std::string
  576. // -----------------------------------------------------------------------------
  577. // FUNCTIONAL COMPARATORS:
  578. // REMARKS:
  579. // These structs are derived from the std::binary_function template. They
  580. // give us functional classes (which may be used in Standard C++ Library
  581. // collections and algorithms) that perform case-insensitive comparisons of
  582. // CStdString objects. This is useful for maps in which the key may be the
  583. // proper string but in the wrong case.
  584. // -----------------------------------------------------------------------------
  585. struct StdStringLessNoCase
  586. : std::binary_function<CStdString, CStdString, bool>
  587. {
  588. inline bool
  589. operator()(const CStdString& sLeft, const CStdString& sRight) const
  590. { return ssicmp(sLeft.c_str(), sRight.c_str()) < 0; }
  591. };
  592. struct StdStringEqualsNoCase
  593. : std::binary_function<CStdString, CStdString, bool>
  594. {
  595. inline bool
  596. operator()(const CStdString& sLeft, const CStdString& sRight) const
  597. { return ssicmp(sLeft.c_str(), sRight.c_str()) == 0; }
  598. };
  599. } // namespace StdString
  600. typedef StdString::CStdString RString;
  601. #endif // #ifndef STDSTRING_H
  602. /*
  603. * COPYRIGHT:
  604. * 1999 Joseph M. O'Leary. This code is free. Use it anywhere you want.
  605. * Rewrite it, restructure it, whatever. Please don't blame me if it makes
  606. * your $30 billion dollar satellite explode in orbit. If you redistribute
  607. * it in any form, I'd appreciate it if you would leave this notice here.
  608. *
  609. * If you find any bugs, please let me know:
  610. *
  611. * jmoleary@earthlink.net
  612. * http://home.earthlink.net/~jmoleary
  613. */