• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* This program is copyright (c) 2009-2013 by Roderick W. Smith. It is distributed
2   under the terms of the GNU GPL version 2, as detailed in the COPYING file. */
3 
4 #include <stdint.h>
5 #include <stdlib.h>
6 #ifdef USE_UTF16
7 #include <unicode/ustream.h>
8 #else
9 #define UnicodeString string
10 #endif
11 #include <string>
12 #include "support.h"
13 #include "guid.h"
14 
15 #ifndef __PARTITION_TYPES
16 #define __PARTITION_TYPES
17 
18 using namespace std;
19 
20 // A partition type
21 struct AType {
22    // I'm using a custom 16-bit extension of the original MBR 8-bit
23    // type codes, so as to permit disambiguation and use of new
24    // codes required by GPT
25    uint16_t MBRType;
26    GUIDData GUIDType;
27    string name;
28    int display; // 1 to show to users as available type, 0 not to
29    AType* next;
30 }; // struct AType
31 
32 class PartType : public GUIDData {
33 protected:
34    static int numInstances;
35    static AType* allTypes; // Linked list holding all the data
36    static AType* lastType; // Pointer to last entry in the list
37    void AddAllTypes(void);
38 public:
39    PartType(void);
40    PartType(const PartType & orig);
41    PartType(const GUIDData & orig);
42    ~PartType(void);
43 
44    // Set up type information
45    int AddType(uint16_t mbrType, const char * guidData, const char * name, int toDisplay = 1);
46 
47    // New assignment operators....
48    PartType & operator=(const string & orig);
49    PartType & operator=(const char * orig);
50 
51    // Assignment operators based on base class....
52    GUIDData & operator=(const GUIDData & orig) {return GUIDData::operator=(orig);}
53 
54    // New data assignment
55    PartType & operator=(uint16_t ID); // Use MBR type code times 0x0100 to assign GUID
56 
57    // Retrieve transformed GUID data based on type code matches
58    string TypeName(void) const;
59    UnicodeString UTypeName(void) const;
60    uint16_t GetHexType() const;
61 
62    // Information relating to all type data
63    void ShowAllTypes(int maxLines = 21) const;
64    int Valid(uint16_t code) const;
65 };
66 
67 #endif
68