1 /* This program is copyright (c) 2009-2018 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 with GUID "00000000-0000-0000-0000-000000000000" 40 static const PartType unusedPartType; 41 42 PartType(void); 43 PartType(const PartType & orig); 44 PartType(const GUIDData & orig); 45 ~PartType(void); 46 47 // Set up type information 48 int AddType(uint16_t mbrType, const char * guidData, const char * name, int toDisplay = 1); 49 50 // New assignment operators.... 51 PartType & operator=(const string & orig); 52 PartType & operator=(const char * orig); 53 54 // Assignment operators based on base class.... 55 GUIDData & operator=(const GUIDData & orig) {return GUIDData::operator=(orig);} 56 57 // New data assignment 58 PartType & operator=(uint16_t ID); // Use MBR type code times 0x0100 to assign GUID 59 60 // Retrieve transformed GUID data based on type code matches 61 string TypeName(void) const; 62 UnicodeString UTypeName(void) const; 63 uint16_t GetHexType() const; 64 65 // Information relating to all type data 66 void ShowAllTypes(int maxLines = 21) const; 67 int Valid(uint16_t code) const; 68 }; 69 70 #endif 71