uuid.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/ole/uuid.h
  3. // Purpose: encapsulates an UUID with some added helper functions
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 11.07.97
  7. // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
  8. // Licence: wxWindows licence
  9. //
  10. // Notes: you should link your project with RPCRT4.LIB!
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #ifndef _WX_OLEUUID_H
  13. #define _WX_OLEUUID_H
  14. #include "wx/chartype.h"
  15. // ------------------------------------------------------------------
  16. // UUID (Universally Unique IDentifier) definition
  17. // ------------------------------------------------------------------
  18. // ----- taken from RPC.H
  19. #ifndef UUID_DEFINED // in some cases RPC.H will be already
  20. #ifdef __WIN32__ // included, so avoid redefinition
  21. typedef struct
  22. {
  23. unsigned long Data1;
  24. unsigned short Data2;
  25. unsigned short Data3;
  26. unsigned char Data4[8];
  27. } UUID; // UUID = GUID = CLSID = LIBID = IID
  28. #endif // WIN32
  29. #endif // UUID_DEFINED
  30. #ifndef GUID_DEFINED
  31. typedef UUID GUID;
  32. #define UUID_DEFINED // prevent redefinition
  33. #endif // GUID_DEFINED
  34. typedef unsigned char uchar;
  35. // ------------------------------------------------------------------
  36. // a class to store UUID and it's string representation
  37. // ------------------------------------------------------------------
  38. // uses RPC functions to create/convert Universally Unique Identifiers
  39. class WXDLLIMPEXP_CORE Uuid
  40. {
  41. private:
  42. UUID m_uuid;
  43. wxUChar *m_pszUuid; // this string is alloc'd and freed by RPC
  44. wxChar *m_pszCForm; // this string is allocated in Set/Create
  45. void UuidToCForm();
  46. // function used to set initial state by all ctors
  47. void Init() { m_pszUuid = NULL; m_pszCForm = NULL; }
  48. public:
  49. // ctors & dtor
  50. Uuid() { Init(); }
  51. Uuid(const wxChar *pc) { Init(); Set(pc); }
  52. Uuid(const UUID &uuid) { Init(); Set(uuid); }
  53. ~Uuid();
  54. // copy ctor and assignment operator needed for this class
  55. Uuid(const Uuid& uuid);
  56. Uuid& operator=(const Uuid& uuid);
  57. // create a brand new UUID
  58. void Create();
  59. // set value of UUID
  60. bool Set(const wxChar *pc); // from a string, returns true if ok
  61. void Set(const UUID& uuid); // from another UUID (never fails)
  62. // comparison operators
  63. bool operator==(const Uuid& uuid) const;
  64. bool operator!=(const Uuid& uuid) const { return !(*this == uuid); }
  65. // accessors
  66. operator const UUID*() const { return &m_uuid; }
  67. operator const wxChar*() const { return (wxChar *)(m_pszUuid); }
  68. // return string representation of the UUID in the C form
  69. // (as in DEFINE_GUID macro)
  70. const wxChar *CForm() const { return m_pszCForm; }
  71. };
  72. #endif //_WX_OLEUUID_H