diff options
Diffstat (limited to 'parttypes.cc')
-rw-r--r-- | parttypes.cc | 20 |
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; |