WvStreams
uuidops.h
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2  *
3  * XPLC - Cross-Platform Lightweight Components
4  * Copyright (C) 2000-2003, Pierre Phaneuf
5  * Copyright (C) 2002, Net Integration Technologies, Inc.
6  * Copyright (C) 2004, Stéphane Lajoie
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21  * USA
22  *
23  * As a special exception, you may use this file as part of a free
24  * software library without restriction. Specifically, if other files
25  * instantiate templates or use macros or inline functions from this
26  * file, or you compile this file and link it with other files to
27  * produce an executable, this file does not by itself cause the
28  * resulting executable to be covered by the GNU Lesser General Public
29  * License. This exception does not however invalidate any other
30  * reasons why the executable file might be covered by the GNU Lesser
31  * General Public License.
32  */
33 
34 #ifndef __XPLC_UUIDOPS_H__
35 #define __XPLC_UUIDOPS_H__
36 
37 #if defined(__GNUC__) && __GNUC__ > 3
38 # pragma GCC system_header
39 #endif
40 
41 #include <xplc/uuid.h>
42 
43 #if !defined _SYS_GUID_OPERATOR_EQ_ && !defined _NO_SYS_GUID_OPERATOR_EQ_
44 #define _SYS_GUID_OPERATOR_EQ_
45 
49 inline int operator==(const UUID& uuid1, const UUID& uuid2) {
50  return
51  (&uuid1 == &uuid2) ||
52  ((static_cast<const u_int32_t*>(&uuid1.Data1)[0] == static_cast<const u_int32_t*>(&uuid2.Data1)[0]) &&
53  (static_cast<const u_int32_t*>(&uuid1.Data1)[1] == static_cast<const u_int32_t*>(&uuid2.Data1)[1]) &&
54  (static_cast<const u_int32_t*>(&uuid1.Data1)[2] == static_cast<const u_int32_t*>(&uuid2.Data1)[2]) &&
55  (static_cast<const u_int32_t*>(&uuid1.Data1)[3] == static_cast<const u_int32_t*>(&uuid2.Data1)[3]));
56 }
57 
61 inline int operator!=(const UUID& uuid1, const UUID& uuid2) {
62  return
63  (&uuid1 != &uuid2) &&
64  ((static_cast<const u_int32_t*>(&uuid1.Data1)[0] != static_cast<const u_int32_t*>(&uuid2.Data1)[0]) ||
65  (static_cast<const u_int32_t*>(&uuid1.Data1)[1] != static_cast<const u_int32_t*>(&uuid2.Data1)[1]) ||
66  (static_cast<const u_int32_t*>(&uuid1.Data1)[2] != static_cast<const u_int32_t*>(&uuid2.Data1)[2]) ||
67  (static_cast<const u_int32_t*>(&uuid1.Data1)[3] != static_cast<const u_int32_t*>(&uuid2.Data1)[3]));
68 }
69 
70 #endif
71 
80 const UUID UuidFromString(const char* str);
81 
90 char* UuidToString(const UUID& uuid, char* str);
91 
92 #endif /* __XPLC_UUIDOPS_H__ */
uuid.h
_GUID
The structure underlying UUIDs.
Definition: uuid.h:94