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