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