• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // C++ Interface: GUIDData
3 //
4 // Description: GUIDData class header
5 // Implements the GUIDData data structure and support methods
6 //
7 //
8 // Author: Rod Smith <rodsmith@rodsbooks.com>, (C) 2010-2011
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
21 // for Unix (libuuid) vs. Windows (in rpc.h)
22 #ifdef _WIN32
23 #include <rpc.h>
24    #ifdef _MSC_VER
25    #pragma comment(lib, "Rpcrt4.lib")
26    #endif
27 typedef unsigned char my_uuid_t[16];
28 #else // Not Windows
29 #include <uuid/uuid.h>
30 typedef uuid_t my_uuid_t;
31 #endif
32 
33 // Note: This class's data size is critical. If data elements must be added,
34 // it will be necessary to modify various GPT classes to compensate.
35 class GUIDData {
36    private:
37       static bool firstInstance;
38    protected:
39       my_uuid_t uuidData;
40       std::string DeleteSpaces(std::string s);
41    public:
42       GUIDData(void);
43       GUIDData(const GUIDData & orig);
44       GUIDData(const std::string & orig);
45       GUIDData(const char * orig);
46       ~GUIDData(void);
47 
48       // Data assignment operators....
49       GUIDData & operator=(const GUIDData & orig);
50       GUIDData & operator=(const std::string & orig);
51       GUIDData & operator=(const char * orig);
52       void Zero(void);
53       void Randomize(void);
54 
55       // Data tests....
56       int operator==(const GUIDData & orig) const;
57       int operator!=(const GUIDData & orig) const;
58 
59       // Data retrieval....
60       std::string AsString(void) const;
61 }; // class GUIDData
62 
63 std::ostream & operator<<(std::ostream & os, const GUIDData & data);
64 
65 #endif
66