blob: 229d5bd0e79edb76dcfa569844b5aef58c62f7f0 [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 {
Roderick W. Smith84aaff62014-02-17 16:17:11 -050038 private:
39 static bool firstInstance;
srs569420e2a972010-02-04 00:55:04 -050040 protected:
41 my_uuid_t uuidData;
srs569455d92612010-03-07 22:16:07 -050042 string DeleteSpaces(string s);
srs569420e2a972010-02-04 00:55:04 -050043 public:
44 GUIDData(void);
45 GUIDData(const GUIDData & orig);
srs56945a608532011-03-17 13:53:01 -040046 GUIDData(const string & orig);
srs569420e2a972010-02-04 00:55:04 -050047 GUIDData(const char * orig);
48 ~GUIDData(void);
49
50 // Data assignment operators....
51 GUIDData & operator=(const GUIDData & orig);
52 GUIDData & operator=(const string & orig);
53 GUIDData & operator=(const char * orig);
srs569420e2a972010-02-04 00:55:04 -050054 void Zero(void);
55 void Randomize(void);
56
57 // Data tests....
srs56945a081752010-09-24 20:39:41 -040058 int operator==(const GUIDData & orig) const;
59 int operator!=(const GUIDData & orig) const;
srs569420e2a972010-02-04 00:55:04 -050060
61 // Data retrieval....
srs56945a081752010-09-24 20:39:41 -040062 string AsString(void) const;
srs569420e2a972010-02-04 00:55:04 -050063}; // class GUIDData
64
srs56945a081752010-09-24 20:39:41 -040065ostream & operator<<(ostream & os, const GUIDData & data);
66
srs569420e2a972010-02-04 00:55:04 -050067#endif