+void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
+
+ std::map<int, int> SplitPoints;
+ std::map<int, int> SplitLength;
+ std::map<int, int>::iterator SLiter;
+ wxString PropertyData;
+ wxString PropertyName;
+ wxString PropertyValue;
+ wxString PropertyTokens;
+ bool FirstToken = TRUE;
+ int intPrevValue = 7;
+ int intPref = 0;
+ int intType = 0;
+ long ListCtrlIndex;
+
+ SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
+
+ intPrevValue = 6;
+
+ PropertyType PropType = PROPERTY_NONE;
+
+ // Look for type before continuing.
+
+ CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
+
+ // Setup the pointers.
+
+ std::map<int, wxString> *TitleList = NULL;
+ std::map<int, wxString> *TitleListAltID = NULL;
+ std::map<int, wxString> *TitleListPID = NULL;
+ std::map<int, wxString> *TitleListType = NULL;
+ std::map<int, wxString> *TitleListTokens = NULL;
+ std::map<int, wxString> *TitleListLanguage = NULL;
+ std::map<int, int> *TitleListPref = NULL;
+
+ // Setup blank lines for later on.
+
+ switch(PropType){
+ case PROPERTY_NONE:
+ TitleList = &GeneralTitleList;
+ TitleListType = &GeneralTitleListType;
+ TitleListAltID = &GeneralTitleListAltID;
+ TitleListPID = &GeneralTitleListPID;
+ TitleListTokens = &GeneralTitleListTokens;
+ TitleListLanguage = &GeneralTitleListLanguage;
+ TitleListPref = &GeneralTitleListPref;
+ break;
+ case PROPERTY_HOME:
+ TitleList = &HomeTitleList;
+ TitleListType = &HomeTitleListType;
+ TitleListAltID = &HomeTitleListAltID;
+ TitleListPID = &HomeTitleListPID;
+ TitleListTokens = &HomeTitleListTokens;
+ TitleListLanguage = &HomeTitleListLanguage;
+ TitleListPref = &HomeTitleListPref;
+ break;
+ case PROPERTY_WORK:
+ TitleList = &BusinessTitleList;
+ TitleListType = &BusinessTitleListType;
+ TitleListAltID = &BusinessTitleListAltID;
+ TitleListPID = &BusinessTitleListPID;
+ TitleListTokens = &BusinessTitleListTokens;
+ TitleListLanguage = &BusinessTitleListLanguage;
+ TitleListPref = &BusinessTitleListPref;
+ break;
+ }
+
+ intPrevValue = 6;
+
+ for (std::map<int, int>::iterator intiter = SplitPoints.begin();
+ intiter != SplitPoints.end(); ++intiter){
+
+ SLiter = SplitLength.find(intiter->first);
+
+ PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
+
+ wxStringTokenizer PropertyElement (PropertyData, wxT("="));
+ PropertyName = PropertyElement.GetNextToken();
+ PropertyValue = PropertyElement.GetNextToken();
+
+ intPrevValue = intiter->second;
+
+ // Process properties.
+
+ size_t intPropertyValueLen = PropertyValue.Len();
+
+ if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
+
+ PropertyValue.Trim();
+ PropertyValue.RemoveLast();
+
+ }
+
+ if (PropertyValue.Mid(0, 1) == wxT("\"")){
+
+ PropertyValue.Remove(0, 1);
+
+ }
+
+ CaptureString(&PropertyValue, FALSE);
+
+ if (PropertyName == wxT("ALTID")){
+
+ TitleListAltID->erase(*TitleCount);
+ TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
+
+ } else if (PropertyName == wxT("PID")){
+
+ TitleListPID->erase(*TitleCount);
+ TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
+
+ } 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){
+
+ TitleListPref->erase(*TitleCount);
+ TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
+
+ }
+
+ } else if (PropertyName == wxT("LANGUAGE")){
+
+ TitleListLanguage->erase(*TitleCount);
+ TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
+
+ } else {
+
+ // Something else we don't know about so append
+ // to the tokens variable.
+
+ if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
+
+ if (FirstToken == TRUE){
+
+ PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
+ FirstToken = FALSE;
+
+ } else {
+
+ PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
+
+ }
+
+ }
+
+ }
+
+ }
+
+ // Add the data to the General/Home/Work address variables.
+
+ CaptureString(&PropertySeg2, FALSE);
+
+ TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
+
+ if (!PropertyTokens.IsEmpty()){
+
+ TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
+
+ }
+
+}
+