1 // frmContactEditor-LoadGender.cpp - frmContactEditor load gender subroutines.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "frmContactEditor.h"
21 void frmContactEditor::LoadGender(wxString wxSPropertySeg1, wxString wxSPropertySeg2, bool *GenderProcessed, vCard *ContactData){
23 std::map<int, int> SplitPoints;
24 std::map<int, int> SplitLength;
25 std::map<int, int>::iterator SLiter;
26 wxString PropertyData;
27 wxString PropertyName;
28 wxString PropertyValue;
29 wxString PropertyTokens;
30 bool FirstToken = TRUE;
33 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
37 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
38 intiter != SplitPoints.end(); ++intiter){
40 SLiter = SplitLength.find(intiter->first);
42 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
44 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
45 PropertyName = PropertyElement.GetNextToken();
46 PropertyValue = PropertyElement.GetNextToken();
48 intPrevValue = intiter->second;
50 // Process properties.
52 size_t intPropertyValueLen = PropertyValue.Len();
54 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
57 PropertyValue.RemoveLast();
61 if (PropertyValue.Mid(0, 1) == wxT("\"")){
63 PropertyValue.Remove(0, 1);
67 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
69 if (FirstToken == TRUE){
71 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
76 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
84 wxStringTokenizer GenderDetails (wxSPropertySeg2, wxT(";"));
86 wxString GenderComponent;
87 wxString GenderIdentity;
89 if (GenderDetails.CountTokens() >= 2){
91 GenderComponent = GenderDetails.GetNextToken();
92 GenderIdentity = GenderDetails.GetString();
94 ProcessCaptureStrings(&GenderIdentity);
96 txtGenderDescription->SetValue(ContactData->Convert(GenderIdentity, TRUE));
100 GenderComponent = GenderDetails.GetNextToken();
104 if (GenderComponent == wxT("M")){
108 cmbGender->SetSelection(1);
110 } else if (GenderComponent == wxT("F")){
114 cmbGender->SetSelection(2);
116 } else if (GenderComponent == wxT("O")){
120 cmbGender->SetSelection(3);
122 } else if (GenderComponent == wxT("N")){
124 // Gender is None/Not Applicable.
126 cmbGender->SetSelection(4);
128 } else if (GenderComponent == wxT("U")){
130 // Gender is Unknown.
132 cmbGender->SetSelection(5);
136 GenderTokens = PropertyTokens;
137 *GenderProcessed = TRUE;