blob: 6eb6ebf56a8290f016539fbab9cbfb1841632f08 [file] [log] [blame]
srs569420e2a972010-02-04 00:55:04 -05001//
2// C++ Interface: GUIDData
3//
4// Description: GUIDData class header
5// Implements the GUIDData data structure and support methods
6//
7//
srs569400b6d7a2011-06-26 22:40:06 -04008// Author: Rod Smith <rodsmith@rodsbooks.com>, (C) 2010-2011
srs569420e2a972010-02-04 00:55:04 -05009//
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
srs569400b6d7a2011-06-26 22:40:06 -040021// for Unix (libuuid) vs. Windows (in rpc.h)
srs569420e2a972010-02-04 00:55:04 -050022#ifdef _WIN32
srs569400b6d7a2011-06-26 22:40:06 -040023#include <rpc.h>
24 #ifdef _MSC_VER
25 #pragma comment(lib, "Rpcrt4.lib")
26 #endif
srs569420e2a972010-02-04 00:55:04 -050027typedef unsigned char my_uuid_t[16];
srs569400b6d7a2011-06-26 22:40:06 -040028#else // Not Windows
srs569464cbd172011-03-01 22:03:54 -050029#include <uuid/uuid.h>
srs569420e2a972010-02-04 00:55:04 -050030typedef uuid_t my_uuid_t;
31#endif
32
33using 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.
37class GUIDData {
38 protected:
39 my_uuid_t uuidData;
srs569455d92612010-03-07 22:16:07 -050040 string DeleteSpaces(string s);
srs569420e2a972010-02-04 00:55:04 -050041 public:
42 GUIDData(void);
43 GUIDData(const GUIDData & orig);
srs56945a608532011-03-17 13:53:01 -040044 GUIDData(const string & orig);
srs569420e2a972010-02-04 00:55:04 -050045 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);
srs569420e2a972010-02-04 00:55:04 -050052 void Zero(void);
53 void Randomize(void);
54
55 // Data tests....
srs56945a081752010-09-24 20:39:41 -040056 int operator==(const GUIDData & orig) const;
57 int operator!=(const GUIDData & orig) const;
srs569420e2a972010-02-04 00:55:04 -050058
59 // Data retrieval....
srs56945a081752010-09-24 20:39:41 -040060 string AsString(void) const;
srs569420e2a972010-02-04 00:55:04 -050061}; // class GUIDData
62
srs56945a081752010-09-24 20:39:41 -040063ostream & operator<<(ostream & os, const GUIDData & data);
64
srs569420e2a972010-02-04 00:55:04 -050065#endif