From 4a40989643e36ab0e1cd71cffcb6410704e1ee6d Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Mon, 28 Dec 2015 04:35:36 +0000 Subject: [PATCH] Replaced string processing in RELATED with ProcessStringValue. --- source/contacteditor/ContactDataObject.cpp | 63 +++++++--------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index e78af70..ec9a03d 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -2910,6 +2910,8 @@ void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertyS intPrevValue = 8; + bool PropertyMatched = FALSE; + for (std::map::iterator intiter = SplitPoints.begin(); intiter != SplitPoints.end(); ++intiter){ @@ -2942,60 +2944,31 @@ void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertyS CaptureString(&PropertyValue, FALSE); - if (PropertyName == wxT("ALTID")){ - - GeneralRelatedListAltID.erase(*RelatedCount); - GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue)); - - } else if (PropertyName == wxT("PID")){ + ProcessStringValue(&PropertyName, "ALTID", &GeneralRelatedListAltID, &PropertyValue, RelatedCount, &PropertyMatched); + ProcessStringValue(&PropertyName, "PID", &GeneralRelatedListPID, &PropertyValue, RelatedCount, &PropertyMatched); + ProcessStringValue(&PropertyName, "LANGUAGE", &GeneralRelatedListLanguage, &PropertyValue, RelatedCount, &PropertyMatched); + ProcessIntegerValue(&PropertyName, "PREF", &GeneralRelatedListPref, &PropertyValue, RelatedCount, &PropertyMatched); - GeneralRelatedListPID.erase(*RelatedCount); - GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue)); + if (PropertyMatched == TRUE){ - } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - GeneralRelatedListPref.erase(*RelatedCount); - GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber)); - - } + PropertyMatched = FALSE; + continue; - } else if (PropertyName == wxT("LANGUAGE")){ + } - ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount); - - } else if (PropertyName != wxT("TYPE")) { + if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){ + + if (FirstToken == TRUE){ - // Something else we don't know about so append - // to the tokens variable. + PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue); + FirstToken = FALSE; - if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){ + } else { - if (FirstToken == TRUE){ - - PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue); - FirstToken = FALSE; - - } else { - - PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue); - - } + PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue); } - + } } -- 2.39.2