nsresult nsAutoCompleteSimpleResult::AppendResult(nsIAutoCompleteResult* aResult) { nsAutoString searchString; nsresult rv = aResult->GetSearchString(searchString); NS_ENSURE_SUCCESS(rv, rv); mSearchString = searchString; uint16_t searchResult; rv = aResult->GetSearchResult(&searchResult); NS_ENSURE_SUCCESS(rv, rv); mSearchResult = searchResult; nsAutoString errorDescription; if (NS_SUCCEEDED(aResult->GetErrorDescription(errorDescription)) && !errorDescription.IsEmpty()) { mErrorDescription = errorDescription; } int32_t defaultIndex = -1; if (NS_SUCCEEDED(aResult->GetDefaultIndex(&defaultIndex)) && defaultIndex >= 0) { mDefaultIndex = defaultIndex; } nsCOMPtr<nsIAutoCompleteSimpleResult> simpleResult = do_QueryInterface(aResult); if (simpleResult) { nsCOMPtr<nsIAutoCompleteSimpleResultListener> listener; if (NS_SUCCEEDED(simpleResult->GetListener(getter_AddRefs(listener))) && listener) { listener.swap(mListener); } } // Copy matches. uint32_t matchCount = 0; rv = aResult->GetMatchCount(&matchCount); NS_ENSURE_SUCCESS(rv, rv); for (size_t i = 0; i < matchCount; ++i) { nsAutoString value, comment, image, style, finalCompleteValue, label; rv = aResult->GetValueAt(i, value); NS_ENSURE_SUCCESS(rv, rv); rv = aResult->GetCommentAt(i, comment); NS_ENSURE_SUCCESS(rv, rv); rv = aResult->GetImageAt(i, image); NS_ENSURE_SUCCESS(rv, rv); rv = aResult->GetStyleAt(i, style); NS_ENSURE_SUCCESS(rv, rv); rv = aResult->GetFinalCompleteValueAt(i, finalCompleteValue); NS_ENSURE_SUCCESS(rv, rv); rv = aResult->GetLabelAt(i, label); NS_ENSURE_SUCCESS(rv, rv); rv = AppendMatch(value, comment, image, style, finalCompleteValue, label); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; }
void AlignTwoMSAsGivenPathSW(const PWPath &Path, const MSA &msaA, const MSA &msaB, MSA &msaCombined) { msaCombined.Clear(); #if TRACE Log("AlignTwoMSAsGivenPathSW\n"); Log("Template A:\n"); msaA.LogMe(); Log("Template B:\n"); msaB.LogMe(); #endif const unsigned uColCountA = msaA.GetColCount(); const unsigned uColCountB = msaB.GetColCount(); const unsigned uSeqCountA = msaA.GetSeqCount(); const unsigned uSeqCountB = msaB.GetSeqCount(); msaCombined.SetSeqCount(uSeqCountA + uSeqCountB); // Copy sequence names into combined MSA for (unsigned uSeqIndexA = 0; uSeqIndexA < uSeqCountA; ++uSeqIndexA) { msaCombined.SetSeqName(uSeqIndexA, msaA.GetSeqName(uSeqIndexA)); msaCombined.SetSeqId(uSeqIndexA, msaA.GetSeqId(uSeqIndexA)); } for (unsigned uSeqIndexB = 0; uSeqIndexB < uSeqCountB; ++uSeqIndexB) { msaCombined.SetSeqName(uSeqCountA + uSeqIndexB, msaB.GetSeqName(uSeqIndexB)); msaCombined.SetSeqId(uSeqCountA + uSeqIndexB, msaB.GetSeqId(uSeqIndexB)); } unsigned uColIndexA = 0; unsigned uColIndexB = 0; unsigned uColIndexCombined = 0; const unsigned uEdgeCount = Path.GetEdgeCount(); for (unsigned uEdgeIndex = 0; uEdgeIndex < uEdgeCount; ++uEdgeIndex) { const PWEdge &Edge = Path.GetEdge(uEdgeIndex); #if TRACE Log("\nEdge %u %c%u.%u\n", uEdgeIndex, Edge.cType, Edge.uPrefixLengthA, Edge.uPrefixLengthB); #endif const char cType = Edge.cType; const unsigned uPrefixLengthA = Edge.uPrefixLengthA; unsigned uColCountA = 0; if (uPrefixLengthA > 0) { const unsigned uNodeIndexA = uPrefixLengthA - 1; const unsigned uTplColIndexA = uNodeIndexA; if (uTplColIndexA > uColIndexA) uColCountA = uTplColIndexA - uColIndexA; } const unsigned uPrefixLengthB = Edge.uPrefixLengthB; unsigned uColCountB = 0; if (uPrefixLengthB > 0) { const unsigned uNodeIndexB = uPrefixLengthB - 1; const unsigned uTplColIndexB = uNodeIndexB; if (uTplColIndexB > uColIndexB) uColCountB = uTplColIndexB - uColIndexB; } AppendUnalignedTerminals(msaA, uColIndexA, uColCountA, msaB, uColIndexB, uColCountB, uSeqCountA, uSeqCountB, msaCombined, uColIndexCombined); switch (cType) { case 'M': { assert(uPrefixLengthA > 0); assert(uPrefixLengthB > 0); const unsigned uColA = uPrefixLengthA - 1; const unsigned uColB = uPrefixLengthB - 1; assert(uColIndexA == uColA); assert(uColIndexB == uColB); AppendMatch(msaA, uColIndexA, msaB, uColIndexB, uSeqCountA, uSeqCountB, msaCombined, uColIndexCombined); break; } case 'D': { assert(uPrefixLengthA > 0); const unsigned uColA = uPrefixLengthA - 1; assert(uColIndexA == uColA); AppendDelete(msaA, uColIndexA, uSeqCountA, uSeqCountB, msaCombined, uColIndexCombined); break; } case 'I': { assert(uPrefixLengthB > 0); const unsigned uColB = uPrefixLengthB - 1; assert(uColIndexB == uColB); AppendInsert(msaB, uColIndexB, uSeqCountA, uSeqCountB, msaCombined, uColIndexCombined); break; } default: assert(false); } } unsigned uInsertColCountA = uColCountA - uColIndexA; unsigned uInsertColCountB = uColCountB - uColIndexB; AppendUnalignedTerminals(msaA, uColIndexA, uInsertColCountA, msaB, uColIndexB, uInsertColCountB, uSeqCountA, uSeqCountB, msaCombined, uColIndexCombined); }