0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / RWStepBasic / RWStepBasic_RWPerson.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <Interface_Check.hxx>
16 #include <Interface_HArray1OfHAsciiString.hxx>
17 #include <RWStepBasic_RWPerson.hxx>
18 #include <StepBasic_Person.hxx>
19 #include <StepData_StepReaderData.hxx>
20 #include <StepData_StepWriter.hxx>
21
22 RWStepBasic_RWPerson::RWStepBasic_RWPerson () {}
23
24 void RWStepBasic_RWPerson::ReadStep
25         (const Handle(StepData_StepReaderData)& data,
26          const Standard_Integer num,
27          Handle(Interface_Check)& ach,
28          const Handle(StepBasic_Person)& ent) const
29 {
30
31
32         // --- Number of Parameter Control ---
33
34         if (!data->CheckNbParams(num,6,ach,"person")) return;
35
36         // --- own field : id ---
37
38         Handle(TCollection_HAsciiString) aId;
39         //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
40         data->ReadString (num,1,"id",ach,aId);
41
42         // --- own field : lastName ---
43
44         Handle(TCollection_HAsciiString) aLastName;
45         Standard_Boolean hasAlastName = Standard_True;
46         if (data->IsParamDefined(num,2)) {
47           //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
48           data->ReadString (num,2,"last_name",ach,aLastName);
49         }
50         else {
51           hasAlastName = Standard_False;
52           aLastName.Nullify();
53         }
54
55         // --- own field : firstName ---
56
57         Handle(TCollection_HAsciiString) aFirstName;
58         Standard_Boolean hasAfirstName = Standard_True;
59         if (data->IsParamDefined(num,3)) {
60           //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
61           data->ReadString (num,3,"first_name",ach,aFirstName);
62         }
63         else {
64           hasAfirstName = Standard_False;
65           aFirstName.Nullify();
66         }
67
68         // --- own field : middleNames ---
69
70         Handle(Interface_HArray1OfHAsciiString) aMiddleNames;
71         Standard_Boolean hasAmiddleNames = Standard_True;
72         if (data->IsParamDefined(num,4)) {
73           Handle(TCollection_HAsciiString) aMiddleNamesItem;
74           Standard_Integer nsub4;
75           if (data->ReadSubList (num,4,"middle_names",ach,nsub4)) {
76             Standard_Integer nb4 = data->NbParams(nsub4);
77             aMiddleNames = new Interface_HArray1OfHAsciiString (1, nb4);
78             for (Standard_Integer i4 = 1; i4 <= nb4; i4 ++) {
79               //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed
80               if (data->ReadString (nsub4,i4,"middle_names",ach,aMiddleNamesItem))
81                 aMiddleNames->SetValue(i4,aMiddleNamesItem);
82             }
83           }
84         }
85         else {
86           hasAmiddleNames = Standard_False;
87           aMiddleNames.Nullify();
88         }
89
90         // --- own field : prefixTitles ---
91
92         Handle(Interface_HArray1OfHAsciiString) aPrefixTitles;
93         Standard_Boolean hasAprefixTitles = Standard_True;
94         if (data->IsParamDefined(num,5)) {
95           Handle(TCollection_HAsciiString) aPrefixTitlesItem;
96           Standard_Integer nsub5;
97           if (data->ReadSubList (num,5,"prefix_titles",ach,nsub5)) {
98             Standard_Integer nb5 = data->NbParams(nsub5);
99             aPrefixTitles = new Interface_HArray1OfHAsciiString (1, nb5);
100             for (Standard_Integer i5 = 1; i5 <= nb5; i5 ++) {
101               //szv#4:S4163:12Mar99 `Standard_Boolean stat5 =` not needed
102               if (data->ReadString (nsub5,i5,"prefix_titles",ach,aPrefixTitlesItem))
103                 aPrefixTitles->SetValue(i5,aPrefixTitlesItem);
104             }
105           }
106         }
107         else {
108           hasAprefixTitles = Standard_False;
109           aPrefixTitles.Nullify();
110         }
111
112         // --- own field : suffixTitles ---
113
114         Handle(Interface_HArray1OfHAsciiString) aSuffixTitles;
115         Standard_Boolean hasAsuffixTitles = Standard_True;
116         if (data->IsParamDefined(num,6)) {
117           Handle(TCollection_HAsciiString) aSuffixTitlesItem;
118           Standard_Integer nsub6;
119           if (data->ReadSubList (num,6,"suffix_titles",ach,nsub6)) {
120             Standard_Integer nb6 = data->NbParams(nsub6);
121             aSuffixTitles = new Interface_HArray1OfHAsciiString (1, nb6);
122             for (Standard_Integer i6 = 1; i6 <= nb6; i6 ++) {
123               //szv#4:S4163:12Mar99 `Standard_Boolean stat6 =` not needed
124               if (data->ReadString (nsub6,i6,"suffix_titles",ach,aSuffixTitlesItem))
125                 aSuffixTitles->SetValue(i6,aSuffixTitlesItem);
126             }
127           }
128         }
129         else {
130           hasAsuffixTitles = Standard_False;
131           aSuffixTitles.Nullify();
132         }
133
134         //--- Initialisation of the read entity ---
135
136
137         ent->Init(aId, hasAlastName, aLastName, hasAfirstName, aFirstName, hasAmiddleNames, aMiddleNames, hasAprefixTitles, aPrefixTitles, hasAsuffixTitles, aSuffixTitles);
138 }
139
140
141 void RWStepBasic_RWPerson::WriteStep
142         (StepData_StepWriter& SW,
143          const Handle(StepBasic_Person)& ent) const
144 {
145
146         // --- own field : id ---
147
148         SW.Send(ent->Id());
149
150         // --- own field : lastName ---
151
152         Standard_Boolean hasAlastName = ent->HasLastName();
153         if (hasAlastName) {
154           SW.Send(ent->LastName());
155         }
156         else {
157           SW.SendUndef();
158         }
159
160         // --- own field : firstName ---
161
162         Standard_Boolean hasAfirstName = ent->HasFirstName();
163         if (hasAfirstName) {
164           SW.Send(ent->FirstName());
165         }
166         else {
167           SW.SendUndef();
168         }
169
170         // --- own field : middleNames ---
171
172         Standard_Boolean hasAmiddleNames = ent->HasMiddleNames();
173         if (hasAmiddleNames) {
174           SW.OpenSub();
175           for (Standard_Integer i4 = 1;  i4 <= ent->NbMiddleNames();  i4 ++) {
176             SW.Send(ent->MiddleNamesValue(i4));
177           }
178           SW.CloseSub();
179         }
180         else {
181           SW.SendUndef();
182         }
183
184         // --- own field : prefixTitles ---
185
186         Standard_Boolean hasAprefixTitles = ent->HasPrefixTitles();
187         if (hasAprefixTitles) {
188           SW.OpenSub();
189           for (Standard_Integer i5 = 1;  i5 <= ent->NbPrefixTitles();  i5 ++) {
190             SW.Send(ent->PrefixTitlesValue(i5));
191           }
192           SW.CloseSub();
193         }
194         else {
195           SW.SendUndef();
196         }
197
198         // --- own field : suffixTitles ---
199
200         Standard_Boolean hasAsuffixTitles = ent->HasSuffixTitles();
201         if (hasAsuffixTitles) {
202           SW.OpenSub();
203           for (Standard_Integer i6 = 1;  i6 <= ent->NbSuffixTitles();  i6 ++) {
204             SW.Send(ent->SuffixTitlesValue(i6));
205           }
206           SW.CloseSub();
207         }
208         else {
209           SW.SendUndef();
210         }
211 }