summaryrefslogtreecommitdiff
path: root/guid.h
blob: 515a75d1b1b52b893b091c51da669070f1bbd537 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// C++ Interface: GUIDData
//
// Description: GUIDData class header
// Implements the GUIDData data structure and support methods
//
//
// Author: Rod Smith <rodsmith@rodsbooks.com>, (C) 2010-2011
//
// Copyright: See COPYING file that comes with this distribution
//
//

#ifndef __GUIDDATA_CLASS
#define __GUIDDATA_CLASS

#include <stdint.h>
#include <string>

// Have to play games with uuid_t since it's defined in incompatible ways
// for Unix (libuuid) vs. Windows (in rpc.h)
#ifdef _WIN32
#include <rpc.h>
   #ifdef _MSC_VER
   #pragma comment(lib, "Rpcrt4.lib")
   #endif
typedef unsigned char my_uuid_t[16];
#else // Not Windows
#include <uuid/uuid.h>
typedef uuid_t my_uuid_t;
#endif

// Note: This class's data size is critical. If data elements must be added,
// it will be necessary to modify various GPT classes to compensate.
class GUIDData {
   private:
      static bool firstInstance;
   protected:
      my_uuid_t uuidData;
      std::string DeleteSpaces(std::string s);
   public:
      GUIDData(void);
      GUIDData(const GUIDData & orig);
      GUIDData(const std::string & orig);
      GUIDData(const char * orig);
      ~GUIDData(void);

      // Data assignment operators....
      GUIDData & operator=(const GUIDData & orig);
      GUIDData & operator=(const std::string & orig);
      GUIDData & operator=(const char * orig);
      void Zero(void);
      void Randomize(void);

      // Data tests....
      int operator==(const GUIDData & orig) const;
      int operator!=(const GUIDData & orig) const;

      // Data retrieval....
      std::string AsString(void) const;
}; // class GUIDData

std::ostream & operator<<(std::ostream & os, const GUIDData & data);

#endif