wxString PropertyValue;
wxString PropertyTokens;
bool FirstToken = TRUE;
+ bool PropertyMatched = FALSE;
int intSplitsFound = 0;
int intSplitSize = 0;
int intPrevValue = 8;
CaptureString(&PropertyValue, FALSE);
- if (PropertyName == wxT("ALTID")){
-
- SourceListAltID.erase(*SourceCount);
- SourceListAltID.insert(std::make_pair(*SourceCount, PropertyValue));
+ ProcessStringValue(&PropertyName, "ALTID", &SourceListAltID, &PropertyValue, SourceCount, &PropertyMatched);
+ ProcessStringValue(&PropertyName, "PID", &SourceListPID, &PropertyValue, SourceCount, &PropertyMatched);
+ ProcessStringValue(&PropertyName, "MEDIATYPE", &SourceListMediatype, &PropertyValue, SourceCount, &PropertyMatched);
+ ProcessIntegerValue(&PropertyName, "PREF", &SourceListPref, &PropertyValue, SourceCount, &PropertyMatched);
- } else if (PropertyName == wxT("PID")){
-
- SourceListPID.erase(*SourceCount);
- SourceListPID.insert(std::make_pair(*SourceCount, PropertyValue));
+ if (PropertyMatched == TRUE){
- } else if (PropertyName == wxT("PREF")){
-
- ProcessIntegerValue(this, &SourceListPref, &PropertyValue, SourceCount);
-
- } else if (PropertyName == wxT("MEDIATYPE")){
+ PropertyMatched = FALSE;
+ continue;
- SourceListMediatype.erase(*SourceCount);
- SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue));
-
- } else {
+ }
- // Something else we don't know about so append
- // to the tokens variable.
-
- if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
+ 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);
+ if (FirstToken == TRUE){
- }
+ PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
+ FirstToken = FALSE;
+
+ } else {
+
+ PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
}
wxString PropertyTokens;
std::map<int,int>::iterator SLiter;
bool FirstToken = TRUE;
+ bool PropertyMatched = FALSE;
for (std::map<int, int>::iterator intiter = SplitPoints.begin();
intiter != SplitPoints.end(); ++intiter){
CaptureString(&PropertyValue, FALSE);
- if (PropertyName == wxT("ALTID")){
-
- XMLListAltID.erase(*XMLCount);
- XMLListAltID.insert(std::make_pair(*XMLCount, PropertyValue));
+ ProcessStringValue(&PropertyName, "ALTID", &XMLListAltID, &PropertyValue, XMLCount, &PropertyMatched);
+
+ if (PropertyMatched == TRUE){
+
+ PropertyMatched = FALSE;
+ continue;
}
wxString PropertyTokens;
std::map<int,int>::iterator SLiter;
bool FirstToken = TRUE;
+ bool PropertyMatched = FALSE;
for (std::map<int, int>::iterator intiter = SplitPoints.begin();
intiter != SplitPoints.end(); ++intiter){
CaptureString(&PropertyValue, FALSE);
- if (PropertyName == wxT("ALTID")){
-
- GroupsListAltID.erase(*GroupCount);
- GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
+ ProcessStringValue(&PropertyName, "ALTID", &GroupsListAltID, &PropertyValue, GroupCount, &PropertyMatched);
+ ProcessStringValue(&PropertyName, "PID", &GroupsListPID, &PropertyValue, GroupCount, &PropertyMatched);
+ ProcessStringValue(&PropertyName, "MEDIATYPE", &GroupsListMediaType, &PropertyValue, GroupCount, &PropertyMatched);
+ ProcessIntegerValue(&PropertyName, "PREF", &GroupsListPref, &PropertyValue, GroupCount, &PropertyMatched);
- } else if (PropertyName == wxT("PID")){
-
- GroupsListPID.erase(*GroupCount);
- GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
+ if (PropertyMatched == TRUE){
- } else if (PropertyName == wxT("PREF")){
-
- ProcessIntegerValue(this, &GroupsListPref, &PropertyValue, GroupCount);
+ PropertyMatched = FALSE;
+ continue;
- } else if (PropertyName == wxT("MEDIATYPE")){
-
- GroupsListMediaType.erase(*GroupCount);
- GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
+ }
- } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
+ if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
if (FirstToken == TRUE){
wxString PropertyTokens;
std::map<int,int>::iterator SLiter;
bool FirstToken = TRUE;
+ bool PropertyMatched = FALSE;
for (std::map<int, int>::iterator intiter = SplitPoints.begin();
intiter != SplitPoints.end(); ++intiter){
FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
}
+
+ PropertyMatched = TRUE;
- } else if (PropertyName == wxT("LANGUAGE")){
-
- FullNamesListLanguage.erase(*FNCount);
- FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
+ }
- } else if (PropertyName == wxT("ALTID")){
+ ProcessStringValue(&PropertyName, "ALTID", &FullNamesListAltID, &PropertyValue, FNCount, &PropertyMatched);
+ ProcessStringValue(&PropertyName, "PID", &FullNamesListPID, &PropertyValue, FNCount, &PropertyMatched);
+ ProcessStringValue(&PropertyName, "LANGUAGE", &FullNamesListLanguage, &PropertyValue, FNCount, &PropertyMatched);
+ ProcessIntegerValue(&PropertyName, "PREF", &FullNamesListPref, &PropertyValue, FNCount, &PropertyMatched);
- FullNamesListAltID.erase(*FNCount);
- FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
+ if (PropertyMatched == TRUE){
- } else if (PropertyName == wxT("PID")){
-
- FullNamesListPID.erase(*FNCount);
- FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
+ PropertyMatched = FALSE;
+ continue;
- } else if (PropertyName == wxT("PREF")){
-
- ProcessIntegerValue(this, &FullNamesListPref, &PropertyValue, FNCount);
+ }
- } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
+ if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
if (FirstToken == TRUE){
} else if (PropertyName == wxT("PREF")){
- ProcessIntegerValue(this, NicknamesListPref, &PropertyValue, NicknameCount);
+ ProcessIntegerValue(NicknamesListPref, &PropertyValue, NicknameCount);
} else if (PropertyName == wxT("LANGUAGE")){
} else if (PropertyName == wxT("PREF")){
- ProcessIntegerValue(this, TZListPref, &PropertyValue, TimeZoneCount);
+ ProcessIntegerValue(TZListPref, &PropertyValue, TimeZoneCount);
} else if (PropertyName == wxT("MEDIATYPE")){
} else if (PropertyName == wxT("PREF")){
- ProcessIntegerValue(this, AddressListPref, &PropertyValue, AddressCount);
+ ProcessIntegerValue(AddressListPref, &PropertyValue, AddressCount);
} else {
} else if (PropertyName == wxT("PREF")){
- ProcessIntegerValue(this, EmailListPref, &PropertyValue, EmailCount);
+ ProcessIntegerValue(EmailListPref, &PropertyValue, EmailCount);
} else {
} else if (PropertyName == wxT("PREF")){
- ProcessIntegerValue(this, IMListPref, &PropertyValue, IMCount);
+ ProcessIntegerValue(IMListPref, &PropertyValue, IMCount);
} else {
} else if (PropertyName == wxT("PREF")){
- ProcessIntegerValue(this, TelephoneListPref, &PropertyValue, TelephoneCount);
+ ProcessIntegerValue(TelephoneListPref, &PropertyValue, TelephoneCount);
} else {
} else if (PropertyName == wxT("PREF")){
- ProcessIntegerValue(this, LanguageListPref, &PropertyValue, LanguageCount);
+ ProcessIntegerValue(LanguageListPref, &PropertyValue, LanguageCount);
} else {
} else if (PropertyName == wxT("PREF")){
- ProcessIntegerValue(this, GeopositionListPref, &PropertyValue, GeographicCount);
+ ProcessIntegerValue(GeopositionListPref, &PropertyValue, GeographicCount);
} else {
} else if (PropertyName == wxT("LANGUAGE")){
- ProcessIntegerValue(this, &GeneralRelatedListPref, &PropertyValue, RelatedCount);
+ ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount);
} else if (PropertyName != wxT("TYPE")) {
} else if (PropertyName == wxT("PREF")){
- ProcessIntegerValue(this, WebsiteListPref, &PropertyValue, URLCount);
+ ProcessIntegerValue(WebsiteListPref, &PropertyValue, URLCount);
} else if (PropertyName == wxT("MEDIATYPE")){
} else if (PropertyName == wxT("PREF")){
- ProcessIntegerValue(this, TitleListPref, &PropertyValue, TitleCount);
+ ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount);
} else if (PropertyName == wxT("LANGUAGE")){
} else if (PropertyName == wxT("PREF")){
- ProcessIntegerValue(this, RoleListPref, &PropertyValue, RoleCount);
+ ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount);
} else if (PropertyName == wxT("LANGUAGE")){
OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, 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){
-
- OrganisationsListPref->erase(*OrganisationCount);
- OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
- }
-
+ ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount);
+
} else if (PropertyName == wxT("LANGUAGE")){
OrganisationsListLanguage->erase(*OrganisationCount);
NoteListPID->insert(std::make_pair(*NoteCount, 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){
-
- NoteListPref->erase(*NoteCount);
- NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
- }
-
+ ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount);
+
} else if (PropertyName == wxT("LANGUAGE")){
NoteListLanguage->erase(*NoteCount);
CategoriesListPID.insert(std::make_pair(*CategoryCount, 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){
- CategoriesListPref.erase(*CategoryCount);
- CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
-
- }
-
+ ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount);
+
} else if (PropertyName == wxT("LANGUAGE")){
CategoriesListLanguage.erase(*CategoryCount);
PicturesListPID.insert(std::make_pair(*PhotoCount, 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){
-
- PicturesListPref.erase(*PhotoCount);
- PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
-
- }
+ ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount);
} else if (PropertyName == wxT("MEDIATYPE")){
LogosListPID.insert(std::make_pair(*LogoCount, 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){
-
- LogosListPref.erase(*LogoCount);
- LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
-
- }
+ ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount);
} else if (PropertyName == wxT("MEDIATYPE")){
SoundsListPID.insert(std::make_pair(*SoundCount, 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){
-
- SoundsListPref.erase(*SoundCount);
- SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
- }
+ ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount);
} else if (PropertyName == wxT("MEDIATYPE")){
CalendarListPID.insert(std::make_pair(*CalURICount, 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){
- CalendarListPref.erase(*CalURICount);
- CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
-
- }
+ ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount);
} else if (PropertyName == wxT("MEDIATYPE")){
CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, 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){
- CalendarRequestListPref.erase(*CalAdrURICount);
- CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
-
- }
+ ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount);
} else if (PropertyName == wxT("MEDIATYPE")){
FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, 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){
-
- FreeBusyListPref.erase(*FreeBusyAddressCount);
- FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
- }
+ ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount);
} else if (PropertyName == wxT("MEDIATYPE")){
KeyListPID.insert(std::make_pair(*KeyCount, 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){
-
- KeyListPref.erase(*KeyCount);
- KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
- }
+ ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount);
} else {
}
-void ProcessIntegerValue(ContactDataObject *ContactData,
+void ProcessStringValue(wxString *PropertyName,
+ wxString PropertyNameMatch,
+ std::map<int,wxString> *MapPtr,
+ wxString *PropertyValue,
+ int *ItemCount,
+ bool *PropertyMatched){
+
+ if (*PropertyName == PropertyNameMatch){
+ MapPtr->erase(*ItemCount);
+ MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
+ *PropertyMatched = TRUE;
+ }
+
+}
+
+void ProcessIntegerValue(wxString *PropertyName,
+ wxString PropertyNameMatch,
std::map<int,int> *PrefPtr,
+ wxString *PropertyValue,
+ int *ItemCount,
+ bool *PropertyMatched){
+
+ if (*PropertyName == PropertyNameMatch){
+ *PropertyMatched = TRUE;
+ } else {
+ return;
+ }
+
+ int PriorityNumber = 0;
+ bool ValidNumber = TRUE;
+
+ try{
+ PriorityNumber = std::stoi(PropertyValue->ToStdString());
+ }
+
+ catch(std::invalid_argument &e){
+ ValidNumber = FALSE;
+ }
+
+ if (ValidNumber == TRUE){
+
+ PrefPtr->erase(*ItemCount);
+ PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
+
+ }
+
+}
+
+void ProcessIntegerValue(std::map<int,int> *PrefPtr,
wxString *PropertyValue,
int *ItemCount){