home *** CD-ROM | disk | FTP | other *** search
/ ftp.funduc.com / 2014.08.ftp.funduc.com.tar / ftp.funduc.com / fshedcode102502.zip / Simparr.h < prev    next >
C/C++ Source or Header  |  2001-04-20  |  17KB  |  766 lines

  1. //=========================================================
  2. // File: simparr.h
  3.  
  4. #if !defined(__SIMPLEARRAY_H)
  5. #define __SIMPLEARRAY_H
  6.  
  7. #define ARR_EMPTY -1
  8.  
  9. #include <string.h>
  10.  
  11. #define bitval(base,pos) ((base)[(pos)/8]&(1<<((pos)%8)))
  12. #define CLIENT_BORDER_WIDTH 2
  13. #define ANSI_SET ANSI_FIXED_FONT
  14. #define OEM_SET  OEM_FIXED_FONT
  15. #define LITTLEENDIAN_MODE    0
  16. #define BIGENDIAN_MODE 1
  17. #define TIMERID 1
  18. #define TIMERDURATION 10
  19. #define MRUMAX 9
  20. #define BMKMAX 9
  21. #define BMKTEXTMAX 256
  22. #define TPL_TYPE_MAXLEN 16
  23. #define TPL_NAME_MAXLEN 128
  24. #define FINDDLG_BUFLEN (64*1024)
  25.  
  26. template<class T> class SimpleArray
  27. {
  28. public:
  29.     operator T*()
  30.     {
  31.         return m_pT;
  32.     }
  33.     T& operator[](int nIndex) {return m_pT[nIndex];}
  34.  
  35. SimpleArray()
  36. {
  37.     m_pT = NULL;
  38.     m_nSize = 0;
  39.     m_nUpperBound = ARR_EMPTY;
  40.     m_nGrowBy = 1;
  41. }
  42.  
  43. //-------------------------------------------------------------------
  44. SimpleArray(int nNewSize, int nGrowBy)
  45. : m_nGrowBy(nGrowBy), m_nUpperBound(ARR_EMPTY), m_nSize(nNewSize)
  46. {
  47.     m_pT = new T[m_nSize];
  48. }
  49.  
  50. //-------------------------------------------------------------------
  51. SimpleArray(T* ptArray, int upbound, int size)
  52. : m_nGrowBy(1), m_pT(ptArray), m_nUpperBound(upbound), m_nSize(size)
  53. {
  54. #ifdef _DEBUG
  55.     if(m_pT == NULL || m_nUpperBound<0 || m_nSize<=0 || m_nUpperBound >= m_nSize)
  56.     {
  57.         m_nSize = 0;
  58.         m_nUpperBound = ARR_EMPTY;
  59.     }
  60. #endif
  61. }
  62.  
  63. //-------------------------------------------------------------------
  64. SimpleArray(SimpleArray& spaArg)
  65.     : m_nSize(spaArg.m_nSize), m_nUpperBound(spaArg.m_nUpperBound),
  66.     m_nGrowBy(spaArg.m_nGrowBy)
  67. {
  68.     m_pT = new T[m_nSize];
  69.     int k;
  70.     for(k = 0; k <= m_nUpperBound; k++)
  71.         m_pT[k] = spaArg.m_pT[k];
  72. }
  73.  
  74. //-------------------------------------------------------------------
  75. ~SimpleArray()
  76. {
  77.     if(m_pT != NULL) delete [] m_pT;
  78. }
  79.  
  80. //-------------------------------------------------------------------
  81. BOOL InsertAtGrow(int nIndex, T argT, int nCount = 1)
  82. {
  83.     if(nIndex<0 || nCount<1)
  84.         return FALSE;
  85.     int i;
  86.     if(nIndex > m_nUpperBound)
  87.     {
  88.         for(i = 0; i < nCount; i++)
  89.             SetAtGrow(nIndex + i, argT);
  90.         return TRUE;
  91.     }
  92.     else
  93.     {
  94.         if(m_nSize < m_nUpperBound + 1 + nCount)
  95.         {
  96.             if (AddSpace(nCount) == FALSE)
  97.                 return FALSE;
  98.         }
  99.         for(i = m_nUpperBound + nCount; i > nIndex; i--)
  100.         {
  101.             m_pT[i] = m_pT[i-nCount];
  102.         }
  103.         for(i = 0; i < nCount; i++)
  104.             m_pT[nIndex + i] = argT;
  105.         m_nUpperBound += nCount;
  106.         return TRUE;
  107.     }
  108. }
  109.  
  110. //-------------------------------------------------------------------
  111. BOOL InsertAtGrow (int nIndex, T* pT, int nSrcIndex, int nCount)
  112. {
  113.     if(nIndex<0 || nCount<1)
  114.         return FALSE;
  115.     int i;
  116.     if(nIndex > m_nUpperBound)
  117.     {
  118.         for(i = 0; i < nCount; i++)
  119.         {
  120.             if (SetAtGrowRef(nIndex + i, pT[nSrcIndex+i]) == FALSE)
  121.                 return FALSE;
  122.         }
  123.         return TRUE;
  124.     }
  125.     else
  126.     {
  127.         if(m_nSize < m_nUpperBound + 1 + nCount)
  128.         {
  129.             if (AddSpace(nCount) == FALSE)
  130.                 return FALSE;
  131.         }
  132.         for(i = m_nUpperBound + nCount; i > nIndex; i--)
  133.         {
  134.             m_pT[i] = m_pT[i-nCount];
  135.         }
  136.         for(i = 0; i < nCount; i++)
  137.             m_pT[nIndex + i] = pT[nSrcIndex+i];
  138.         m_nUpperBound += nCount;
  139.         return TRUE;
  140.     }
  141. }
  142.  
  143. //-------------------------------------------------------------------
  144. void InsertAtGrowRef(int nIndex, T& argT, int nCount = 1)
  145. {
  146.     if(nIndex<0 || nCount<1) return;
  147.     int i;
  148.     if(nIndex > m_nUpperBound)
  149.     {
  150.         for(i = 0; i < nCount; i++)
  151.             SetAtGrowRef(nIndex + i, argT);
  152.         return;
  153.     }
  154.     else
  155.     {
  156.         if(m_nSize < m_nUpperBound + 1 + nCount)
  157.             AddSpace(nCount);
  158.         for(i = m_nUpperBound + nCount; i > nIndex; i--)
  159.         {
  160.             m_pT[i] = m_pT[i-nCount];
  161.         }
  162.         for(i = 0; i < nCount; i++)
  163.             m_pT[nIndex + i] = argT;
  164.         m_nUpperBound += nCount;
  165.     }
  166. }
  167.  
  168. //-------------------------------------------------------------------
  169. BOOL InsertAt( int nIndex, T argT, int nCount = 1)
  170. {
  171.     // Valid index?
  172.     if( nIndex < 0 || nIndex > m_nUpperBound )
  173.         return FALSE;
  174.  
  175.     int i;
  176.     // Is there enough space after m_nUpperBound for inserting?
  177.     if( ( m_nSize - 1 ) - m_nUpperBound >= nCount )
  178.     {
  179.         // Yes, no need to allocate more memory.
  180.         // Push up the elements at the current position.
  181.         for( i = m_nUpperBound + nCount; i >= nIndex + nCount; i-- )
  182.             m_pT[ i ] = m_pT[ i - nCount ];
  183.         // Copy in the new data.
  184.         for( i = 0; i < nCount; i++ )
  185.             m_pT[ nIndex + i ] = argT;
  186.         // Adjust m_nUpperBound to new size.
  187.         m_nUpperBound += nCount;
  188.     }
  189.     else
  190.     {
  191.         // No, need to allocate more memory.
  192.         for (i = m_nSize - 1; i >= nIndex + nCount; i--)
  193.             m_pT[i] = m_pT[i - nCount];
  194.         if (m_nSize - nIndex < nCount)
  195.             nCount = m_nSize - nIndex;
  196.         for (i = 0; i < nCount; i++)
  197.             m_pT[nIndex + i] = argT;
  198.         m_nUpperBound = m_nSize - 1;        
  199.     }
  200.     return TRUE;
  201. }
  202.  
  203. //-------------------------------------------------------------------
  204. void InsertAtRef(int nIndex, T& argT, int nCount)
  205. {
  206.     if(nIndex < 0 || nIndex > m_nUpperBound)
  207.         return;
  208.     int i;
  209.     if ((m_nSize - 1) - m_nUpperBound >= nCount) 
  210.     {
  211.         for(i = m_nUpperBound + nCount; i >= nIndex + nCount; i--)
  212.             m_pT[i] = m_pT[i - nCount];
  213.         for(i = 0; i < nCount; i++)
  214.             m_pT[nIndex + i] = argT;
  215.         m_nUpperBound += nCount;
  216.     }
  217.     else
  218.     {
  219.         for (i = m_nSize - 1; i >= nIndex + nCount; i--)
  220.             m_pT[i] = m_pT[i - nCount];
  221.         if (m_nSize - nIndex < nCount)
  222.             nCount = m_nSize - nIndex;
  223.         for (i = 0; i < nCount; i++)
  224.             m_pT[nIndex + i] = argT;
  225.         m_nUpperBound = m_nSize - 1;        
  226.     }
  227. }
  228.  
  229. //-------------------------------------------------------------------
  230. BOOL RemoveAt(int nIndex, int nCount = 1)
  231. {
  232.     if(nIndex < 0 || nIndex > m_nUpperBound || nCount < 1) return FALSE;
  233.     if(nCount > m_nUpperBound - nIndex)
  234.     {
  235.         m_nUpperBound = nIndex - 1;
  236.         return TRUE;
  237.     }
  238.     int i;
  239.     for(i = nIndex; i <= m_nUpperBound - nCount; i++)
  240.     {
  241.         m_pT[i] = m_pT[i + nCount];
  242.     }
  243.     m_nUpperBound -= nCount;
  244.     return TRUE;
  245. }
  246.  
  247. //-------------------------------------------------------------------
  248. void SetAtGrow(int nIndex, T argT)
  249. {
  250.     if(nIndex < 0) return;
  251.     if(nIndex > m_nSize - 1)
  252.         AddSpace(nIndex - m_nSize + 1);
  253.     m_pT[nIndex] = argT;
  254.     if(nIndex > m_nUpperBound) m_nUpperBound = nIndex;
  255. }
  256.  
  257. //-------------------------------------------------------------------
  258. BOOL SetAtGrowRef(int nIndex, T& argT)
  259. {
  260.     if(nIndex < 0)
  261.         return FALSE;
  262.     if(nIndex > m_nSize - 1)
  263.     {
  264.         if (AddSpace(nIndex - m_nSize + 1) == FALSE)
  265.             return FALSE;
  266.     }
  267.     m_pT[nIndex] = argT;
  268.     if(nIndex > m_nUpperBound)
  269.         m_nUpperBound = nIndex;
  270.     return TRUE;
  271. }
  272.  
  273. //-------------------------------------------------------------------
  274. void SetAt(int nIndex, T argT)
  275. {
  276.     if(nIndex >= 0 && nIndex < m_nSize)
  277.     {
  278.         m_pT[nIndex] = argT;
  279.         if(nIndex > m_nUpperBound)
  280.             m_nUpperBound = nIndex;
  281.     }
  282.     else
  283.         return;
  284. }
  285.  
  286. //-------------------------------------------------------------------
  287. void SetAtRef(int nIndex, T& argT)
  288. {
  289.     if(nIndex >= 0 && nIndex < m_nSize)
  290.     {
  291.         m_pT[nIndex] = argT;
  292.         if(nIndex > m_nUpperBound)
  293.             m_nUpperBound = nIndex;
  294.     }
  295.     else
  296.         return;
  297. }
  298.  
  299. //-------------------------------------------------------------------
  300. T GetAt(int nIndex)
  301. {
  302.     return m_pT[nIndex];
  303. }
  304.  
  305. //-------------------------------------------------------------------
  306. BOOL AddSpace(int nExtend)
  307. {
  308.     int newsize = m_nSize + (((nExtend-1) / m_nGrowBy) + 1) * m_nGrowBy;
  309.     T* pT = new T[newsize];
  310.     if (pT != NULL)
  311.     {
  312.         int i;
  313.         for(i = 0; i < m_nSize; i++)
  314.             pT[i] = m_pT[i];
  315.         if(m_pT != NULL)
  316.             delete [] m_pT;
  317.         m_pT = pT;
  318.         m_nSize = newsize;
  319.         return TRUE;
  320.     }
  321.     else
  322.         return FALSE;
  323. }
  324.  
  325. //-------------------------------------------------------------------
  326. int GetGrowBy()
  327. {
  328.     return m_nGrowBy;
  329. }
  330.  
  331. //-------------------------------------------------------------------
  332. int GetSize()
  333. {
  334.     return m_nSize;
  335. }
  336.  
  337. //-------------------------------------------------------------------
  338. int GetUpperBound()
  339. {
  340.     return m_nUpperBound;
  341. }
  342.  
  343. //-------------------------------------------------------------------
  344. int GetLength()
  345. {
  346.     return m_nUpperBound+1;
  347. }
  348.  
  349. //-------------------------------------------------------------------
  350. BOOL SetSize(int nNewSize, int nGrowBy = 0 )
  351. {
  352.     if(nNewSize < 0)
  353.         return FALSE;
  354.     if (nNewSize == m_nSize)
  355.         return TRUE;
  356.     if( nNewSize == 0 )
  357.     {
  358.         ClearAll();
  359.         return TRUE;
  360.     }
  361.  
  362.     T* pT = new T[nNewSize];
  363.     if (pT == NULL)
  364.         return FALSE;
  365.     int i;
  366.     if(m_nUpperBound < nNewSize)
  367.     {
  368.         for(i = 0; i <= m_nUpperBound; i++)
  369.             pT[i] = m_pT[i];
  370.     }
  371.     else
  372.     {
  373.         for(i = 0; i < nNewSize; i++)
  374.             pT[i] = m_pT[i];
  375.         m_nUpperBound = nNewSize - 1;
  376.     }
  377.  
  378.     if(m_pT != NULL)
  379.         delete [] m_pT;
  380.     m_pT = pT;
  381.     m_nSize = nNewSize;
  382.     if(nGrowBy > 0)
  383.         m_nGrowBy = nGrowBy;
  384.     return TRUE;
  385. }
  386.  
  387. //-------------------------------------------------------------------
  388. void SetGrowBy(int nGrowBy)
  389. {
  390.     if(nGrowBy > 0) m_nGrowBy = nGrowBy;
  391. }
  392.  
  393. //-------------------------------------------------------------------
  394. void ClearAll()
  395. {
  396.     if(m_pT != NULL)
  397.         delete [] m_pT;
  398.     m_pT = NULL;
  399.     m_nSize = 0;
  400.     m_nUpperBound = ARR_EMPTY;
  401. }
  402.  
  403. //-------------------------------------------------------------------
  404. BOOL blContainsRef(T& argT)
  405. {
  406.     int i;
  407.     for(i = 0; i <= m_nUpperBound; i++)
  408.         if(argT == m_pT[i])
  409.             return TRUE;
  410.     return FALSE;
  411. }
  412.  
  413. //-------------------------------------------------------------------
  414. BOOL blContains(T argT)
  415. {
  416.     int i;
  417.     for(i = 0; i <= m_nUpperBound; i++)
  418.         if(argT == m_pT[i])
  419.             return TRUE;
  420.     return FALSE;
  421. }
  422.  
  423. //-------------------------------------------------------------------
  424. int nContainsAt(T argT)
  425. {
  426.     int i;
  427.     for(i = 0; i <= m_nUpperBound; i++)
  428.         if(argT == m_pT[i])
  429.             return i;
  430.     return ARR_EMPTY;
  431. }
  432.  
  433. //-------------------------------------------------------------------
  434. // Make a copy of the other SimpleArray.
  435. SimpleArray<T>& operator=( SimpleArray<T>& spa )
  436. {
  437.     // Can't assign to itself: "sa1 = sa1;" not allowed.
  438.     if( &spa != this )
  439.     {
  440.         // If this array is not empty then delete it.
  441.         ClearAll();
  442.         // Allocate memory.
  443.         m_pT = new T[ m_nSize ];
  444.         // Copy the valid elements.
  445.         if( m_pT != NULL )
  446.         {
  447.             // This array now is just large enough to contain the valid elements of spa.
  448.             m_nUpperBound = spa.m_nUpperBound;
  449.             m_nSize = m_nUpperBound + 1;
  450.             // GrowBy rate is also copied.
  451.             m_nGrowBy = spa.m_nGrowBy;
  452.             int k;
  453.             for(k = 0; k <= m_nUpperBound; k++)
  454.                 m_pT[k] = spa.m_pT[k];
  455.         }
  456.         // If no memory could be allocated, then this array remains empty.
  457.     }
  458.     return *this;
  459. }
  460.  
  461. //-------------------------------------------------------------------
  462. void AppendRef(T& argT)
  463. {
  464.     SetAt(m_nUpperBound+1, argT);
  465. }
  466.  
  467. //-------------------------------------------------------------------
  468. void Append(T argT)
  469. {
  470.     SetAtGrow(m_nUpperBound+1, argT);
  471. }
  472.  
  473. //-------------------------------------------------------------------
  474. T& GetRefAt(int nIndex)
  475. {
  476.     return m_pT[nIndex];
  477. }
  478.  
  479. //-------------------------------------------------------------------
  480. BOOL blCompare(SimpleArray<T>& spa)
  481. {
  482.     if(m_nUpperBound != spa.GetUpperBound() ) return FALSE;
  483.     int k;
  484.     for(k = 0; k <= m_nUpperBound; k++)
  485.     {
  486.         if(m_pT[k] != spa[k]) return FALSE;
  487.     }
  488.     return TRUE;
  489. }
  490.  
  491. //-------------------------------------------------------------------
  492. operator==(SimpleArray<T>& spa)
  493. {
  494.     return blCompare(spa);
  495. }
  496.  
  497. //-------------------------------------------------------------------
  498. operator!=(SimpleArray<T>& spa)
  499. {
  500.     return !blCompare(spa);
  501. }
  502.  
  503. //-------------------------------------------------------------------
  504. BOOL blIsEmpty()
  505. {
  506.     return (GetUpperBound() < 0) ? TRUE : FALSE;
  507. }
  508.  
  509. //-------------------------------------------------------------------
  510. void Exchange(int nIndex1, int nIndex2)
  511. {
  512.     T temp(GetRefAt(nIndex2));
  513.     GetRefAt(nIndex2) = GetRefAt(nIndex1);
  514.     GetRefAt(nIndex1) = temp;
  515. }
  516.  
  517. //-------------------------------------------------------------------
  518. BOOL Adopt(T* ptArray, int upbound, int size)
  519. {
  520. #ifdef _DEBUG
  521.     if(ptArray == NULL || upbound<0 || size<=0 || upbound >= size)
  522.         return FALSE;
  523. #endif
  524.     if(m_pT!=NULL)
  525.         delete [] m_pT;
  526.     m_pT = ptArray;
  527.     m_nSize = size;
  528.     m_nUpperBound = upbound;
  529.     return TRUE;
  530. }
  531.  
  532. //-------------------------------------------------------------------
  533. void SetUpperBound(int upbnd)
  534. {
  535.     if(upbnd < m_nSize)
  536.         m_nUpperBound = upbnd;
  537. }
  538.  
  539. //-------------------------------------------------------------------
  540. BOOL AppendArray( T* pSrc, int srclen )
  541. {
  542.     if( srclen <= 0 )
  543.         return FALSE;
  544.  
  545.     if( m_nUpperBound + 1 + srclen > m_nSize )
  546.     {
  547.         // Not enough space, so get some.
  548.         if( !AddSpace( srclen ) )
  549.             return FALSE;
  550.     }
  551.     // Enough space to append without growing. Copy the data.
  552.     int i;
  553.     for( i=0; i<srclen; i++ )
  554.     {
  555.         m_pT[ m_nUpperBound + 1 + i ] = pSrc[i];
  556.     }
  557.     m_nUpperBound += srclen;
  558.     return TRUE;
  559. }
  560.  
  561. //-------------------------------------------------------------------
  562. BOOL ExpandToSize()
  563. {
  564.     m_nUpperBound = m_nSize - 1;
  565.     return TRUE;
  566. }
  567.  
  568. //-------------------------------------------------------------------
  569. BOOL CopyFrom( int index, T* pSrc, int srclen )
  570. {
  571.     if( m_nSize - index >= srclen )
  572.     {
  573.         // Enough space to copy into.
  574.         int i;
  575.         for( i = 0; i < srclen; i++ )
  576.             m_pT[ index + i ] = pSrc[ i ];
  577.         if( index + srclen - 1 > m_nUpperBound )
  578.             m_nUpperBound = index + srclen - 1;
  579.         return TRUE;
  580.     }
  581.     else
  582.         return FALSE;
  583. }
  584. //-------------------------------------------------------------------
  585. BOOL Replace( int ToReplaceIndex, int ToReplaceLength, T* pReplaceWith, int ReplaceWithLength )
  586. {
  587.     if( m_pT != NULL && ToReplaceLength > 0 )
  588.     {
  589.         // Number of elements from start to end of array large enough for request?
  590.         if( m_nUpperBound - ToReplaceIndex + 1 >= ToReplaceLength )
  591.         {
  592.             if( ToReplaceLength < ReplaceWithLength )
  593.             {
  594.                 int i;
  595.                 T dummy;
  596.  
  597.                 // Next line might cause problems if used with non-pure-binary
  598.                 // objects.
  599.                 dummy = 0;
  600.  
  601.                 InsertAtGrow( ToReplaceIndex, dummy, ReplaceWithLength - ToReplaceLength );
  602.                 for( i = 0; i < ReplaceWithLength; i++ )
  603.                 {
  604.                     m_pT[ ToReplaceIndex + i ] = pReplaceWith[ i ];
  605.                 }
  606.  
  607.                 return TRUE;
  608.             }
  609.             else if( ToReplaceLength == ReplaceWithLength )
  610.             {
  611.                 int i;
  612.                 for( i = 0; i < ReplaceWithLength; i++ )
  613.                 {
  614.                     m_pT[ ToReplaceIndex + i ] = pReplaceWith[ i ];
  615.                 }
  616.                 return TRUE;
  617.             }
  618.             else // if( ToReplaceLength > ReplaceWithLength )
  619.             {
  620.                 int i;
  621.                 for( i = 0; i < ReplaceWithLength; i++ )
  622.                 {
  623.                     m_pT[ ToReplaceIndex + i ] = pReplaceWith[ i ];
  624.                 }
  625.  
  626.                 RemoveAt( ToReplaceIndex + ReplaceWithLength, ToReplaceLength - ReplaceWithLength );
  627.                 return TRUE;
  628.             }
  629.         }
  630.         else
  631.         {
  632.             return FALSE;
  633.         }
  634.     }
  635.     else
  636.     {
  637.         return FALSE;
  638.     }
  639. }
  640. protected:
  641.     T* m_pT;
  642.     int m_nSize;
  643.     int m_nUpperBound;
  644.     int m_nGrowBy;
  645. };
  646.  
  647. // A string class.
  648. class SimpleString : public SimpleArray<char>
  649. {
  650. public:
  651.  
  652. //-------------------------------------------------------------------
  653. int SimpleString::AppendString( char* ps )
  654. {
  655.     if( m_nUpperBound == -1 )
  656.         return SetToString( ps );
  657.     else
  658.     {
  659.         InsertAtGrow( m_nUpperBound, ps, 0, strlen( ps ) );
  660.     }
  661.     return TRUE;
  662. }
  663.  
  664. //-------------------------------------------------------------------
  665. int SimpleString::SetToString( char* ps )
  666. {
  667.     Clear();
  668.     return AppendString( ps );
  669. }
  670.  
  671. //-------------------------------------------------------------------
  672. char* SimpleString::operator=( char* ps )
  673. {
  674.     SetToString( ps );
  675.     return ps;
  676. }
  677.  
  678. //-------------------------------------------------------------------
  679. SimpleString& SimpleString::operator=( SimpleString str )
  680. {
  681.     SetToString( &str[0] );
  682.     return *this;
  683. }
  684.  
  685. //-------------------------------------------------------------------
  686. char* SimpleString::operator+=( char* ps )
  687. {
  688.     if( m_nUpperBound == -1 )
  689.         SetToString( ps );
  690.     else
  691.     {
  692.         InsertAtGrow( m_nUpperBound, ps, 0, strlen( ps ) );
  693.     }
  694.     return ps;
  695. }
  696.  
  697. //-------------------------------------------------------------------
  698. int SimpleString::StrLen()
  699. {
  700.     if( m_pT != NULL )
  701.         return strlen( m_pT );
  702.     else
  703.         return 0;
  704. }
  705.  
  706. //-------------------------------------------------------------------
  707. SimpleString::SimpleString()
  708. {
  709.     // Create a string containing only a zero-byte.
  710.     m_nGrowBy = 64;
  711.     Clear();
  712. }
  713.  
  714. //-------------------------------------------------------------------
  715. SimpleString::SimpleString( char* ps )
  716. {
  717.     // Create a SimpleString from a normal char array-string.
  718.     m_nGrowBy = 64;
  719.     Clear();
  720.     SetToString( ps );
  721. }
  722.  
  723. //-------------------------------------------------------------------
  724. void SimpleString::Clear()
  725. {
  726.     ClearAll();
  727.     Append( '\0' );
  728. }
  729.  
  730. //-------------------------------------------------------------------
  731. SimpleString SimpleString::operator+( SimpleString& str1 )
  732. {
  733.     SimpleString t1;
  734.     t1.SetToString( m_pT );
  735.     t1 += str1;
  736.     return SimpleString( &t1[0] );
  737. }
  738.  
  739. //-------------------------------------------------------------------
  740. int SimpleString::IsEmpty()
  741. {
  742.     return !StrLen();
  743. }
  744.  
  745. };
  746.  
  747. //-------------------------------------------------------------------
  748. inline SimpleString operator+( SimpleString ps1, char* ps2 )
  749. {
  750.     SimpleString s1;
  751.     s1 += ps1;
  752.     s1 += ps2;
  753.     return SimpleString(s1);
  754. }
  755.  
  756. //-------------------------------------------------------------------
  757. inline SimpleString operator+( char* ps1, SimpleString ps2 )
  758. {
  759.     SimpleString s1;
  760.     s1 += ps1;
  761.     s1 += ps2;
  762.     return SimpleString(s1);
  763. }
  764.  
  765. #endif // #if !defined(__SIMPLEARRAY_H)
  766.