home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / wstrdata.hpp < prev    next >
C/C++ Source or Header  |  1996-12-17  |  2KB  |  61 lines

  1. /*************************************************************************
  2.  *
  3.  * WStringData
  4.  *
  5.  *************************************************************************/
  6.  
  7. #ifndef _WSTRDATA_HPP_INCLUDED
  8. #define _WSTRDATA_HPP_INCLUDED
  9.  
  10. #ifndef _WNO_PRAGMA_PUSH
  11. #pragma pack(push,8);
  12. #pragma enum int;
  13. #endif
  14.  
  15. //
  16. // Header for the reference-counted string data.
  17. //
  18.  
  19. struct WStringData;
  20.  
  21. struct WStringHeader {
  22.     WULong         _stringLength; // length in characters
  23.     WULong         _stringSize;   // size in bytes
  24.     WULong         _bufferSize;   // total size of buffer
  25.     WULong         _refCount;
  26.     WStringData   *_other;        // for translation
  27.     WDWord         _flags;
  28.  
  29.     void Clear() { _stringLength = _stringSize = _bufferSize =
  30.                    _refCount = _flags = 0; _other = NULL; }
  31. };
  32.  
  33. //
  34. // The reference-counted string itself
  35. //
  36.  
  37. struct WStringData : public WStringHeader {
  38.     union {
  39.         WAnsiChar    _ansiBuffer[1];
  40.         WUnicodeChar _unicodeBuffer[1];
  41.         WChar        _buffer[1];
  42.     };
  43.  
  44.     void Clear() { WStringHeader::Clear(); _unicodeBuffer[0] = 0; }
  45.  
  46.     static WStringData * Allocate( WStringData *old, WULong bufSize,
  47.                                    WBool makeCopy );
  48.  
  49.     static void          Deallocate( WStringData *old );
  50. };
  51.  
  52. #define WSSTR_DIRTY   0x0001
  53. #define WSSTR_UNICODE 0x0002
  54.  
  55. #ifndef _WNO_PRAGMA_PUSH
  56. #pragma enum pop;
  57. #pragma pack(pop);
  58. #endif
  59.  
  60. #endif // _WSTRDATA_HPP_INCLUDED
  61.