Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Tools/Xabsl2/yabsl/vsyabsl/text.h

Go to the documentation of this file.

    00001
    00002 /***************************************************************************
    00003          Copyright (c) Microsoft Corporation, All rights reserved.
    00004     This code sample is provided "AS IS" without warranty of any kind,
    00005     it is not recommended for use in a production environment.
    00006 ***************************************************************************/
    00007
    00008 #ifndef text_h
    00009 #define text_h
    00010
    00011 /*---------------------------------------------------------
    00012  String function library.
    00013
    00014  These definitions allow you to write
    00015  unicode/ansicode independent code.
    00016
    00017  Size specific strings:
    00018    UniStr   = unicode string
    00019    UniChar  = unicode character
    00020    CUniStr  = const UniChar*
    00021
    00022    AnsiStr  = ascii code string
    00023    AnsiChar = ascii charactre
    00024    CAnsiStr
    00025
    00026  Portable strings:
    00027    OleStr   = OLECHAR string
    00028    OleChar  = OLECHAR
    00029    COleStr
    00030
    00031    Str      = TCHAR string; ie. uses the default windows char size.
    00032    Char     = TCHAR
    00033    CStr
    00034
    00035    BSTR     = OleChar Basic Strings
    00036    CBSTR
    00037
    00038  Function are all prefixed with the string type:
    00039    uniLen, strLen, ansiLen, oleLen, bstrLen
    00040
    00041  Conversions are possible to all other types:
    00042    uniToAnsiDup, strToOleCopy, ansiToStrCat, strToBstrDup
    00043
    00044  If you do conversions, your function should start with
    00045  the "USECONV" macro:
    00046    int foo() { USECONV; ...; Char name[100]; oleToStrCopy(name,oleName,99); ... }
    00047
    00048  You can do 'inplace' conversion for arguments using the Xxx2Xxx macros:
    00049  a "C" can be added after the "2" for constant arguments:
    00050    LoadTypeLibEx( Str2COle(strName), &lib )
    00051
    00052  Most functions take an extra last arguments specifying the maximal
    00053  *length* of the target string. This does NOT include a possible terminating
    00054  '\0' character.
    00055
    00056  Constant strings:
    00057    UNI("hi"), OLE("hi"), ANSI("hi"), STR("hi")
    00058    UNI('a'), OLE('a'), ANSI('a'), STR('a')
    00059
    00060  Freeing strings:
    00061    strFree, bstrFree
    00062
    00063 ---------------------------------------------------------*/
    00064
    00065 #include <ctype.h>
    00066
    00067 #ifdef _UNICODE
    00068 #ifndef UNICODE
    00069 #define UNICODE
    00070 #endif
    00071 #endif
    00072
    00073 #define MAXSTR    255
    00074 #define MAXPATH   255
    00075 #define MAXNAME   99
    00076 #define MAXGUID     99
    00077 #define MAXIID      MAXGUID
    00078 #define MAXCLSID    MAXGUID
    00079
    00080
    00081 typedef unsigned    Nat;
    00082
    00083 //define conversions: STR2(UNI/ANSI) OLE2(UNI/ANSI)
    00084
    00085 #ifdef UNICODE
    00086 #define STR2UNI
    00087 #define OLE2UNI
    00088 #else
    00089 #define STR2ANSI
    00090 #ifndef OLE2ANSI
    00091 #define OLE2UNI
    00092 #endif
    00093 #endif
    00094
    00095 #ifdef OLE2UNI
    00096 #define BSTR2UNI
    00097 #else
    00098 #define BSTR2ANSI
    00099 #endif
    00100
    00101
    00102 //define the basic characters
    00103 typedef unsigned short  UniChar;
    00104 typedef char            AnsiChar;
    00105
    00106 #ifndef OLECHAR
    00107 #ifdef OLE2ANSI
    00108 typedef AnsiChar    OLECHAR;
    00109 #else
    00110 typedef UniChar     OLECHAR;
    00111 #endif
    00112 #endif
    00113
    00114 //define string prefixes
    00115 #define UNI(s)  L##s
    00116 #define ANSI(s) (s)
    00117
    00118 //define the portable Char type
    00119 #if defined (UNICODE)
    00120     typedef UniChar Char;
    00121 #define STR(s)  UNI(s)
    00122 #else
    00123     typedef AnsiChar Char;
    00124 #define STR(s)  ANSI(s)
    00125 #endif
    00126
    00127 //define portable OLE/BSTR Char type
    00128 #ifdef OLE2ANSI
    00129 #define OLE ANSI
    00130 #else
    00131 #define OLE UNI
    00132 #endif
    00133
    00134 typedef OLECHAR OleChar;
    00135 typedef OleChar BstrChar;
    00136
    00137 //strings
    00138 typedef Char*       Str;
    00139 typedef UniChar*    UniStr;
    00140 typedef AnsiChar*   AnsiStr;
    00141 typedef OleChar*    OleStr;
    00142 typedef BSTR        Bstr;
    00143
    00144 typedef const Char*     CStr;
    00145 typedef const UniChar*  CUniStr;
    00146 typedef const AnsiChar* CAnsiStr;
    00147 typedef const OleChar*  COleStr;
    00148 typedef COleStr         CBstr;
    00149 typedef COleStr         CBSTR;
    00150
    00151 //helpers
    00152 #define ansiFree(s) FREE(s)
    00153 #define uniFree(s)  FREE(s)
    00154 #define strFree(s)  FREE(s)
    00155 #define oleFree(s)  FREE(s)
    00156
    00157
    00158 //define the basic ansi/uni code specific functions
    00159 int ansiToUniLen( CAnsiStr s );
    00160 int uniToAnsiLen( CUniStr s );
    00161
    00162 UniStr  ansiToUniCopy( UniStr dest, CAnsiStr src, int maxLen );
    00163 AnsiStr uniToAnsiCopy( AnsiStr dest, CUniStr src, int maxLen );
    00164
    00165 UniStr  ansiToUniDup( CAnsiStr s );
    00166 AnsiStr uniToAnsiDup( CUniStr s );
    00167
    00168 UniStr  ansiToUniCat( UniStr dest, CAnsiStr src, int maxLen );
    00169 AnsiStr uniToAnsiCat( AnsiStr dest, CUniStr src, int maxLen );
    00170
    00171 UniStr  uniCopy( UniStr dest, CUniStr src, int maxLen );
    00172 AnsiStr ansiCopy( AnsiStr dest, CAnsiStr src, int maxLen );
    00173
    00174 UniStr  uniCat( UniStr dest, CUniStr src, int maxLen );
    00175 AnsiStr ansiCat( AnsiStr dest, CAnsiStr src, int maxLen );
    00176
    00177
    00178 inline  bool   uniEmpty( CUniStr s )        { return (s == NULL || s[0] == 0);  }
    00179 inline  int    uniLen( CUniStr s )          { return (s ? lstrlenW(s) : 0);     }
    00180 inline  UniStr uniDup( CUniStr s)           { return (s ? wcsdup(s) : NULL);    }
    00181
    00182 inline  UniStr uniToLower( UniStr s )       { return (s ? _wcslwr(s) : NULL);   }
    00183 inline  UniStr uniToUpper( UniStr s )       { return (s ? _wcsupr(s) : NULL);   }
    00184 inline  int    uniToInt( CUniStr s )        { return (s ? _wtoi(s) : 0 );       }
    00185 inline  void   uniClear( UniStr s )         { if (s) s[0] = UNI('\0');          }
    00186
    00187 inline  int uniCompare( CUniStr s, CUniStr t )
    00188 {
    00189     if (s == t) return 0;
    00190     if (!s)     return (-1);
    00191     if (!t)     return 1;
    00192                 return wcscmp(s,t);
    00193 }
    00194
    00195 inline  int uniICompare( CUniStr s, CUniStr t )
    00196 {
    00197     if (s == t) return 0;
    00198     if (!s)     return (-1);
    00199     if (!t)     return 1;
    00200                 return wcsicmp(s,t);
    00201 }
    00202
    00203 inline  int uniCompareLen( CUniStr s, CUniStr t, Nat n )
    00204 {
    00205     if (n == 0) return 0;
    00206     if (s == t) return 0;
    00207     if (!s)     return (-1);
    00208     if (!t)     return 1;
    00209                 return wcsncmp(s,t,n);
    00210 }
    00211
    00212 inline  int uniICompareLen( CUniStr s, CUniStr t, Nat n )
    00213 {
    00214     if (n == 0) return 0;
    00215     if (s == t) return 0;
    00216     if (!s)     return (-1);
    00217     if (!t)     return 1;
    00218                 return wcsnicmp(s,t,n);
    00219 }
    00220
    00221 inline UniStr uniFindSubStr( CUniStr s, CUniStr sub )
    00222 {
    00223     if (!s)     return NULL;
    00224     if (!sub)   return NULL;
    00225     return wcsstr(s,sub);
    00226 }
    00227
    00228 inline UniStr uniFindChar( CUniStr s, UniChar c )
    00229 {
    00230     if (!s)     return NULL;
    00231     return wcschr(s,c);
    00232 }
    00233
    00234 inline UniStr uniFindCharRev( CUniStr s, UniChar c)
    00235 {
    00236     if (!s) return NULL;
    00237     return wcsrchr(s,c);
    00238 }
    00239
    00240 #define uniCharToLower  towlower
    00241 #define uniCharToUpper  towupper
    00242 #define uniIsSpace      iswspace
    00243 #define uniIsPrintable  iswprint
    00244 #define uniIsControl    iswcntrl
    00245 #define uniIsAlpha      iswalpha
    00246 #define uniIsAlphaNum   iswalnum
    00247 #define uniIsDigit      iswdigit
    00248
    00249 inline  bool    ansiEmpty( CAnsiStr s )     { return (s == NULL || s[0] == 0);  }
    00250 inline  int     ansiLen( CAnsiStr s )       { return (s ? lstrlenA(s) : 0);     }
    00251 inline  AnsiStr ansiDup( CAnsiStr s)        { return (s ? strdup(s) : NULL);    }
    00252
    00253 inline  AnsiStr ansiToLower( AnsiStr s )    { return (s ? _strlwr(s) : NULL);   }
    00254 inline  AnsiStr ansiToUpper( AnsiStr s )    { return (s ? _strupr(s) : NULL);   }
    00255 inline  int     ansiToInt( CAnsiStr s )     { return (s ? atoi(s) : 0 );        }
    00256 inline  void    ansiClear( AnsiStr s )      { if (s) { s[0] = '\0'; }           }
    00257
    00258 inline  int ansiCompare( CAnsiStr s, CAnsiStr t )
    00259 {
    00260     if (s == t) return 0;
    00261     if (!s)     return (-1);
    00262     if (!t)     return 1;
    00263                 return strcmp(s,t);
    00264 }
    00265
    00266 inline  int ansiICompare( CAnsiStr s, CAnsiStr t )
    00267 {
    00268     if (s == t) return 0;
    00269     if (!s)     return (-1);
    00270     if (!t)     return 1;
    00271                 return stricmp(s,t);
    00272 }
    00273
    00274 inline  int ansiCompareLen( CAnsiStr s, CAnsiStr t, Nat n )
    00275 {
    00276     if (n == 0) return 0;
    00277     if (s == t) return 0;
    00278     if (!s)     return (-1);
    00279     if (!t)     return 1;
    00280                 return strncmp(s,t,n);
    00281 }
    00282
    00283 inline  int ansiICompareLen( CAnsiStr s, CAnsiStr t, Nat n )
    00284 {
    00285     if (n == 0) return 0;
    00286     if (s == t) return 0;
    00287     if (!s)     return (-1);
    00288     if (!t)     return 1;
    00289                 return strnicmp(s,t,n);
    00290 }
    00291
    00292 inline  AnsiStr ansiFindSubStr( CAnsiStr s, CAnsiStr sub )
    00293 {
    00294     if (!s)     return NULL;
    00295     if (!sub)   return NULL;
    00296     return strstr(s,sub);
    00297 }
    00298
    00299 inline  AnsiStr ansiFindChar( CAnsiStr s, AnsiChar c )
    00300 {
    00301     if (!s)     return NULL;
    00302     return strchr(s,c);
    00303 }
    00304
    00305 inline AnsiStr ansiFindCharRev( CAnsiStr s, AnsiChar c )
    00306 {
    00307     if (!s)     return NULL;
    00308     return strrchr(s,c);
    00309 }
    00310
    00311 #define ansiCharToLower     tolower
    00312 #define ansiCharToUpper     toupper
    00313
    00314 #define ansiIsSpace         isspace
    00315 #define ansiIsPrintable     isprint
    00316 #define ansiIsControl       iscntrl
    00317 #define ansiIsAlpha         isalpha
    00318 #define ansiIsAlphaNum      isalnum
    00319 #define ansiIsDigit         isdigit
    00320
    00321 //conversion macros
    00322 #define USECONV     int _convlen = 0; _convlen
    00323
    00324 #define Uni2Ansi(u) (\
    00325     (NULL==u) ? NULL : (\
    00326         _convlen = uniToAnsiLen(u), \
    00327             uniToAnsiCopy( (AnsiStr)_alloca((_convlen+1)*sizeof(AnsiChar)), u, _convlen )))
    00328
    00329 #define Ansi2Uni(a) (\
    00330     (NULL==a) ? NULL : (\
    00331         _convlen = ansiToUniLen(a), \
    00332            ansiToUniCopy( (UniStr)_alloca((_convlen+1)*sizeof(UniChar)), a, _convlen )))
    00333
    00334 #define AnsiCopy(a) (\
    00335     (NULL==a) ? NULL : (\
    00336         _convlen = ansiLen(a), \
    00337             ansiCopy( (AnsiStr)_alloca((_convlen+1)*sizeof(AnsiChar)), a, _convlen )))
    00338
    00339 #define UniCopy(u) (\
    00340     (NULL==u) ? NULL : (\
    00341        _convlen = uniLen(u), \
    00342             uniCopy( (UniStr)_alloca((_convlen+1)*sizeof(UniChar)), u, _convlen )))
    00343
    00344 #define Uni2CAnsi(u)    ((CAnsiStr)Uni2Ansi(u))
    00345 #define Ansi2CUni(a)    ((CUniStr)Ansi2Uni(a))
    00346
    00347
    00348 //Str conversion
    00349 #ifdef UNICODE
    00350
    00351 #define Uni2Str UniCopy
    00352 #define Str2Uni UniCopy
    00353 inline  CStr    Uni2CStr( CUniStr u )   { return u; };
    00354 inline  CUniStr Str2CUni( CStr s )      { return s; };
    00355
    00356 #define Ansi2Str  Ansi2Uni
    00357 #define Str2Ansi  Uni2Ansi
    00358 #define Ansi2CStr Ansi2CUni
    00359 #define Str2CAnsi Uni2CAnsi
    00360
    00361 #define uniToStrLen     uniLen
    00362 #define uniToStrCopy    uniCopy
    00363 #define uniToStrDup     uniDup
    00364 #define uniToStrCat     uniCat
    00365
    00366 #define strToUniLen     uniLen
    00367 #define strToUniCopy    uniCopy
    00368 #define strToUniDup     uniDup
    00369 #define strToUniCat     uniCat
    00370
    00371 #define ansiToStrLen    ansiToUniLen
    00372 #define ansiToStrCopy   ansiToUniCopy
    00373 #define ansiToStrDup    ansiToUniDup
    00374 #define ansiToStrCat    ansiToUniCat
    00375
    00376 #define strToAnsiLen    uniToAnsiLen
    00377 #define strToAnsiCopy   uniToAnsiCopy
    00378 #define strToAnsiDup    uniToAnsiDup
    00379 #define strToAnsiCat    uniToAnsiCat
    00380
    00381 #else
    00382
    00383 #define Ansi2Str    AnsiCopy
    00384 #define Str2Ansi    AnsiCopy
    00385 inline  CStr        Ansi2CStr( CAnsiStr a ){ return a; };
    00386 inline  CAnsiStr    Str2CAnsi( CStr s  )    { return s; };
    00387
    00388 #define Uni2Str  Uni2Ansi
    00389 #define Str2Uni  Ansi2Uni
    00390 #define Uni2CStr Uni2CAnsi
    00391 #define Str2CUni Ansi2CUni
    00392
    00393 #define uniToStrLen     uniToAnsiLen
    00394 #define uniToStrCopy    uniToAnsiCopy
    00395 #define uniToStrDup     uniToAnsiDup
    00396 #define uniToStrCat     uniToAnsiCat
    00397
    00398 #define strToUniLen     ansiToUniLen
    00399 #define strToUniCopy    ansiToUniCopy
    00400 #define strToUniDup     ansiToUniDup
    00401 #define strToUniCat     ansiToUniCat
    00402
    00403 #define ansiToStrLen    ansiLen
    00404 #define ansiToStrCopy   ansiCopy
    00405 #define ansiToStrDup    ansiDup
    00406 #define ansiToStrCat    ansiCat
    00407
    00408 #define strToAnsiLen    ansiLen
    00409 #define strToAnsiCopy   ansiCopy
    00410 #define strToAnsiDup    ansiDup
    00411 #define strToAnsiCat    ansiCat
    00412
    00413
    00414 #endif
    00415
    00416
    00417 //Ole conversion
    00418 #ifdef OLE2ANSI
    00419
    00420 #define Ansi2Ole    AnsiCopy
    00421 #define Ole2Ansi    AnsiCopy
    00422 inline  COleStr     Ansi2COle( CAnsiStr a ){ return a; };
    00423 inline  CAnsiStr    Ole2CAnsi( COleStr s ) { return s; };
    00424
    00425 #define Uni2Ole  Uni2Ansi
    00426 #define Ole2Uni  Ansi2Uni
    00427 #define Uni2COle Uni2CAnsi
    00428 #define Ole2CUni Ansi2CUni
    00429
    00430 #define uniToOleLen     uniToAnsiLen
    00431 #define uniToOleCopy    uniToAnsiCopy
    00432 #define uniToOleDup     uniToAnsiDup
    00433 #define uniToOleCat     uniToAnsiCat
    00434
    00435 #define oleToUniLen     ansiToUniLen
    00436 #define oleToUniCopy    ansiToUniCopy
    00437 #define oleToUniDup     ansiToUniDup
    00438 #define oleToUniCat     ansiToUniCat
    00439
    00440 #define ansiToOleLen    ansiLen
    00441 #define ansiToOleCopy   ansiCopy
    00442 #define ansiToOleDup    ansiDup
    00443 #define ansiToOleCat    ansiCat
    00444
    00445 #define oleToAnsiLen    ansiLen
    00446 #define oleToAnsiCopy   ansiCopy
    00447 #define oleToAnsiDup    ansiDup
    00448 #define oleToAnsiCat    ansiCat
    00449
    00450 #else
    00451
    00452 #define Uni2Ole UniCopy
    00453 #define Ole2Uni UniCopy
    00454 inline  COleStr Uni2COle( CUniStr u )   { return u; };
    00455 inline  CUniStr Ole2CUni( COleStr o )   { return o; };
    00456
    00457 #define Ansi2Ole  Ansi2Uni
    00458 #define Ole2Ansi  Uni2Ansi
    00459 #define Ansi2COle Ansi2CUni
    00460 #define Ole2CAnsi Uni2CAnsi
    00461
    00462 #define uniToOleLen     uniLen
    00463 #define uniToOleCopy    uniCopy
    00464 #define uniToOleDup     uniDup
    00465
    00466 #define oleToUniLen     uniLen
    00467 #define oleToUniCopy    uniCopy
    00468 #define oleToUniDup     uniDup
    00469 #define oleToUniCat     uniCat
    00470
    00471 #define ansiToOleLen    ansiToUniLen
    00472 #define ansiToOleCopy   ansiToUniCopy
    00473 #define ansiToOleDup    ansiToUniDup
    00474 #define ansiToOleCat    ansiToUniCat
    00475
    00476 #define oleToAnsiLen    uniToAnsiLen
    00477 #define oleToAnsiCopy   uniToAnsiCopy
    00478 #define oleToAnsiDup    uniToAnsiDup
    00479 #define oleToAnsiCat    uniToAnsiCat
    00480
    00481 #endif
    00482
    00483 //Ole - Str conversion
    00484
    00485 #if defined(UNICODE)
    00486 //ole and str are the same
    00487 #define Ole2Str UniCopy
    00488 #define Str2Ole UniCopy
    00489 inline  COleStr Str2COle( CStr s )      { return s; };
    00490 inline  CStr    Ole2CStr( COleStr o )   { return o; };
    00491
    00492 #define oleToStrLen     uniLen
    00493 #define oleToStrCopy    uniCopy
    00494 #define oleToStrDup     uniDup
    00495 #define oleToStrCat     uniCat
    00496
    00497 #define strToOleLen     uniLen
    00498 #define strToOleCopy    uniCopy
    00499 #define strToOleDup     uniDup
    00500 #define strToOleCat     uniCat
    00501
    00502 #elif defined(OLE2ANSI)
    00503 //ole and str are the same
    00504 #define Str2Ole AnsiCopy
    00505 #define Ole2Str AnsiCopy
    00506 inline  COleStr Str2COle( CStr s )      { return s; };
    00507 inline  CStr    Ole2CStr( COleStr o )   { return o; };
    00508
    00509 #define oleToStrLen     ansiLen
    00510 #define oleToStrCopy    ansiCopy
    00511 #define oleToStrDup     ansiDup
    00512 #define oleToStrCat     ansiCat
    00513
    00514 #define strToOleLen     ansiLen
    00515 #define strToOleCopy    ansiCopy
    00516 #define strToOleDup     ansiDup
    00517 #define strToOleCat     ansiCat
    00518
    00519
    00520 #else
    00521 //ole is uni, str is ansi
    00522 #define Ole2Str  Uni2Ansi
    00523 #define Str2Ole  Ansi2Uni
    00524 #define Ole2CStr Uni2CAnsi
    00525 #define Str2COle Ansi2CUni
    00526
    00527 #define oleToStrLen     uniToAnsiLen
    00528 #define oleToStrCopy    uniToAnsiCopy
    00529 #define oleToStrDup     uniToAnsiDup
    00530 #define oleToStrCat     uniToAnsiCat
    00531
    00532 #define strToOleLen     ansiToUniLen
    00533 #define strToOleCopy    ansiToUniCopy
    00534 #define strToOleDup     ansiToUniDup
    00535 #define strToOleCat     ansiToUniCat
    00536
    00537 #endif
    00538
    00539
    00540 //utility functions
    00541
    00542 //Str
    00543 #ifdef UNICODE
    00544
    00545 #define strEmpty            uniEmpty
    00546 #define strLen              uniLen
    00547 #define strCopy             uniCopy
    00548 #define strCat              uniCat
    00549 #define strDup              uniDup
    00550 #define strClear            uniClear
    00551 #define strCompare          uniCompare
    00552 #define strICompare         uniICompare
    00553 #define strCompareLen       uniCompareLen
    00554 #define strICompareLen      uniICompareLe
    00555 #define strToLower          uniToLower
    00556 #define strToUpper          uniToUpper
    00557 #define strCharToLower      uniCharToLower
    00558 #define strCharToUpper      uniCharToUpper
    00559 #define strFindSubStr       uniFindSubStr
    00560 #define strFindChar         uniFindChar
    00561 #define strFindCharRev      uniFindCharRev
    00562 #define strToInt            uniToInt
    00563 #define strIsSpace          uniIsSpace
    00564 #define strIsPrintable      uniIsPrintable
    00565 #define strIsControl        uniIsControl
    00566 #define strIsAlpha          uniIsAlpha
    00567 #define strIsAlphaNum       uniIsAlphaNum
    00568 #define strIsDigit          uniIsDigit
    00569 #else
    00570
    00571 #define strEmpty            ansiEmpty
    00572 #define strLen              ansiLen
    00573 #define strCopy             ansiCopy
    00574 #define strCat              ansiCat
    00575 #define strDup              ansiDup
    00576 #define strClear            ansiClear
    00577 #define strCompare          ansiCompare
    00578 #define strICompare         ansiICompare
    00579 #define strCompareLen       ansiCompareLen
    00580 #define strICompareLen      ansiICompareLen
    00581 #define strToLower          ansiToLower
    00582 #define strToUpper          ansiToUpper
    00583 #define strCharToLower      ansiCharToLower
    00584 #define strCharToUpper      ansiCharToUpper
    00585 #define strFindSubStr       ansiFindSubStr
    00586 #define strFindChar         ansiFindChar
    00587 #define strFindCharRev      ansiFindCharRev
    00588 #define strToInt            ansiToInt
    00589 #define strIsSpace          ansiIsSpace
    00590 #define strIsPrintable      ansiIsPrintable
    00591 #define strIsControl        ansiIsControl
    00592 #define strIsAlpha          ansiIsAlpha
    00593 #define strIsAlphaNum       ansiIsAlphaNum
    00594 #define strIsDigit          ansiIsDigit
    00595
    00596
    00597 #endif
    00598
    00599
    00600 //Ole
    00601 #ifdef OLE2ANSI
    00602
    00603 #define oleEmpty            ansiEmpty
    00604 #define oleLen              ansiLen
    00605 #define oleCopy             ansiCopy
    00606 #define oleCat              ansiCat
    00607 #define oleDup              ansiDup
    00608 #define oleClear            ansiClear
    00609 #define oleCompare          ansiCompare
    00610 #define oleICompare         ansiICompare
    00611 #define oleCompareLen       ansiCompareLen
    00612 #define oleICompareLen      ansiICompareLen
    00613 #define oleToLower          ansiToLower
    00614 #define oleToUpper          ansiToUpper
    00615 #define oleCharToLower      ansiCharToLower
    00616 #define oleCharToUpper      ansiCharToUpper
    00617 #define oleFindSubStr       ansiFindSubStr
    00618 #define oleFindChar         ansiFindChar
    00619 #define oleFindCharRev      ansiFindCharRev
    00620 #define oleToInt            ansiToInt
    00621 #define oleIsSpace          ansiIsSpace
    00622 #define oleIsPrintable      ansiIsPrintable
    00623 #define oleIsControl        ansiIsControl
    00624 #define oleIsAlpha          ansiIsAlpha
    00625 #define oleIsAlphaNum       ansiIsAlphaNum
    00626 #define oleIsDigit          ansiIsDigit
    00627
    00628 #else
    00629
    00630 #define oleEmpty            uniEmpty
    00631 #define oleLen              uniLen
    00632 #define oleCopy             uniCopy
    00633 #define oleCat              uniCat
    00634 #define oleDup              uniDup
    00635 #define oleClear            uniClear
    00636 #define oleCompare          uniCompare
    00637 #define oleICompare         uniICompare
    00638 #define oleCompareLen       uniCompareLen
    00639 #define oleICompareLen      uniICompareLen
    00640 #define oleToLower          uniToLower
    00641 #define oleToUpper          uniToUpper
    00642 #define oleCharToLower      uniCharToLower
    00643 #define oleCharToUpper      uniCharToUpper
    00644 #define oleFindSubStr       uniFindSubStr
    00645 #define oleFindChar         uniFindChar
    00646 #define oleFindCharRev      uniFindCharRev
    00647 #define oleToInt            uniToInt
    00648 #define oleIsSpace          uniIsSpace
    00649 #define oleIsPrintable      uniIsPrintable
    00650 #define oleIsControl        uniIsControl
    00651 #define oleIsAlpha          uniIsAlpha
    00652 #define oleIsAlphaNum       uniIsAlphaNum
    00653 #define oleIsDigit          uniIsDigit
    00654
    00655 #endif
    00656
    00657
    00658
    00659 //BSTR
    00660 inline  bool bstrEmpty( CBSTR s )      { return (s == NULL || s[0] == 0); }
    00661 inline  int  bstrLen( CBSTR s)         { return (s ? SysStringLen((BSTR)s) : 0 ); }
    00662 inline  BSTR bstrDup( CBSTR s)         { return (s ? SysAllocString((BSTR)s) : NULL ); }
    00663
    00664 void bstrFree( BSTR& );
    00665 BSTR bstrCopy( BSTR&, COleStr, int maxLen );
    00666 BSTR bstrCat( BSTR&, COleStr, int maxLen );
    00667
    00668 //conversion
    00669 //use dup for 'to bstr' conversion
    00670 #define ansiToBstrDup(s)    bstrDup( Ansi2COle(s) )
    00671 #define uniToBstrDup(s)     bstrDup( Uni2COle(s) )
    00672 #define strToBstrDup(s)     bstrDup( Str2COle(s) )
    00673 #define oleToBstrDup(s)     bstrDup( s )
    00674
    00675 #define bstrNew(s)          oleToBstrDup( OLE(s) )
    00676
    00677 #define bstrToAnsiDup   oleToAnsiDup
    00678 #define bstrToUniDup    oleToUniDup
    00679 #define bstrToStrDup    oleToStrDup
    00680 #define bstrToOleDup    oleDup
    00681
    00682 #define Bstr2Ansi       Ole2Ansi
    00683 #define Bstr2CAnsi      Ole2CAnsi
    00684 #define Bstr2Uni        Ole2Uni
    00685 #define Bstr2CUni       Ole2CUni
    00686 #define Bstr2Str        Ole2Str
    00687 #define Bstr2CStr       Ole2CStr
    00688 #define Bstr2Ole        OleCopy
    00689 inline  COleStr Bstr2COle( BSTR s)  { return s; }
    00690
    00691 //len
    00692 #define ansiToBstrLen   ansiToOleLen
    00693 #define uniToBstrLen    uniToOleLen
    00694 #define strToBstrLen    strToOleLen
    00695 #define oleToBstrLen    oleLen
    00696
    00697 #if defined(UNICODE)
    00698 #define bstrToAnsiLen   uniToAnsiLen
    00699 #define bstrToUniLen    bstrLen
    00700 #define bstrToStrLen    bstrLen
    00701 #elif defined(OLE2ANSI)
    00702 #define bstrToAnsiLen   bstrLen
    00703 #define bstrToUniLen    ansiToUniLen
    00704 #define bstrToStrLen    bstrLen
    00705 #else
    00706 #define bstrToAnsiLen   uniToAnsiLen
    00707 #define bstrToUniLen    bstrLen
    00708 #define bstrToStrLen    uniToAnsiLen
    00709 #endif
    00710
    00711 #define bstrToOleLen    bstrLen
    00712
    00713 //copy
    00714 #define ansiToBstrCopy(d,s,l)   bstrCopy(d,Ansi2COle(s),l)
    00715 #define uniToBstrCopy(d,s,l)    bstrCopy(d,Uni2COle(s),l)
    00716 #define strToBstrCopy(d,s,l)    bstrCopy(d,Str2COle(s),l)
    00717 #define oleToBstrCopy(d,s,l)    bstrCopy(d,s,l)
    00718
    00719 #define bstrToAnsiCopy      oleToAnsiCopy
    00720 #define bstrToUniCopy       oleToUniCopy
    00721 #define bstrToStrCopy       oleToStrCopy
    00722 #define bstrToOleCopy       oleCopy
    00723
    00724 //cat
    00725 #define ansiToBstrCat(d,s,l)    bstrCat(d,Ansi2COle(s),l)
    00726 #define uniToBstrCat(d,s,l)     bstrCat(d,Uni2COle(s),l)
    00727 #define strToBstrCat(d,s,l)     bstrCat(d,Str2COle(s),l)
    00728 #define oleToBstrCat(d,s,l)     bstrCat(d,s,l)
    00729
    00730 #define bstrToAnsiCat           oleToAnsiCat
    00731 #define bstrToUniCat            oleToUniCat
    00732 #define bstrToStrCat            oleToStrCat
    00733 #define bstrToOleCat            oleCat
    00734
    00735 #define bstrClear           bstrFree
    00736 #define bstrCompare         oleCompare
    00737 #define bstrICompare        oleICompare
    00738 #define bstrCompareLen      oleCompareLen
    00739 #define bstrICompareLen     oleICompareLen
    00740 #define bstrToLower         oleToLower
    00741 #define bstrToUpper         oleToUpper
    00742 #define bstrFindSubStr      oleFindSubStr
    00743 #define bstrFindChar        oleFindChar
    00744 #define bstrFindCharRev     oleFindCharRev
    00745 #define bstrToInt           oleToInt
    00746
    00747 //end include
    00748 #endif