mi32/fixedstr.h

Go to the documentation of this file.
00001 /**
00002 *  mi32/fixedstr.h - FIXEDSTRING<> template class.
00003 *
00004 *  \if NODOC
00005 *  $Id: fixedstr.h_v 1.50 2003/11/19 23:03:08 scowan Exp $
00006 *
00007 *  $Log: fixedstr.h_v $
00008 *  Revision 1.50  2003/11/19 23:03:08  scowan
00009 *  Comment out cast operator to mistring.
00010 *
00011 *  Revision 1.49  2003/09/15 13:49:56  fileserver!dwilliss
00012 *  Doxygen
00013 *
00014 *  Revision 1.48  2003/04/15 17:06:40  scowan
00015 *  Make sure string is cleared to zero from the terminator to the end in generate unique name.
00016 *
00017 *  Revision 1.47  2003/04/15 16:33:59  scowan
00018 *  Added a generate unique name method with filter.
00019 *
00020 *  Revision 1.46  2003/04/10 15:55:58  scowan
00021 *  nc.
00022 *
00023 *  Revision 1.45  2003/04/10 15:42:09  dwilliss
00024 *  Don't use _T in templates.  Mac's ctype.h defines a global _T
00025 *
00026 *  Revision 1.44  2003/02/06 17:33:27  scowan
00027 *  Made get max size a static method.
00028 *
00029 *  Revision 1.43  2002/09/09 13:21:52  mju
00030 *  Remove deprecated methods.
00031 *
00032 *  Revision 1.42  2002/08/28 13:34:25  mju
00033 *  Remove prompt stuff as causes lots of header conflicts with Windows.
00034 *
00035 *  Revision 1.41  2002/08/27 16:58:25  mju
00036 *  Use Widget, not MDLGPARENT.
00037 *
00038 *  Revision 1.40  2002/08/27 14:13:57  scowan
00039 *  Hack for lack of function template support in some compilers.
00040 *
00041 *  Revision 1.39  2002/08/22 19:38:43  scowan
00042 *  Damn annoying compilers.  Made the concatinate operator work again.
00043 *
00044 *  Revision 1.38  2002/08/22 19:02:59  scowan
00045 *  Oops.
00046 *
00047 *  Revision 1.37  2002/08/22 17:33:46  scowan
00048 *  UNIX compiler confusion.
00049 *
00050 *  Revision 1.36  2002/08/22 17:07:06  scowan
00051 *  *** empty log message ***
00052 *
00053 *  Revision 1.35  2002/08/22 17:05:52  scowan
00054 *  Check for null in constructor.
00055 *
00056 *  Revision 1.34  2002/08/19 15:38:22  scowan
00057 *  Fixed g++3.1 warnings.
00058 *
00059 *  Revision 1.33  2002/07/08 14:49:16  scowan
00060 *  nc.
00061 *
00062 *  Revision 1.32  2002/05/17 17:37:29  mju
00063 *  Add GetTail() methods.
00064 *
00065 *  Revision 1.31  2002/05/17 16:53:55  mju
00066 *  Add FIXEDSTRCHAR template defn.
00067 *
00068 *  Revision 1.30  2002/05/02 16:03:46  scowan
00069 *  Nothing.
00070 *
00071 *  Revision 1.29  2002/04/25 22:07:24  mju
00072 *  Remove confusing comment.
00073 *
00074 *  Revision 1.28  2002/04/08 16:48:04  mju
00075 *  Remove sprintf methods.
00076 *
00077 *  Revision 1.27  2002/04/08 16:01:45  mju
00078 *  Add dEPRECATE_FIXEDSTR check.
00079 *
00080 *  Revision 1.26  2002/04/04 22:10:36  mju
00081 *  Remove AssignMsgf as no longer used.
00082 *
00083 *  Revision 1.24  2002/03/28 15:05:02  scowan
00084 *  Deprecated assign message.
00085 *
00086 *  Revision 1.23  2002/03/27 16:36:19  mju
00087 *  Add ctor, op= using TEXTID.
00088 *  Deprecate varargs.
00089 *
00090 *  Revision 1.21  2002/03/25 18:06:10  scowan
00091 *  Added pad to end method.
00092 *
00093 *  Revision 1.20  2002/03/19 18:11:23  mju
00094 *  Rename SetString() as AssignMsgF and add AssignMsg() which does no formatting.
00095 *
00096 *  Revision 1.19  2002/02/19 23:20:58  scowan
00097 *  Added upper and lower case methods.
00098 *
00099 *  Revision 1.18  2002/02/19 18:18:53  scowan
00100 *  Added a conversion to a non-const unicode.
00101 *
00102 *  Revision 1.1  1999/08/26 16:11:28  scowan
00103 *  Initial revision
00104 *  \endif
00105 **/
00106 
00107 #ifndef INC_MI32_FIXEDSTR_H
00108 #define INC_MI32_FIXEDSTR_H
00109 
00110 #ifndef INC_MI32_STDDEFNS_H
00111    #include <mi32/stddefns.h>
00112 #endif
00113    
00114 #ifndef INC_MI32_STDANSIC_H
00115    #include <mi32/stdansic.h>
00116 #endif
00117 
00118 #ifndef INC_MI32_UCSTRING_H
00119    #include <mi32/ucstring.h>
00120 #endif
00121 
00122 #ifndef INC_MI32_MEMBUF_H
00123    #include <mi32/membuf.h>
00124 #endif
00125 
00126 #ifndef INC_MI32_INIDEFNS_H
00127    #include <mi32/inidefns.h>
00128 #endif
00129 
00130 #ifndef INC_MI32_MISTRING_H
00131    #include <mi32/mistring.h>
00132 #endif
00133 
00134 //! Fixed-size array-based UNICODE string.
00135 //!   This class is designed to replace fixed size UNICODE array string constructs in other classes and structures.
00136 //! It is not meant as a STRING class implementation.  Therefore, the class cannot have virtual methods nor any
00137 //!   other members except for the string storage itself.
00138 template <size_t _CT> class FIXEDSTRING {
00139    public:
00140 
00141       //! Default constructor, clears the string.
00142       FIXEDSTRING (                          
00143          ) { Clear(); }
00144 
00145       //! Copy constructor.
00146       FIXEDSTRING (                          
00147          const FIXEDSTRING& rhs
00148          ) { memcpy(m_String, rhs.m_String, sizeof(m_String)); }
00149 
00150       //! Construct from UNICODE string.
00151       FIXEDSTRING (                          
00152          const UNICODE* string
00153          ) { 
00154          Clear(); 
00155          if (string != 0) ucstrncpy(m_String, string, _CT - 1);
00156          }
00157 
00158       //! Construct from MISTRING string.
00159       FIXEDSTRING (                          
00160          const MISTRING& string
00161          ) { 
00162          Clear(); 
00163          ucstrncpy(m_String, string, _CT - 1);
00164          }
00165 
00166       //! Construct from TEXTID.
00167       FIXEDSTRING (
00168          TEXTID textid
00169          ) { Clear(); MISTRING str(textid); ucstrncpy(m_String,str,_CT-1); }
00170 
00171       //! Destructor.
00172       ~FIXEDSTRING (                         
00173          ) { m_String[0] = 0; }
00174 
00175       //! Assignment operator.
00176       FIXEDSTRING& operator= (                  
00177          const FIXEDSTRING& rhs           //!< String to assign from
00178          ) {
00179          if (this != &rhs) {
00180             memcpy(m_String, rhs.m_String, sizeof(m_String));
00181             }
00182          return (*this);
00183          }
00184 
00185       //! Assign from UNICODE string.
00186       FIXEDSTRING& operator= (               
00187          const UNICODE* rhs               //!< String to assign from
00188          ) {
00189          if (m_String != rhs) {
00190             Clear();
00191             if (rhs != 0) ucstrncpy(m_String, rhs, _CT - 1);
00192             }
00193          return (*this);
00194          }
00195 
00196       //! Assign from MISTRING string.
00197       FIXEDSTRING& operator= (               
00198          const MISTRING& rhs              //!< String to assign from
00199          ) {
00200          Clear();
00201          ucstrncpy(m_String, rhs, _CT - 1);
00202          return (*this);
00203          }
00204 
00205       //! Assign from TEXTID.
00206       FIXEDSTRING& operator= (
00207          TEXTID textid                    //!< Message text ID
00208          ) { Clear(); MISTRING str(textid); ucstrncpy(m_String,str,_CT-1); return(*this); }
00209 
00210       //! Concatenate operator.
00211       template <int _T2>
00212       FIXEDSTRING<_CT>& operator+= (
00213          const FIXEDSTRING<_T2>& rhs            //!< String to concatinate from
00214          ) {
00215          ucstrncat(m_String, static_cast<const UNICODE*>(rhs), _CT - (ucstrlen(m_String) + 1));
00216          return (*this);
00217          }
00218 
00219       //! Concatenate from UNICODE string.
00220       FIXEDSTRING& operator+= (                 
00221          const UNICODE* rhs               //!< String to concatinate from
00222          ) {
00223          if (rhs != 0) ucstrncat(m_String, rhs, _CT - (ucstrlen(m_String) + 1));
00224          return (*this);
00225          }
00226          
00227       //! Equality.
00228       bool operator== (
00229          const FIXEDSTRING& rhs
00230          ) const { return (Compare(rhs) == 0); }
00231 
00232       //! Equality.
00233       bool operator== (
00234          const UNICODE *rhs
00235          ) const { return (Compare(rhs) == 0); }
00236 
00237       //! Inequality.
00238       bool operator!= (
00239          const FIXEDSTRING& rhs
00240          ) const { return (!(*this == rhs)); }
00241 
00242       //! Inequality.
00243       bool operator!= (
00244          const UNICODE *rhs
00245          ) const { return (!(*this == rhs)); }
00246 
00247       //! Less Than
00248       bool operator< (
00249          const FIXEDSTRING& rhs
00250          ) const { return (Compare(rhs) < 0); }
00251 
00252       //! Less Than
00253       bool operator< (
00254          const UNICODE *rhs
00255          ) const { return (Compare(rhs) < 0); }
00256 
00257       //! Less Than or Equal to
00258       bool operator<= (
00259          const FIXEDSTRING& rhs
00260          ) const { return (Compare(rhs) <= 0); }
00261 
00262       //! Less Than or Equal to
00263       bool operator<= (
00264          const UNICODE *rhs
00265          ) const { return (Compare(rhs) <= 0); }
00266 
00267       //! Greater Than
00268       bool operator> (
00269          const FIXEDSTRING& rhs
00270          ) const { return (Compare(rhs) > 0); }
00271 
00272       //! Greater Than
00273       bool operator> (
00274          const UNICODE *rhs
00275          ) const { return (Compare(rhs) > 0); }
00276 
00277       //! Greater Than or Equal to
00278       bool operator>= (
00279          const FIXEDSTRING& rhs
00280          ) const { return (Compare(rhs) >= 0); }
00281 
00282       //! Greater Than or Equal to
00283       bool operator>= (
00284          const UNICODE *rhs
00285          ) const { return (Compare(rhs) >= 0); }
00286 
00287       //! Cast to <const UNICODE*>.
00288       operator const UNICODE* (
00289          ) const { return (m_String); }
00290 
00291       //! Cast to <const MISTRING>.
00292 //    operator const MISTRING (
00293 //       ) const { return (MISTRING(m_String)); }
00294 
00295       //! Append from character string, not a constructor so that it is locatable in code.
00296       void Append (                          
00297          const char* name                 //!< Character string to append from
00298          ) {
00299          UNICODE *p = ucstrchr(m_String, 0);
00300          strntouc(p, name, _CT - (p - m_String) - 1);
00301          return;
00302          }
00303 
00304       //! Assign from character string, not a constructor so that it is locatable in code.
00305       void Assign (                          
00306          const char* name                 //!< Character string to assign from
00307          ) { strntouc(m_String, name, _CT - 1); }
00308 
00309       //! Assign from UNICODE string with a max length given
00310       void Assign (                          
00311          const UNICODE* name,                //!< UNICODE string to assign from
00312          size_t len
00313          ) { ucstrncpy(m_String, name, MIN(_CT - 1, len)); }
00314 
00315       //! Clear the whole string.
00316       void Clear (                           
00317          ) { memset(m_String, 0, sizeof(m_String)); }
00318       
00319       //! Case-sensitive comparison, length limited (similar to strncmp).
00320       //! @return 0 if strings equal, -1 if this < str, 1 if this > str.
00321       int Compare (
00322          const FIXEDSTRING& str                 //!< String to compare to
00323          ) const { return (ucstrcmp(m_String, str.m_String)); }
00324 
00325       //! Case-sensitive comparison, length limited (similar to strncmp).
00326       //! @return 0 if strings equal, -1 if this < str, 1 if this > str.
00327       int Compare (
00328          const UNICODE *str                  //!< String to compare to
00329          ) const { return (ucstrcmp(m_String, str)); }
00330 
00331       //! Case-insensitive comparison (similar to stricmp).
00332       //! @return 0 if strings equal, -1 if this < str, 1 if this > str.
00333       int CompareNoCase (
00334          const FIXEDSTRING& str                 //!< String to compare to
00335          ) const { return (ucstricmp(m_String, str.m_String)); }
00336 
00337       //! Case-insensitive comparison (similar to stricmp).
00338       //! @return 0 if strings equal, -1 if this < str, 1 if this > str.
00339       int CompareNoCase (
00340          const UNICODE *str                  //!< String to compare to
00341          ) const { return (ucstricmp(m_String, str)); }
00342          
00343       //! Find out if the string is empty.   
00344       bool IsEmpty (                         
00345          ) const { return (m_String[0] == 0); }
00346          
00347       //! Set the string according to values in ini file
00348       //! @return: 'true' if entry found and information read, false if empty field or field does not exist
00349       bool IniRead (
00350          INIHANDLE inih,
00351          const char *group,
00352          const char*const field
00353          ) { return (::IniRead(inih, group, field, m_String, _CT * sizeof(UNICODE)) > 0); }
00354 
00355       //! Save the string to values in ini file
00356       void IniWrite (
00357          INIHANDLE inih,
00358          const char *group,
00359          const char*const field
00360          ) { ::IniWrite(inih, group, field, m_String); }
00361 
00362       //! Unique name filter class to determine if the name given is unique               
00363       class UNIQUENAMEFILTER {
00364          public:
00365             UNIQUENAMEFILTER () {}
00366 
00367             //! Filter called to determine if the name is unique
00368             //! @return '1' if unique, '0' if not, < 0 error
00369             int Filter (const FIXEDSTRING<_CT>& string) { return (v_Filter(string)); }
00370          private:
00371             virtual int v_Filter (const FIXEDSTRING<_CT>& string) = 0;
00372          };
00373 
00374       //! Generate an unique name based on the filter passed in
00375       ERRVALUE GenerateUniqueName (
00376          UNIQUENAMEFILTER& FilterInst
00377          ) {
00378          ERRVALUE err;
00379          if ((err = FilterInst.Filter(*this)) < 0) return (err);
00380          if (err > 0) return (0);      //! String is already unique
00381 
00382          //! Initialize string and pointer for character replacement 
00383          int k = 0, len = GetLength();
00384          memset(&m_String[len], 0, (_CT - len) * sizeof(UNICODE));         //! Make sure rest of m_String is set to 0
00385          UNICODE* where = &m_String[len];
00386          if (len == (_CT-1)) where --;
00387          UNICODE* start = where;
00388          UINT8 count[_CT];
00389          memset(count, 0, _CT);
00390 
00391          static char *AddArray = "1234567890abcdefghijklmnopqrstuvwxyz_?";
00392          do {
00393             *where = static_cast<UNICODE>(AddArray[k++]);
00394             if (*where == static_cast<UNICODE>('?')) {
00395                k = 1;
00396                *where = static_cast<UNICODE>(AddArray[0]);
00397                UNICODE *p;
00398                for (p = where - 1;(p >= start);--p) {
00399                   *p = static_cast<UNICODE>(AddArray[count[p-m_String]++]);
00400                   if (*p == static_cast<UNICODE>('?')) {
00401                      *p = static_cast<UNICODE>(AddArray[0]);
00402                      count[p-m_String] = 0;
00403                      }
00404                   else break;
00405                   }
00406                if (p < start) {     //! Reset system and increment where
00407                   ++where;
00408                   if (where - start == 4) return (EProgramError); //! Reality check, if need to increase, it can be. 37 ^ 4 tried!
00409                   memset(count, 0, _CT);
00410                   if (where - m_String == (_CT-1)) {     //! As far out a possible, retreat until a match is not found
00411                      start --;
00412                      where = start;
00413                      if (start < m_String) return (EProgramError);      //! Out of 37 ^ (_CT-1) possible combinations, none found
00414                      }  
00415                   for (p = where;(p >= start);--p) *p = static_cast<UNICODE>(AddArray[0]);
00416                   }
00417                }
00418             err = FilterInst.Filter(*this);
00419             } while (err == 0);
00420          if (err < 0) return (err);
00421          return (0);
00422          }
00423 
00424       //! Return length of string, not including terminator.
00425       size_t GetLength (                        
00426          ) const { return (ucstrlen(m_String)); }
00427 
00428       //! Return maximum string size, not including terminator.
00429       static size_t GetMaxSize (                      
00430          ) { return (_CT-1); }
00431          
00432       //! Return const string pointer, used for sprintf type parameters
00433       const UNICODE* GetReference (
00434          ) const { return (m_String); }
00435          
00436       //! Get tail of string having up to specified number of characters.
00437       const UNICODE* GetTail (
00438          int maxlen
00439          ) const { int len = ucstrlen(m_String); return ((len <= maxlen) ? m_String : (m_String + (len - maxlen))); }
00440          
00441       //! Pad the string with a char to the end of the buffer
00442       void PadToEnd (
00443          char item
00444          ) {
00445          for (int j = ucstrlen(m_String);(j < _CT-1);++j) m_String[j] = item;
00446          m_String[_CT-1] = 0;
00447          }
00448          
00449       //! Set the string to lower case letters
00450       void SetLowerCase (
00451          ) { ucstrlwr(m_String); }
00452 
00453       //! Set the string to upper case letters
00454       void SetUpperCase (
00455          ) { ucstrupr(m_String); }
00456          
00457       //! Swap bytes of the string, used for RVC strings
00458       void SwapBytes (
00459          ) { ::SwapBytes(m_String, _CT); }
00460 
00461       //! Force termination of string at the end.
00462       void Terminate (                       
00463          ) { m_String[_CT - 1] = 0; }
00464 
00465       //! Truncate the string, has no effect if the string is shorter than NewLength.
00466       void Truncate (                           
00467          size_t NewLength
00468          ) { if (NewLength < (_CT - 1)) m_String[NewLength] = 0; }
00469 
00470    private:
00471       #ifndef GENERATING_DOXYGEN_OUTPUT
00472       UNICODE m_String[_CT];
00473       #endif // GENERATING_DOXYGEN_OUTPUT
00474    };
00475 
00476 //! Fixed-size array-based 'char' string.
00477 //!   This class is designed to replace fixed size 'char' array string constructs in other classes and structures.
00478 //! It is not meant as a STRING class implementation.  Therefore, the class cannot have virtual methods nor any
00479 //!   other members except for the string storage itself.
00480 template <size_t _CT> class FIXEDSTRCHAR {
00481    public:
00482 
00483       //! Default constructor, clears the string.
00484       FIXEDSTRCHAR (                         
00485          ) { Clear(); }
00486 
00487       //! Copy constructor.
00488       FIXEDSTRCHAR (                         
00489          const FIXEDSTRCHAR& rhs
00490          ) { memcpy(m_String, rhs.m_String, sizeof(m_String)); }
00491 
00492       //! Construct from char string.
00493       FIXEDSTRCHAR (                         
00494          const char* string
00495          ) { Clear(); strncpy(m_String, string, _CT - 1); }
00496 
00497       //! Destructor.
00498       ~FIXEDSTRCHAR (                           
00499          ) { m_String[0] = 0; }
00500 
00501       //! Assignment operator.
00502       FIXEDSTRCHAR& operator= (                 
00503          const FIXEDSTRCHAR& rhs          //!< String to assign from
00504          ) {
00505          if (this != &rhs) {
00506             memcpy(m_String, rhs.m_String, sizeof(m_String));
00507             }
00508          return (*this);
00509          }
00510 
00511       //! Assign from char string.
00512       FIXEDSTRCHAR& operator= (              
00513          const char* rhs               //!< String to assign from
00514          ) {
00515          if (m_String != rhs) {
00516             Clear();
00517             strncpy(m_String, rhs, _CT - 1);
00518             }
00519          return (*this);
00520          }
00521 
00522       //! Concatenate operator.
00523       FIXEDSTRCHAR& operator+= (                
00524          const FIXEDSTRCHAR& rhs          //!< String to concatinate from
00525          ) {
00526          strncat(m_String, rhs.m_String, _CT - (strlen(m_String) + 1));
00527          return (*this);
00528          }
00529 
00530       //! Concatenate from char string.
00531       FIXEDSTRCHAR& operator+= (                
00532          const char* rhs               //!< String to concatinate from
00533          ) {
00534          strncat(m_String, rhs, _CT - (strlen(m_String) + 1));
00535          return (*this);
00536          }
00537          
00538       //! Equality.
00539       bool operator== (
00540          const FIXEDSTRCHAR& rhs
00541          ) const { return (Compare(rhs) == 0); }
00542 
00543       //! Equality.
00544       bool operator== (
00545          const char *rhs
00546          ) const { return (Compare(rhs) == 0); }
00547 
00548       //! Inequality.
00549       bool operator!= (
00550          const FIXEDSTRCHAR& rhs
00551          ) const { return (!(*this == rhs)); }
00552 
00553       //! Inequality.
00554       bool operator!= (
00555          const char *rhs
00556          ) const { return (!(*this == rhs)); }
00557 
00558       //! Less Than
00559       bool operator< (
00560          const FIXEDSTRCHAR& rhs
00561          ) const { return (Compare(rhs) < 0); }
00562 
00563       //! Less Than
00564       bool operator< (
00565          const char *rhs
00566          ) const { return (Compare(rhs) < 0); }
00567 
00568       //! Less Than or Equal to
00569       bool operator<= (
00570          const FIXEDSTRCHAR& rhs
00571          ) const { return (Compare(rhs) <= 0); }
00572 
00573       //! Less Than or Equal to
00574       bool operator<= (
00575          const char *rhs
00576          ) const { return (Compare(rhs) <= 0); }
00577 
00578       //! Greater Than
00579       bool operator> (
00580          const FIXEDSTRCHAR& rhs
00581          ) const { return (Compare(rhs) > 0); }
00582 
00583       //! Greater Than
00584       bool operator> (
00585          const char *rhs
00586          ) const { return (Compare(rhs) > 0); }
00587 
00588       //! Greater Than or Equal to
00589       bool operator>= (
00590          const FIXEDSTRCHAR& rhs
00591          ) const { return (Compare(rhs) >= 0); }
00592 
00593       //! Greater Than or Equal to
00594       bool operator>= (
00595          const char *rhs
00596          ) const { return (Compare(rhs) >= 0); }
00597 
00598       //! Cast to <const char*>.
00599       operator const char* (
00600          ) const { return (m_String); }
00601 
00602       //! Assign from character string.
00603       void Assign (
00604          const char* name                 //!< Character string to assign from
00605          ) { strncpy(m_String, name, _CT - 1); }
00606 
00607       //! Assign from char string with a max length given
00608       void Assign (                          
00609          const char* name,                //!< char string to assign from
00610          size_t len
00611          ) { strncpy(m_String, name, MIN(_CT - 1, len)); }
00612 
00613       //! Clear the whole string.
00614       void Clear (                           
00615          ) { memset(m_String, 0, sizeof(m_String)); }
00616       
00617       //! Case-sensitive comparison, similar to strcmp.
00618       //! @return 0 if strings equal, -1 if this < str, 1 if this > str.
00619       int Compare (
00620          const FIXEDSTRCHAR& str                //!< String to compare to
00621          ) const { return (strcmp(m_String, str.m_String)); }
00622 
00623       //! Case-sensitive comparison, (similar to strcmp).
00624       //! @return 0 if strings equal, -1 if this < str, 1 if this > str.
00625       int Compare (
00626          const char *str                  //!< String to compare to
00627          ) const { return (strcmp(m_String, str)); }
00628 
00629       //! Case-insensitive comparison (similar to stricmp).
00630       //! @return 0 if strings equal, -1 if this < str, 1 if this > str.
00631       int CompareNoCase (
00632          const FIXEDSTRCHAR& str                //!< String to compare to
00633          ) const { return (stricmp(m_String, str.m_String)); }
00634 
00635       //! Case-insensitive comparison (similar to stricmp).
00636       //! @return 0 if strings equal, -1 if this < str, 1 if this > str.
00637       int CompareNoCase (
00638          const char *str                  //!< String to compare to
00639          ) const { return (stricmp(m_String, str)); }
00640          
00641       //! Find out if the string is empty.   
00642       bool IsEmpty (                         
00643          ) const { return (m_String[0] == 0); }
00644          
00645       //! Set the string according to values in ini file
00646       //! @return: 'true' if entry found and information read, false if empty field or field does not exist
00647       bool IniRead (
00648          INIHANDLE inih,
00649          const char *group,
00650          const char*const field
00651          ) { return (::IniRead(inih, group, field, m_String, _CT * sizeof(char)) > 0); }
00652 
00653       //! Save the string to values in ini file
00654       void IniWrite (
00655          INIHANDLE inih,
00656          const char *group,
00657          const char*const field
00658          ) { ::IniWrite(inih, group, field, m_String); }
00659 
00660       //! Return length of string, not including terminator.
00661       size_t GetLength (                        
00662          ) const { return (strlen(m_String)); }
00663 
00664       //! Return maximum string size, not including terminator.
00665       size_t GetMaxSize (                       
00666          ) const { return (_CT-1); }
00667 
00668       //! Get tail of string having up to specified number of characters.
00669       const char* GetTail (
00670          int maxlen
00671          ) const { int len = strlen(m_String); return ((len <= maxlen) ? m_String : (m_String + (len - maxlen))); }
00672          
00673       //! Pad the string with a char to the end of the buffer
00674       void PadToEnd (
00675          char item
00676          ) {
00677          for (int j = strlen(m_String);(j < _CT-1);++j) m_String[j] = item;
00678          m_String[_CT-1] = 0;
00679          }
00680          
00681       //! Set the string to lower case letters
00682       void SetLowerCase (
00683          ) { strlwr(m_String); }
00684 
00685       //! Set the string to upper case letters
00686       void SetUpperCase (
00687          ) { strupr(m_String); }
00688          
00689       //! Force termination of string at the end.
00690       void Terminate (                       
00691          ) { m_String[_CT - 1] = 0; }
00692 
00693       //! Truncate the string, has no effect if the string is shorter than NewLength.
00694       void Truncate (                           
00695          size_t NewLength
00696          ) { if (NewLength >= 0 && NewLength < (_CT - 1)) m_String[NewLength] = 0; }
00697 
00698    protected:
00699       #ifndef GENERATING_DOXYGEN_OUTPUT
00700       char m_String[_CT];
00701       #endif //!< GENERATING_DOXYGEN_OUTPUT
00702    };
00703 
00704 #endif      //!< INC_MI32_FIXEDSTR_H

Generated on Thu Aug 12 06:18:33 2004 for TNTsdk by doxygen 1.3.4-20031026