blob: 77ed851b2a00f107cf6862a6741bb953c56fb075 [file] [log] [blame]
srs5694221e0872009-08-29 15:00:31 -04001/* 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
srs5694e7b4ff92009-08-18 13:16:10 -04004#include <stdint.h>
srs5694e7b4ff92009-08-18 13:16:10 -04005#include <stdlib.h>
srs56945a608532011-03-17 13:53:01 -04006#include <unicode/unistr.h>
7#include <unicode/ustream.h>
srs5694fed16d02010-01-27 23:03:40 -05008#include <string>
srs5694e7b4ff92009-08-18 13:16:10 -04009#include "support.h"
srs56946699b012010-02-04 00:55:30 -050010#include "guid.h"
srs5694e7b4ff92009-08-18 13:16:10 -040011
12#ifndef __PARTITION_TYPES
13#define __PARTITION_TYPES
14
srs5694e7b4ff92009-08-18 13:16:10 -040015using namespace std;
16
17// A partition type
18struct 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;
srs56946699b012010-02-04 00:55:30 -050023 GUIDData GUIDType;
srs5694e321d442010-01-29 17:44:04 -050024 string name;
srs5694e7b4ff92009-08-18 13:16:10 -040025 int display; // 1 to show to users as available type, 0 not to
26 AType* next;
27}; // struct AType
28
srs56946699b012010-02-04 00:55:30 -050029class PartType : public GUIDData {
srs5694e7b4ff92009-08-18 13:16:10 -040030protected:
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
srs56946699b012010-02-04 00:55:30 -050034 void AddAllTypes(void);
srs5694e7b4ff92009-08-18 13:16:10 -040035public:
srs56946699b012010-02-04 00:55:30 -050036 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
srs569482f3f0b2010-09-22 10:50:24 -040044 // New assignment operators....
45 PartType & operator=(const string & orig);
46 PartType & operator=(const char * orig);
47
srs56946699b012010-02-04 00:55:30 -050048 // Assignment operators based on base class....
49 GUIDData & operator=(const GUIDData & orig) {return GUIDData::operator=(orig);}
srs56946699b012010-02-04 00:55:30 -050050
51 // New data assignment
srs5694cb76c672010-02-11 22:22:22 -050052 PartType & operator=(uint16_t ID); // Use MBR type code times 0x0100 to assign GUID
srs56946699b012010-02-04 00:55:30 -050053
54 // Retrieve transformed GUID data based on type code matches
srs56945a081752010-09-24 20:39:41 -040055 string TypeName(void) const;
srs56945a608532011-03-17 13:53:01 -040056 UnicodeString UTypeName(void) const;
srs56945a081752010-09-24 20:39:41 -040057 uint16_t GetHexType() const;
srs56946699b012010-02-04 00:55:30 -050058
59 // Information relating to all type data
srs56945a081752010-09-24 20:39:41 -040060 void ShowAllTypes(void) const;
61 int Valid(uint16_t code) const;
srs5694e7b4ff92009-08-18 13:16:10 -040062};
63
srs56945a608532011-03-17 13:53:01 -040064UnicodeString ReadUString(void);
65
srs5694e7b4ff92009-08-18 13:16:10 -040066#endif