Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added copyright and license header to the C++ source and header files in the contacte...
[xestiaab/.git] / source / contacteditor / frmContactEditor-LoadGender.cpp
1 // frmContactEditor-LoadGender.cpp - frmContactEditor load gender subroutines.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
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.
10 //
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.
15 //
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;
31         int intPrevValue = 8;
33         SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
34         
35         intPrevValue = 7;                       
36         
37         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
38         intiter != SplitPoints.end(); ++intiter){
39         
40                 SLiter = SplitLength.find(intiter->first);
41         
42                 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
43                 
44                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
45                 PropertyName = PropertyElement.GetNextToken();                          
46                 PropertyValue = PropertyElement.GetNextToken();
47                 
48                 intPrevValue = intiter->second;
49                 
50                 // Process properties.
51                 
52                 size_t intPropertyValueLen = PropertyValue.Len();
53                 
54                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
55                         
56                         PropertyValue.Trim();
57                         PropertyValue.RemoveLast();
58                         
59                 }                               
60                 
61                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
62                         
63                         PropertyValue.Remove(0, 1);
64                         
65                 }                               
66                 
67                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
69                         if (FirstToken == TRUE){
70         
71                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
72                                 FirstToken = FALSE;
73         
74                         } else {
75         
76                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
77         
78                         }
80                 }
81         
82         }       
84         wxStringTokenizer GenderDetails (wxSPropertySeg2, wxT(";"));
85         
86         wxString GenderComponent;
87         wxString GenderIdentity;
88         
89         if (GenderDetails.CountTokens() >= 2){
90         
91                 GenderComponent = GenderDetails.GetNextToken();
92                 GenderIdentity = GenderDetails.GetString();
93         
94                 ProcessCaptureStrings(&GenderIdentity);
95         
96                 txtGenderDescription->SetValue(ContactData->Convert(GenderIdentity, TRUE));
97                                                 
98         } else {
99         
100                 GenderComponent = GenderDetails.GetNextToken();
101         
102         }
103                 
104         if (GenderComponent == wxT("M")){
105                 
106                 // Gender is Male.
107                         
108                 cmbGender->SetSelection(1);
109                 
110         } else if (GenderComponent == wxT("F")){
111                 
112                 // Gender is Female.
113                         
114                 cmbGender->SetSelection(2);                                     
115                 
116         } else if (GenderComponent == wxT("O")){
117                 
118                 // Gender is Other.
119                         
120                 cmbGender->SetSelection(3);
121                 
122         } else if (GenderComponent == wxT("N")){
123                 
124                 // Gender is None/Not Applicable.
125                 
126                 cmbGender->SetSelection(4);                                     
127                 
128         } else if (GenderComponent == wxT("U")){
129                 
130                 // Gender is Unknown.
131                         
132                 cmbGender->SetSelection(5);                                     
133                 
134         }
135         
136         GenderTokens = PropertyTokens;
137         *GenderProcessed = TRUE;
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