uuid.h

00001 /*
00002  * uuid.h
00003  * This file is part of dbPager Classes Library (DCL)
00004  *
00005  * Copyright (c) 2008 Dennis Prochko <wolfsoft@mail.ru>
00006  *
00007  * DCL is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation version 3.
00010  *
00011  * DCL is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with DCL; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor,
00019  * Boston, MA  02110-1301  USA
00020  */
00021 
00022 #ifndef _UUID_H_
00023 #define _UUID_H_
00024 
00025 #include <string>
00026 
00027 namespace dbp {
00028 
00030 
00034 class uuid {
00036         friend std::istream& operator>>(std::istream&, uuid&);
00038         friend std::ostream& operator<<(std::ostream&, const uuid&);
00039 public:
00041         uuid();
00043         uuid(const std::string&);
00045         uuid(const char*);
00047         uuid(const uuid&);
00049         uuid& operator=(const uuid&);
00051         bool operator==(const uuid&) const;
00053         bool operator<(const uuid&) const;
00055         bool operator>(const uuid &rhs) const {
00056                 return (rhs < *this);
00057         }
00059         bool operator<=(const uuid &rhs) const {
00060                 return !(rhs < *this);
00061         }
00063         bool operator>=(const uuid& rhs) const {
00064                 return !(*this < rhs);
00065         }
00067         bool operator!=(const uuid &rhs) const {
00068                 return !(*this == rhs);
00069         }
00071         bool operator!() const {
00072                 return empty();
00073         }
00075         typedef bool (uuid::*bool_type)() const;
00077         operator bool_type() const {
00078                 return empty() ? NULL : &uuid::empty;
00079         }
00081         void generate();
00083         void clear();
00085         bool empty() const;
00087         std::string str() const;
00088 private:
00089         static const int size = 16;
00090         unsigned char _data[size];
00091         void assign(const std::string&);
00092 };
00093 
00094 }
00095 
00096 #endif /*_UUID_H_*/
00097 

 
Support This Project
SourceForge.net Logo