blob: dd23e941f14d14521581718f7610215012491c57 [file] [log] [blame]
Roderick W. Smithe3ee7332013-09-24 12:56:11 -04001/* This program is copyright (c) 2009-2013 by Roderick W. Smith. It is distributed
srs5694221e0872009-08-29 15:00:31 -04002 under the terms of the GNU GPL version 2, as detailed in the COPYING file. */
3
srs5694e7b4ff92009-08-18 13:16:10 -04004#include <stdint.h>
srs5694e7b4ff92009-08-18 13:16:10 -04005#include <stdlib.h>
srs569400b6d7a2011-06-26 22:40:06 -04006#ifdef USE_UTF16
srs56945a608532011-03-17 13:53:01 -04007#include <unicode/ustream.h>
srs5694699941e2011-03-21 21:33:57 -04008#else
9#define UnicodeString string
10#endif
srs5694fed16d02010-01-27 23:03:40 -050011#include <string>
srs5694e7b4ff92009-08-18 13:16:10 -040012#include "support.h"
srs56946699b012010-02-04 00:55:30 -050013#include "guid.h"
srs5694e7b4ff92009-08-18 13:16:10 -040014
15#ifndef __PARTITION_TYPES
16#define __PARTITION_TYPES
17
srs5694e7b4ff92009-08-18 13:16:10 -040018using namespace std;
19
20// A partition type
21struct 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;
srs56946699b012010-02-04 00:55:30 -050026 GUIDData GUIDType;
srs5694e321d442010-01-29 17:44:04 -050027 string name;
srs5694e7b4ff92009-08-18 13:16:10 -040028 int display; // 1 to show to users as available type, 0 not to
29 AType* next;
30}; // struct AType
31
srs56946699b012010-02-04 00:55:30 -050032class PartType : public GUIDData {
srs5694e7b4ff92009-08-18 13:16:10 -040033protected:
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
srs56946699b012010-02-04 00:55:30 -050037 void AddAllTypes(void);
srs5694e7b4ff92009-08-18 13:16:10 -040038public:
srs56946699b012010-02-04 00:55:30 -050039 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
srs569482f3f0b2010-09-22 10:50:24 -040047 // New assignment operators....
48 PartType & operator=(const string & orig);
49 PartType & operator=(const char * orig);
50
srs56946699b012010-02-04 00:55:30 -050051 // Assignment operators based on base class....
52 GUIDData & operator=(const GUIDData & orig) {return GUIDData::operator=(orig);}
srs56946699b012010-02-04 00:55:30 -050053
54 // New data assignment
srs5694cb76c672010-02-11 22:22:22 -050055 PartType & operator=(uint16_t ID); // Use MBR type code times 0x0100 to assign GUID
srs56946699b012010-02-04 00:55:30 -050056
57 // Retrieve transformed GUID data based on type code matches
srs56945a081752010-09-24 20:39:41 -040058 string TypeName(void) const;
srs56945a608532011-03-17 13:53:01 -040059 UnicodeString UTypeName(void) const;
srs56945a081752010-09-24 20:39:41 -040060 uint16_t GetHexType() const;
srs56946699b012010-02-04 00:55:30 -050061
62 // Information relating to all type data
Roderick W. Smithe3ee7332013-09-24 12:56:11 -040063 void ShowAllTypes(int maxLines = 21) const;
srs56945a081752010-09-24 20:39:41 -040064 int Valid(uint16_t code) const;
srs5694e7b4ff92009-08-18 13:16:10 -040065};
66
srs5694e7b4ff92009-08-18 13:16:10 -040067#endif