srs5694 | 20e2a97 | 2010-02-04 00:55:04 -0500 | [diff] [blame] | 1 | // |
| 2 | // C++ Interface: GUIDData |
| 3 | // |
| 4 | // Description: GUIDData class header |
| 5 | // Implements the GUIDData data structure and support methods |
| 6 | // |
| 7 | // |
srs5694 | 00b6d7a | 2011-06-26 22:40:06 -0400 | [diff] [blame] | 8 | // Author: Rod Smith <rodsmith@rodsbooks.com>, (C) 2010-2011 |
srs5694 | 20e2a97 | 2010-02-04 00:55:04 -0500 | [diff] [blame] | 9 | // |
| 10 | // Copyright: See COPYING file that comes with this distribution |
| 11 | // |
| 12 | // |
| 13 | |
| 14 | #ifndef __GUIDDATA_CLASS |
| 15 | #define __GUIDDATA_CLASS |
| 16 | |
| 17 | #include <stdint.h> |
| 18 | #include <string> |
| 19 | |
| 20 | // Have to play games with uuid_t since it's defined in incompatible ways |
srs5694 | 00b6d7a | 2011-06-26 22:40:06 -0400 | [diff] [blame] | 21 | // for Unix (libuuid) vs. Windows (in rpc.h) |
srs5694 | 20e2a97 | 2010-02-04 00:55:04 -0500 | [diff] [blame] | 22 | #ifdef _WIN32 |
srs5694 | 00b6d7a | 2011-06-26 22:40:06 -0400 | [diff] [blame] | 23 | #include <rpc.h> |
| 24 | #ifdef _MSC_VER |
| 25 | #pragma comment(lib, "Rpcrt4.lib") |
| 26 | #endif |
srs5694 | 20e2a97 | 2010-02-04 00:55:04 -0500 | [diff] [blame] | 27 | typedef unsigned char my_uuid_t[16]; |
srs5694 | 00b6d7a | 2011-06-26 22:40:06 -0400 | [diff] [blame] | 28 | #else // Not Windows |
srs5694 | 64cbd17 | 2011-03-01 22:03:54 -0500 | [diff] [blame] | 29 | #include <uuid/uuid.h> |
srs5694 | 20e2a97 | 2010-02-04 00:55:04 -0500 | [diff] [blame] | 30 | typedef uuid_t my_uuid_t; |
| 31 | #endif |
| 32 | |
| 33 | using namespace std; |
| 34 | |
| 35 | // Note: This class's data size is critical. If data elements must be added, |
| 36 | // it will be necessary to modify various GPT classes to compensate. |
| 37 | class GUIDData { |
| 38 | protected: |
| 39 | my_uuid_t uuidData; |
srs5694 | 55d9261 | 2010-03-07 22:16:07 -0500 | [diff] [blame] | 40 | string DeleteSpaces(string s); |
srs5694 | 20e2a97 | 2010-02-04 00:55:04 -0500 | [diff] [blame] | 41 | public: |
| 42 | GUIDData(void); |
| 43 | GUIDData(const GUIDData & orig); |
srs5694 | 5a60853 | 2011-03-17 13:53:01 -0400 | [diff] [blame] | 44 | GUIDData(const string & orig); |
srs5694 | 20e2a97 | 2010-02-04 00:55:04 -0500 | [diff] [blame] | 45 | GUIDData(const char * orig); |
| 46 | ~GUIDData(void); |
| 47 | |
| 48 | // Data assignment operators.... |
| 49 | GUIDData & operator=(const GUIDData & orig); |
| 50 | GUIDData & operator=(const string & orig); |
| 51 | GUIDData & operator=(const char * orig); |
srs5694 | 20e2a97 | 2010-02-04 00:55:04 -0500 | [diff] [blame] | 52 | void Zero(void); |
| 53 | void Randomize(void); |
| 54 | |
| 55 | // Data tests.... |
srs5694 | 5a08175 | 2010-09-24 20:39:41 -0400 | [diff] [blame] | 56 | int operator==(const GUIDData & orig) const; |
| 57 | int operator!=(const GUIDData & orig) const; |
srs5694 | 20e2a97 | 2010-02-04 00:55:04 -0500 | [diff] [blame] | 58 | |
| 59 | // Data retrieval.... |
srs5694 | 5a08175 | 2010-09-24 20:39:41 -0400 | [diff] [blame] | 60 | string AsString(void) const; |
srs5694 | 20e2a97 | 2010-02-04 00:55:04 -0500 | [diff] [blame] | 61 | }; // class GUIDData |
| 62 | |
srs5694 | 5a08175 | 2010-09-24 20:39:41 -0400 | [diff] [blame] | 63 | ostream & operator<<(ostream & os, const GUIDData & data); |
| 64 | |
srs5694 | 20e2a97 | 2010-02-04 00:55:04 -0500 | [diff] [blame] | 65 | #endif |