Commit | Line | Data |
---|---|---|
bbf1f0e5 KB |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: ole/uuid.h | |
3 | // Purpose: encapsulates an UUID with some added helper functions | |
4 | // Author: Vadim Zeitlin | |
0a0e6a5b | 5 | // Modified by: |
bbf1f0e5 KB |
6 | // Created: 11.07.97 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
65571936 | 9 | // Licence: wxWindows licence |
bbf1f0e5 KB |
10 | // |
11 | // Notes: you should link your project with RPCRT4.LIB! | |
12 | /////////////////////////////////////////////////////////////////////////////// | |
13 | ||
bbcdf8bc JS |
14 | #ifndef _WX_OLEUUID_H |
15 | #define _WX_OLEUUID_H | |
bbf1f0e5 | 16 | |
12028905 | 17 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
bbf1f0e5 KB |
18 | #pragma interface "uuid.h" |
19 | #endif | |
7dee726c | 20 | #include "wx/wxchar.h" |
bbf1f0e5 KB |
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 | |
0a0e6a5b | 28 | typedef struct |
bbf1f0e5 KB |
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 | |
bbf1f0e5 KB |
35 | #endif // WIN32 |
36 | #endif // UUID_DEFINED | |
37 | ||
38 | #ifndef GUID_DEFINED | |
39 | typedef UUID GUID; | |
40 | #define UUID_DEFINED // prevent redefinition | |
41 | #endif // GUID_DEFINED | |
42 | ||
43 | typedef unsigned char uchar; | |
44 | ||
45 | // ------------------------------------------------------------------ | |
46 | // a class to store UUID and it's string representation | |
47 | // ------------------------------------------------------------------ | |
48 | ||
49 | // uses RPC functions to create/convert Universally Unique Identifiers | |
8853b9a8 | 50 | class WXDLLEXPORT Uuid |
bbf1f0e5 KB |
51 | { |
52 | private: | |
53 | UUID m_uuid; | |
0a0e6a5b | 54 | wxUChar *m_pszUuid; // this string is alloc'd and freed by RPC |
c47d0f2e | 55 | wxChar *m_pszCForm; // this string is allocated in Set/Create |
bbf1f0e5 KB |
56 | |
57 | void UuidToCForm(); | |
58 | ||
59 | // function used to set initial state by all ctors | |
60 | void Init() { m_pszUuid = NULL; m_pszCForm = NULL; } | |
61 | ||
62 | public: | |
63 | // ctors & dtor | |
64 | Uuid() { Init(); } | |
c47d0f2e | 65 | Uuid(const wxChar *pc) { Init(); Set(pc); } |
bbf1f0e5 KB |
66 | Uuid(const UUID &uuid) { Init(); Set(uuid); } |
67 | ~Uuid(); | |
68 | ||
69 | // copy ctor and assignment operator needed for this class | |
70 | Uuid(const Uuid& uuid); | |
71 | Uuid& operator=(const Uuid& uuid); | |
72 | ||
73 | // create a brand new UUID | |
74 | void Create(); | |
75 | ||
0a0e6a5b | 76 | // set value of UUID |
c47d0f2e | 77 | bool Set(const wxChar *pc); // from a string, returns true if ok |
bbf1f0e5 KB |
78 | void Set(const UUID& uuid); // from another UUID (never fails) |
79 | ||
80 | // accessors | |
c47d0f2e OK |
81 | operator const UUID*() const { return &m_uuid; } |
82 | operator const wxChar*() const { return (wxChar *)(m_pszUuid); } | |
bbf1f0e5 KB |
83 | |
84 | // return string representation of the UUID in the C form | |
85 | // (as in DEFINE_GUID macro) | |
c47d0f2e | 86 | const wxChar *CForm() const { return m_pszCForm; } |
bbf1f0e5 KB |
87 | }; |
88 | ||
8853b9a8 | 89 | #endif //_WX_OLEUUID_H |