Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Replaced the PREF code in TITLE with ProcessIntegerValue.
[xestiaab/.git] / source / contacteditor / ContactDataObject.cpp
index 532884d..6247596 100644 (file)
@@ -611,24 +611,8 @@ void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySe
                
                } 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){
-
-                               SourceListPref.erase(*SourceCount);
-                               SourceListPref.insert(std::make_pair(*SourceCount, PriorityNumber));
+                       ProcessIntegerValue(this, &SourceListPref, &PropertyValue, SourceCount);
 
-                       }
-               
                } else if (PropertyName == wxT("MEDIATYPE")){
                
                        SourceListMediatype.erase(*SourceCount);
@@ -785,23 +769,7 @@ void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySe
                
                } 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){
-
-                               GroupsListPref.erase(*GroupCount);
-                               GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
-               
-                       }
+                       ProcessIntegerValue(this, &GroupsListPref, &PropertyValue, GroupCount);
                
                } else if (PropertyName == wxT("MEDIATYPE")){
 
@@ -898,23 +866,7 @@ void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2,
                
                } 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){
-
-                               FullNamesListPref.erase(*FNCount);
-                               FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
-
-                       }
+                       ProcessIntegerValue(this, &FullNamesListPref, &PropertyValue, FNCount);
                
                } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
                        
@@ -1274,23 +1226,7 @@ void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString Property
 
                } 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){
-
-                               NicknamesListPref->erase(*NicknameCount);
-                               NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
-
-                       }
+                       ProcessIntegerValue(this, NicknamesListPref, &PropertyValue, NicknameCount);
                
                } else if (PropertyName == wxT("LANGUAGE")){
 
@@ -1765,23 +1701,7 @@ void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString Property
 
                } 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){
-
-                               TZListPref->erase(*TimeZoneCount);
-                               TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
-
-                       }
+                       ProcessIntegerValue(this, TZListPref, &PropertyValue, TimeZoneCount);
                
                } else if (PropertyName == wxT("MEDIATYPE")){
 
@@ -1997,24 +1917,8 @@ void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertyS
                        AddressListMediatype->insert(std::make_pair(*AddressCount, 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){
-
-                               AddressListPref->erase(*AddressCount);
-                               AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
 
-                       }
+                       ProcessIntegerValue(this, AddressListPref, &PropertyValue, AddressCount);
                
                } else {
                
@@ -2279,23 +2183,7 @@ void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg
                
                } 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){
-
-                               EmailListPref->erase(*EmailCount);
-                               EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
-
-                       }
+                       ProcessIntegerValue(this, EmailListPref, &PropertyValue, EmailCount);
                
                } else {
                
@@ -2430,23 +2318,7 @@ void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2,
                
                } 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){
-
-                               IMListPref->erase(*IMCount);
-                               IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
-
-                       }
+                       ProcessIntegerValue(this, IMListPref, &PropertyValue, IMCount);
                
                } else {
                
@@ -2739,24 +2611,8 @@ void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString Propert
                        TelephoneListPID->insert(std::make_pair(*TelephoneCount, 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){
 
-                               TelephoneListPref->erase(*TelephoneCount);
-                               TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
-
-                       }
+                       ProcessIntegerValue(this, TelephoneListPref, &PropertyValue, TelephoneCount);
                
                } else {
                
@@ -2882,23 +2738,7 @@ void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString Property
                
                } 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){
-
-                               LanguageListPref->erase(*LanguageCount);
-                               LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
-
-                       }
+                       ProcessIntegerValue(this, LanguageListPref, &PropertyValue, LanguageCount);
                
                } else {
                
@@ -3031,24 +2871,8 @@ void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString Proper
                        GeopositionListMediatype->insert(std::make_pair(*GeographicCount, 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){
-
-                               GeopositionListPref->erase(*GeographicCount);
-                               GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
 
-                       }
+                       ProcessIntegerValue(this, GeopositionListPref, &PropertyValue, GeographicCount);
                
                } else {
                
@@ -3283,9 +3107,8 @@ void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertyS
                        }
                
                } else if (PropertyName == wxT("LANGUAGE")){
-               
-                       GeneralRelatedListLanguage.erase(*RelatedCount);
-                       GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
+
+                       ProcessIntegerValue(this, &GeneralRelatedListPref, &PropertyValue, RelatedCount);
                
                } else if (PropertyName != wxT("TYPE")) {
                
@@ -3436,25 +3259,9 @@ void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2,
                        WebsiteListPID->insert(std::make_pair(*URLCount, 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){
 
-                               WebsiteListPref->erase(*URLCount);
-                               WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
-
-                       }
-                                       
+                       ProcessIntegerValue(this, WebsiteListPref, &PropertyValue, URLCount);
+                                                       
                } else if (PropertyName == wxT("MEDIATYPE")){
                
                        WebsiteListMediatype->erase(*URLCount);
@@ -3610,25 +3417,9 @@ void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg
                        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));
-
-                       }
-                                       
+                       ProcessIntegerValue(this, TitleListPref, &PropertyValue, TitleCount);
+                       
                } else if (PropertyName == wxT("LANGUAGE")){
                
                        TitleListLanguage->erase(*TitleCount);
@@ -5878,9 +5669,9 @@ void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySe
 }
 
 void ProcessIntegerValue(ContactDataObject *ContactData,
-       std::map<int,int> *KeyListPref
+       std::map<int,int> *PrefPtr
        wxString *PropertyValue, 
-       int *KeyCount){
+       int *ItemCount){
 
        int PriorityNumber = 0; 
        bool ValidNumber = TRUE;
@@ -5895,8 +5686,8 @@ void ProcessIntegerValue(ContactDataObject *ContactData,
 
        if (ValidNumber == TRUE){
 
-               KeyListPref->erase(*KeyCount);
-               KeyListPref->insert(std::make_pair(*KeyCount, PriorityNumber));
+               PrefPtr->erase(*ItemCount);
+               PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
 
        }
 
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy