WvStreams
uuidops.h
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * XPLC - Cross-Platform Lightweight Components
00004  * Copyright (C) 2000-2003, Pierre Phaneuf
00005  * Copyright (C) 2002, Net Integration Technologies, Inc.
00006  * Copyright (C) 2004, Stéphane Lajoie
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation; either version 2.1 of
00011  * the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00021  * USA
00022  *
00023  * As a special exception, you may use this file as part of a free
00024  * software library without restriction.  Specifically, if other files
00025  * instantiate templates or use macros or inline functions from this
00026  * file, or you compile this file and link it with other files to
00027  * produce an executable, this file does not by itself cause the
00028  * resulting executable to be covered by the GNU Lesser General Public
00029  * License.  This exception does not however invalidate any other
00030  * reasons why the executable file might be covered by the GNU Lesser
00031  * General Public License.
00032  */
00033 
00034 #ifndef __XPLC_UUIDOPS_H__
00035 #define __XPLC_UUIDOPS_H__
00036 
00037 #if defined(__GNUC__) && __GNUC__ > 3
00038 # pragma GCC system_header
00039 #endif
00040 
00041 #include <xplc/uuid.h>
00042 
00043 #if !defined _SYS_GUID_OPERATOR_EQ_ && !defined _NO_SYS_GUID_OPERATOR_EQ_
00044 #define _SYS_GUID_OPERATOR_EQ_
00045 
00049 inline int operator==(const UUID& uuid1, const UUID& uuid2) {
00050     return
00051       (&uuid1 == &uuid2) ||
00052       ((static_cast<const u_int32_t*>(&uuid1.Data1)[0] == static_cast<const u_int32_t*>(&uuid2.Data1)[0]) &&
00053        (static_cast<const u_int32_t*>(&uuid1.Data1)[1] == static_cast<const u_int32_t*>(&uuid2.Data1)[1]) &&
00054        (static_cast<const u_int32_t*>(&uuid1.Data1)[2] == static_cast<const u_int32_t*>(&uuid2.Data1)[2]) &&
00055        (static_cast<const u_int32_t*>(&uuid1.Data1)[3] == static_cast<const u_int32_t*>(&uuid2.Data1)[3]));
00056 }
00057 
00061 inline int operator!=(const UUID& uuid1, const UUID& uuid2) {
00062     return
00063       (&uuid1 != &uuid2) &&
00064       ((static_cast<const u_int32_t*>(&uuid1.Data1)[0] != static_cast<const u_int32_t*>(&uuid2.Data1)[0]) ||
00065        (static_cast<const u_int32_t*>(&uuid1.Data1)[1] != static_cast<const u_int32_t*>(&uuid2.Data1)[1]) ||
00066        (static_cast<const u_int32_t*>(&uuid1.Data1)[2] != static_cast<const u_int32_t*>(&uuid2.Data1)[2]) ||
00067        (static_cast<const u_int32_t*>(&uuid1.Data1)[3] != static_cast<const u_int32_t*>(&uuid2.Data1)[3]));
00068 }
00069 
00070 #endif
00071 
00080 const UUID UuidFromString(const char* str);
00081 
00090 char* UuidToString(const UUID& uuid, char* str);
00091 
00092 #endif /* __XPLC_UUIDOPS_H__ */