1 /* 2 ** OSSP uuid - Universally Unique Identifier 3 ** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com> 4 ** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/> 5 ** 6 ** This file is part of OSSP uuid, a library for the generation 7 ** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/ 8 ** 9 ** Permission to use, copy, modify, and distribute this software for 10 ** any purpose with or without fee is hereby granted, provided that 11 ** the above copyright notice and this permission notice appear in all 12 ** copies. 13 ** 14 ** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 15 ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 ** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR 18 ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 21 ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 24 ** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 ** SUCH DAMAGE. 26 ** 27 ** uuid++.hh: library C++ API definition 28 */ 29 30 #ifndef __UUIDXX_HH__ 31 #define __UUIDXX_HH__ 32 33 /* required C API header */ 34 #include <stdlib.h> 35 #include "uuid.h" 36 37 /* UUID object class */ 38 class uuid { 39 public: 40 /* construction & destruction */ 41 uuid (); /* standard constructor */ 42 uuid (const uuid &_obj); /* copy constructor */ 43 uuid (const uuid_t *_obj); /* import constructor */ 44 uuid (const void *_bin); /* import constructor */ 45 uuid (const char *_str); /* import constructor */ 46 ~uuid (); /* destructor */ 47 48 /* copying & cloning */ 49 uuid &operator= (const uuid &_obj); /* copy assignment operator */ 50 uuid &operator= (const uuid_t *_obj); /* import assignment operator */ 51 uuid &operator= (const void *_bin); /* import assignment operator */ 52 uuid &operator= (const char *_str); /* import assignment operator */ 53 uuid clone (void); /* regular method */ 54 55 /* content generation */ 56 void load (const char *_name); /* regular method */ 57 void make (unsigned int _mode, ...); /* regular method */ 58 59 /* content comparison */ 60 int isnil (void); /* regular method */ 61 int compare (const uuid &_obj); /* regular method */ 62 int operator== (const uuid &_obj); /* comparison operator */ 63 int operator!= (const uuid &_obj); /* comparison operator */ 64 int operator< (const uuid &_obj); /* comparison operator */ 65 int operator<= (const uuid &_obj); /* comparison operator */ 66 int operator> (const uuid &_obj); /* comparison operator */ 67 int operator>= (const uuid &_obj); /* comparison operator */ 68 69 /* content importing & exporting */ 70 void import (const void *_bin); /* regular method */ 71 void import (const char *_str); /* regular method */ 72 void *binary (void); /* regular method */ 73 char *string (void); /* regular method */ 74 char *integer (void); /* regular method */ 75 char *summary (void); /* regular method */ 76 77 unsigned long version (void); /* regular method */ 78 79 private: 80 uuid_t *ctx; 81 }; 82 83 /* UUID exception class */ 84 class uuid_error_t { 85 public: uuid_error_t()86 uuid_error_t () { code(UUID_RC_OK); }; uuid_error_t(uuid_rc_t _code)87 uuid_error_t (uuid_rc_t _code) { code(_code); }; ~uuid_error_t()88 ~uuid_error_t () { }; code(uuid_rc_t _code)89 void code (uuid_rc_t _code) { rc = _code; }; code(void)90 uuid_rc_t code (void) { return rc; }; string(void)91 char *string (void) { return uuid_error(rc); }; 92 93 private: 94 uuid_rc_t rc; 95 }; 96 97 #endif /* __UUIDXX_HH__ */ 98 99