summaryrefslogtreecommitdiff
path: root/parttypes.cc
diff options
context:
space:
mode:
authorsrs5694 <srs5694@users.sourceforge.net>2010-09-22 10:50:24 -0400
committersrs5694 <srs5694@users.sourceforge.net>2010-09-22 10:50:24 -0400
commit82f3f0b529ec1bb936141ae41b03f95c72ce573a (patch)
treeb6233ff63f89d536a0cdf38b95e3a7cfb974b6b5 /parttypes.cc
parent327129e9331f888a8fc08d688dcb0a739a3c17be (diff)
downloadsgdisk-82f3f0b529ec1bb936141ae41b03f95c72ce573a.tar.gz
Further refinements to GUID type code entry.
Diffstat (limited to 'parttypes.cc')
-rw-r--r--parttypes.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/parttypes.cc b/parttypes.cc
index 968be74..a9cdf79 100644
--- a/parttypes.cc
+++ b/parttypes.cc
@@ -190,6 +190,26 @@ int PartType::AddType(uint16_t mbrType, const char * guidData, const char * name
return allOK;
} // GUID::AddType(const char* variant)
+// Assignment operator by string. If the original string is short,
+// interpret it as a gdisk hex code; if it's longer, interpret it as
+// a direct entry of a GUID value....
+PartType & PartType::operator=(const string & orig) {
+ uint32_t hexCode;
+
+ if (orig.length() < 32) {
+ sscanf(orig.c_str(), "%x", &hexCode);
+ *this = hexCode;
+ } else {
+ GUIDData::operator=(orig);
+ } // if/else hexCode or GUID
+ return *this;
+} // PartType::operator=(const char * orig)
+
+// Assignment from C-style string; rely on C++ casting....
+PartType & PartType::operator=(const char * orig) {
+ return operator=((string) orig);
+} // PartType::operator=(const char * orig)
+
// Assign a GUID based on my custom 2-byte (16-bit) MBR hex ID variant
PartType & PartType::operator=(uint16_t ID) {
AType* theItem = allTypes;