+}\r
+\r
+inline\r
+bool BamAlignment::GetTag(const std::string& tag, std::string& destination) {\r
+ \r
+ if ( TagData.empty() ) { return false; }\r
+\r
+ // localize the tag data\r
+ char* pTagData = (char*)TagData.data();\r
+ const unsigned int tagDataLen = TagData.size();\r
+ unsigned int numBytesParsed = 0;\r
+\r
+ bool foundReadGroupTag = false;\r
+ while( numBytesParsed < tagDataLen ) {\r
+\r
+ const char* pTagType = pTagData;\r
+ const char* pTagStorageType = pTagData + 2;\r
+ pTagData += 3;\r
+ numBytesParsed += 3;\r
+\r
+ // check the current tag\r
+ if ( std::strncmp(pTagType, tag.c_str(), 2) == 0 ) {\r
+ foundReadGroupTag = true;\r
+ break;\r
+ }\r
+\r
+ // get the storage class and find the next tag\r
+ if (*pTagStorageType == '\0') { return false; }\r
+ SkipToNextTag( *pTagStorageType, pTagData, numBytesParsed );\r
+ if (*pTagData == '\0') { return false; }\r
+ }\r
+\r
+ // return if the read group tag was not present\r
+ if ( !foundReadGroupTag ) { return false; }\r
+\r
+ // assign the read group\r
+ const unsigned int dataLen = std::strlen(pTagData);\r
+ destination.resize(dataLen);\r
+ std::memcpy( (char*)destination.data(), pTagData, dataLen );\r
+ return true;\r
+}\r
+\r
+template<typename T> \r
+bool BamAlignment::GetTag(const std::string& tag, T& destination) {\r
+ \r
+ if ( TagData.empty() ) { return false; }\r
+\r
+ // localize the tag data\r
+ char* pTagData = (char*)TagData.data();\r
+ const unsigned int tagDataLen = TagData.size();\r
+ unsigned int numBytesParsed = 0;\r
+\r
+ bool foundDesiredTag = false;\r
+ while( numBytesParsed < tagDataLen ) {\r
+\r
+ const char* pTagType = pTagData;\r
+ const char* pTagStorageType = pTagData + 2;\r
+ pTagData += 3;\r
+ numBytesParsed += 3;\r
+\r
+ // check the current tag\r
+ if ( strncmp(pTagType, tag.c_str(), 2) == 0 ) {\r
+ foundDesiredTag = true;\r
+ break;\r
+ }\r
+\r
+ // get the storage class and find the next tag\r
+ if (*pTagStorageType == '\0') { return false; }\r
+ SkipToNextTag( *pTagStorageType, pTagData, numBytesParsed );\r
+ if (*pTagData == '\0') { return false; }\r
+ }\r
+ // return if the edit distance tag was not present\r
+ if ( !foundDesiredTag ) { return false; }\r
+\r
+ // assign the editDistance value\r
+ std::memcpy(&destination, pTagData, sizeof(T));\r
+ return true;\r
+}\r
+\r
+inline\r