added columns "old value" and "new value" in audit log; server configuration variable...
[public/netxms.git] / include / uuid.h
CommitLineData
f3d12ff6
VK
1/*
2 * Public include file for the UUID library
3 *
4 * Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
5 *
6 * %Begin-Header%
7 * This file may be redistributed under the terms of the GNU
8 * Library General Public License.
9 * %End-Header%
10 */
11
12#ifndef _UUID_H_
13#define _UUID_H_
14
95b6a1b6
VK
15#define UUID_LENGTH 16
16
3071f10a 17#if !HAVE_UUID_T
f3d12ff6 18#undef uuid_t
de4af576 19typedef unsigned char uuid_t[UUID_LENGTH];
3071f10a 20#endif
f3d12ff6
VK
21
22/* UUID Variant definitions */
95b6a1b6
VK
23#define UUID_VARIANT_NCS 0
24#define UUID_VARIANT_DCE 1
25#define UUID_VARIANT_MICROSOFT 2
26#define UUID_VARIANT_OTHER 3
f3d12ff6 27
999945fa
VK
28void LIBNETXMS_EXPORTABLE _uuid_clear(uuid_t uu);
29int LIBNETXMS_EXPORTABLE _uuid_compare(const uuid_t uu1, const uuid_t uu2);
30void LIBNETXMS_EXPORTABLE _uuid_generate(uuid_t out);
31bool LIBNETXMS_EXPORTABLE _uuid_is_null(const uuid_t uu);
32int LIBNETXMS_EXPORTABLE _uuid_parse(const TCHAR *in, uuid_t uu);
33TCHAR LIBNETXMS_EXPORTABLE *_uuid_to_string(const uuid_t uu, TCHAR *out);
f3d12ff6 34
de4af576
VK
35#ifdef __cplusplus
36
37/**
38 * Wrapper class for UUID
39 * Lower case used to avoid conflict with UUID struct defined in Windows headers
40 */
41class LIBNETXMS_EXPORTABLE uuid
42{
43private:
44 uuid_t m_value;
45
46public:
999945fa 47 uuid() { _uuid_clear(m_value); }
de4af576
VK
48 uuid(const uuid_t v) { memcpy(m_value, v, UUID_LENGTH); }
49
999945fa
VK
50 int compare(const uuid& u) const { return _uuid_compare(m_value, u.m_value); }
51 bool equals(const uuid& u) const { return _uuid_compare(m_value, u.m_value) == 0; }
de4af576 52 const uuid_t& getValue() const { return m_value; }
999945fa
VK
53 bool isNull() const { return _uuid_is_null(m_value); }
54 TCHAR *toString(TCHAR *buffer) const { return _uuid_to_string(m_value, buffer); }
55 String toString() const { TCHAR buffer[64]; return String(_uuid_to_string(m_value, buffer)); }
de4af576
VK
56
57 /**
58 * Generate new UUID
59 */
60 static uuid generate()
61 {
62 uuid_t u;
999945fa 63 _uuid_generate(u);
de4af576
VK
64 return uuid(u);
65 }
66
67 /**
68 * Parse string into UUID. Returns NULL UUID on error.
69 */
70 static uuid parse(const TCHAR *s)
71 {
72 uuid_t u;
999945fa 73 if (_uuid_parse(s, u) != 0)
de4af576
VK
74 return NULL_UUID;
75 return uuid(u);
76 }
77
78 static const uuid NULL_UUID;
79};
80
81#endif
82
f3d12ff6 83#endif