]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/ole/uuid.h
no message
[wxWidgets.git] / include / wx / msw / ole / uuid.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: 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 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 //
11 // Notes: you should link your project with RPCRT4.LIB!
12 ///////////////////////////////////////////////////////////////////////////////
13
14 #ifndef _WX_OLEUUID_H
15 #define _WX_OLEUUID_H
16
17 #ifdef __GNUG__
18 #pragma interface "uuid.h"
19 #endif
20
21 // ------------------------------------------------------------------
22 // UUID (Universally Unique IDentifier) definition
23 // ------------------------------------------------------------------
24
25 // ----- taken from RPC.H
26 #ifndef UUID_DEFINED // in some cases RPC.H will be already
27 #ifdef __WIN32__ // included, so avoid redefinition
28 typedef struct
29 {
30 unsigned long Data1;
31 unsigned short Data2;
32 unsigned short Data3;
33 unsigned char Data4[8];
34 } UUID; // UUID = GUID = CLSID = LIBID = IID
35 #else // WIN16
36 #error "Don't know about UUIDs on this platform"
37 #endif // WIN32
38 #endif // UUID_DEFINED
39
40 #ifndef GUID_DEFINED
41 typedef UUID GUID;
42 #define UUID_DEFINED // prevent redefinition
43 #endif // GUID_DEFINED
44
45 typedef unsigned char uchar;
46
47 // ------------------------------------------------------------------
48 // a class to store UUID and it's string representation
49 // ------------------------------------------------------------------
50
51 // uses RPC functions to create/convert Universally Unique Identifiers
52 class WXDLLEXPORT Uuid
53 {
54 private:
55 UUID m_uuid;
56 uchar *m_pszUuid; // this string is alloc'd and freed by RPC
57 char *m_pszCForm; // this string is allocated in Set/Create
58
59 void UuidToCForm();
60
61 // function used to set initial state by all ctors
62 void Init() { m_pszUuid = NULL; m_pszCForm = NULL; }
63
64 public:
65 // ctors & dtor
66 Uuid() { Init(); }
67 Uuid(const char *pc) { Init(); Set(pc); }
68 Uuid(const UUID &uuid) { Init(); Set(uuid); }
69 ~Uuid();
70
71 // copy ctor and assignment operator needed for this class
72 Uuid(const Uuid& uuid);
73 Uuid& operator=(const Uuid& uuid);
74
75 // create a brand new UUID
76 void Create();
77
78 // set value of UUID
79 bool Set(const char *pc); // from a string, returns true if ok
80 void Set(const UUID& uuid); // from another UUID (never fails)
81
82 // accessors
83 operator const UUID*() const { return &m_uuid; }
84 operator const char*() const { return (char *)(m_pszUuid); }
85
86 // return string representation of the UUID in the C form
87 // (as in DEFINE_GUID macro)
88 const char *CForm() const { return m_pszCForm; }
89 };
90
91 #endif //_WX_OLEUUID_H