0023947: Eliminate trivial compiler warnings in MSVC++ with warning level 4
[occt.git] / src / StepData / StepData_Field.cxx
1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
2 //
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
7 //
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10 //
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
17
18 #include <StepData_Field.ixx>
19 #include <Interface_Macros.hxx>
20 #include <StepData_SelectMember.hxx>
21 #include <StepData_SelectInt.hxx>
22 #include <StepData_SelectReal.hxx>
23 #include <StepData_SelectNamed.hxx>
24 #include <TCollection_HAsciiString.hxx>
25 #include <TColStd_HArray1OfInteger.hxx>
26 #include <TColStd_HArray1OfReal.hxx>
27 #include <TColStd_HArray1OfTransient.hxx>
28 #include <Interface_HArray1OfHAsciiString.hxx>
29 #include <TColStd_HArray2OfInteger.hxx>
30 #include <TColStd_HArray2OfReal.hxx>
31 #include <TColStd_HArray2OfTransient.hxx>
32
33 //  Le kind code le type de donnee, le mode d acces (direct ou via Select),
34 //  l arite (simple, liste, carre)
35
36 //  Valeurs pour Kind : 0 = Clear/Undefined
37 //  KindInteger KindBoolean KindLogical KindEnum KindReal KindString KindEntity
38 //  + KindSelect qui s y substitue et peut s y combiner
39 //  + KindList et KindList2  qui peuvent s y combiner
40 //  (sur masque KindArity et decalage ShiftArity)
41
42 #define KindInteger 1
43 #define KindBoolean 2
44 #define KindLogical 3
45 #define KindEnum    4
46 #define KindReal    5
47 #define KindString  6
48 #define KindEntity  7
49 #define KindAny     8
50 #define KindDerived 9
51
52 #define KindType    15
53 #define KindSelect  16
54 #define KindArity   192
55 #define KindList    64
56 #define KindList2   128
57 #define ShiftArity  6
58
59 static Standard_Integer TrueKind (const Standard_Integer kind)
60 {  return (kind & KindType);  }
61
62
63     StepData_Field::StepData_Field ()    {  Clear();  }
64
65     StepData_Field::StepData_Field
66   (const StepData_Field& other, const Standard_Boolean copy)
67 {
68   if (copy)  {  CopyFrom(other);  return;  }
69   thekind = other.Kind(Standard_False);  theint = other.Int();
70   thereal = other.Real();  theany = other.Transient();
71 }
72
73     void  StepData_Field::CopyFrom (const StepData_Field& other)
74 {
75   thekind = other.Kind(Standard_False);  theint = other.Int();
76   thereal = other.Real();  theany = other.Transient();
77   if (thekind == KindString || thekind == KindEnum) {
78     DeclareAndCast(TCollection_HAsciiString,str,theany);
79     if (!str.IsNull()) theany = new TCollection_HAsciiString (str->ToCString());
80     return;
81   }
82   if (thekind == KindSelect) {
83 //  Differents cas
84     DeclareAndCast(StepData_SelectReal,sr,theany);
85     if (!sr.IsNull()) {
86       Standard_Real val = sr->Real();
87       sr = new StepData_SelectReal;  sr->SetReal(val);
88       theany = sr;  return;
89     }
90     DeclareAndCast(StepData_SelectInt,si,theany);
91     if (!si.IsNull()) {
92       Standard_Integer ival = si->Int(), ik = si->Kind();
93       si = new StepData_SelectInt;  si->SetKind(ik);  si->SetInt(ival);
94       theany = si;  return;
95     }
96     DeclareAndCast(StepData_SelectNamed,sn,theany);
97     if (!sn.IsNull()) {
98       Handle(StepData_SelectNamed) sn2 = new StepData_SelectNamed;
99       if (sn->HasName()) sn2->SetName(sn2->Name());
100       sn2->CField().CopyFrom(*this);
101       theany = sn2;  return;
102     }
103   }
104 //    Les listes ...
105   if ((thekind & KindArity) == KindList)  {
106     Standard_Integer i, low, up;
107     DeclareAndCast(TColStd_HArray1OfInteger,hi,theany);
108     if (!hi.IsNull()) {
109       low = hi->Lower();  up = hi->Upper();
110       Handle(TColStd_HArray1OfInteger) hi2 = new TColStd_HArray1OfInteger (low,up);
111       for (i = low; i <= up; i ++) hi2->SetValue (i,hi->Value(i));
112       return;
113     }
114     DeclareAndCast(TColStd_HArray1OfReal,hr,theany);
115     if (!hr.IsNull()) {
116       low = hr->Lower();  up = hr->Upper();
117       Handle(TColStd_HArray1OfReal) hr2 = new TColStd_HArray1OfReal (low,up);
118       for (i = low; i <= up; i ++) hr2->SetValue (i,hr->Value(i));
119       return;
120     }
121     DeclareAndCast(Interface_HArray1OfHAsciiString,hs,theany);
122     if (!hs.IsNull()) {
123       low = hs->Lower();  up = hs->Upper();
124       Handle(Interface_HArray1OfHAsciiString) hs2 = new Interface_HArray1OfHAsciiString (low,up);
125       for (i = low; i <= up; i ++) hs2->SetValue (i,new TCollection_HAsciiString(hs->Value(i)));
126       return;
127     }
128     DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
129     if (!ht.IsNull()) {
130       low = ht->Lower();  up = ht->Upper();
131       Handle(TColStd_HArray1OfTransient) ht2 = new TColStd_HArray1OfTransient (low,up);
132 //  faudrait reprendre les cas SelectMember ...
133       for (i = low; i <= up; i ++) ht2->SetValue (i,ht->Value(i));
134       return;
135     }
136   }
137 //    Reste la liste 2 ...
138 //  if ((thekind & KindArity) == KindList2) {
139 //    DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
140 //  }
141 }
142
143
144     void  StepData_Field::Clear (const Standard_Integer kind)
145 {
146   thekind = kind;
147   theint = 0; thereal = 0.;  theany.Nullify();
148 }
149
150     void  StepData_Field::SetDerived ()
151       {  Clear(KindDerived);  }
152
153     void  StepData_Field::SetInt (const Standard_Integer val)
154 {
155   if (thekind == KindSelect) {
156     DeclareAndCast(StepData_SelectMember,sm,theany);
157     if (!sm.IsNull())  {  sm->SetInteger(val);  return;  }
158   }
159   if (thekind == KindInteger || thekind == KindBoolean ||
160       thekind == KindLogical || thekind == KindEnum)  theint = val;
161 //  else ?
162 }
163
164     void  StepData_Field::SetInteger (const Standard_Integer val)
165 {
166   if (thekind == KindSelect) {
167     DeclareAndCast(StepData_SelectMember,sm,theany);
168     if (!sm.IsNull())  {  sm->SetInteger(val);  return;  }
169   }
170   Clear(KindInteger);
171   theint = val;
172 }
173
174     void  StepData_Field::SetBoolean (const Standard_Boolean val)
175 {
176   if (thekind == KindSelect) {
177     DeclareAndCast(StepData_SelectMember,sm,theany);
178     if (!sm.IsNull())  {  sm->SetBoolean(val);  return;  }
179   }
180   Clear(KindBoolean);
181   theint = (val ? 1 : 0);
182 }
183
184     void  StepData_Field::SetLogical (const StepData_Logical val)
185 {
186   if (thekind == KindSelect) {
187     DeclareAndCast(StepData_SelectMember,sm,theany);
188     if (!sm.IsNull())  {  sm->SetLogical(val);  return;  }
189   }
190   Clear(KindLogical);
191   if (val == StepData_LFalse)   theint = 0;
192   if (val == StepData_LTrue)    theint = 1;
193   if (val == StepData_LUnknown) theint = 2;
194 }
195
196     void  StepData_Field::SetReal (const Standard_Real val)
197 {
198   if (thekind == KindSelect) {
199     DeclareAndCast(StepData_SelectMember,sm,theany);
200     if (!sm.IsNull())  {  sm->SetReal(val);  return;  }
201   }
202   Clear(KindReal);
203   thereal = val;
204 }
205
206     void  StepData_Field::SetString (const Standard_CString val)
207 {
208   if (thekind == KindSelect) {
209     DeclareAndCast(StepData_SelectMember,sm,theany);
210     if (!sm.IsNull())  {  sm->SetString (val);  return;  }
211   }
212   if (thekind != KindEnum) Clear(KindString);
213   theany = new TCollection_HAsciiString(val);
214 }
215
216     void  StepData_Field::SetEnum
217   (const Standard_Integer val, const Standard_CString text)
218 {
219   Clear(KindEnum);
220   SetInt(val);
221   if (text && text[0] != '\0') SetString(text);
222 }
223
224     void  StepData_Field::SetSelectMember
225   (const Handle(StepData_SelectMember)& val)
226 {
227   if (val.IsNull()) return;
228   Clear (KindSelect);
229   theany = val;
230 }
231
232     void  StepData_Field::SetEntity (const Handle(Standard_Transient)& val)
233       {  Clear(KindEntity);  theany = val;  }
234
235     void  StepData_Field::SetEntity ()
236       {  Handle(Standard_Transient) nulent;  SetEntity(nulent);  }
237
238     void  StepData_Field::SetList
239   (const Standard_Integer size, const Standard_Integer first)
240 {
241 //  ATTENTION, on ne traite pas l agrandissement ...
242
243   theint = size;  thereal = 0.0;  theany.Nullify();  // ?? agrandissement ??
244   switch (thekind) {
245   case KindInteger :
246   case KindBoolean :
247   case KindLogical : theany = new TColStd_HArray1OfInteger(first,first+size-1);
248                      break;
249   case KindReal    : theany = new TColStd_HArray1OfReal (first,first+size-1);
250                      break;
251   case KindEnum    :
252   case KindString  : theany = new Interface_HArray1OfHAsciiString (first,first+size-1);
253                      break;
254 //  default : en particulier si "non specifie" (any)
255   default          : theany = new TColStd_HArray1OfTransient(first,first+size-1);
256   }
257   if (thekind == 0) thekind = KindAny;
258   thekind |= KindList;
259 }
260
261     void  StepData_Field::SetList2
262   (const Standard_Integer siz1, const Standard_Integer siz2,
263    const Standard_Integer f1,   const Standard_Integer f2)
264 {
265 //  ATTENTION, on ne traite pas l agrandissement ...
266
267   theint = siz1;  thereal = Standard_Real(siz2);  theany.Nullify();
268   Standard_Integer kind = thekind;
269   if (thekind == KindSelect) {
270     DeclareAndCast(StepData_SelectMember,sm,theany);
271     if (!sm.IsNull())  kind = sm->Kind();
272   }
273   switch (kind) {
274   case KindInteger :
275   case KindBoolean :
276   case KindLogical : theany = new TColStd_HArray2OfInteger(f1,f1+siz1-1,f2,f2+siz2-1);
277                      break;
278   case KindReal    : theany = new TColStd_HArray2OfReal (f1,f1+siz1-1,f2,f2+siz2-1);
279                      break;
280   case KindEnum    :
281   case KindString  : theany = new TColStd_HArray2OfTransient (f1,f1+siz1-1,f2,f2+siz2-1);
282                      break;
283 //  default : en particulier si "non specifie" (any)
284   default          : theany = new TColStd_HArray2OfTransient(f1,f1+siz1-1,f2,f2+siz2-1);
285   }
286   if (thekind == 0) thekind = KindAny;
287   thekind |= KindList2;
288 }
289
290
291     void  StepData_Field::Set (const Handle(Standard_Transient)& val)
292 {
293   Standard_Integer kind = thekind;
294   Clear();  theany = val;
295   if (val.IsNull())  return;
296   if (val->IsKind(STANDARD_TYPE(TCollection_HAsciiString)))
297     {  thekind = KindString;  return;  }
298   DeclareAndCast(StepData_SelectMember,sm,val);
299   if (!sm.IsNull())  {  thekind = KindSelect;  return;  }
300   DeclareAndCast(TColStd_HArray1OfInteger,hi,val);
301   if (!hi.IsNull())
302     {  if (kind == 0) kind = KindInteger;
303        thekind = kind        | KindList;  theint = hi->Length();  return;  }
304   DeclareAndCast(TColStd_HArray1OfReal,hr,val);
305   if (!hr.IsNull())
306     {  thekind = KindReal    | KindList;  theint = hr->Length();  return;  }
307   DeclareAndCast(Interface_HArray1OfHAsciiString,hs,val);
308   if (!hs.IsNull())
309     {  thekind = KindString  | KindList;  theint = hs->Length();  return;  }
310   DeclareAndCast(TColStd_HArray1OfTransient,ht,val);
311   if (!ht.IsNull())
312     {  if (kind == 0) kind = KindAny;
313        thekind = kind        | KindList;  theint = ht->Length();  return;  }
314   DeclareAndCast(TColStd_HArray2OfInteger,hi2,val);
315   if (!hi2.IsNull())
316     {  if (kind == 0) kind = KindInteger;
317        thekind = kind        | KindList2;  theint = hi2->ColLength();
318        thereal = Standard_Real(hi2->RowLength());  return;  }
319   DeclareAndCast(TColStd_HArray2OfReal,hr2,val);
320   if (!hr2.IsNull())
321     {  thekind = KindInteger | KindList2;  theint = hr2->ColLength();
322        thereal = Standard_Real(hi2->RowLength());  return;  }
323   DeclareAndCast(TColStd_HArray2OfTransient,ht2,val);
324   if (!ht2.IsNull())
325     {  if (kind == 0) kind = KindAny;
326        thekind = kind        | KindList2;  theint = ht2->ColLength();
327        thereal = Standard_Real(hi2->RowLength());  return;  }
328 }
329
330
331     void  StepData_Field::ClearItem (const Standard_Integer num)
332 {
333   DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
334   if (!ht.IsNull()) ht->ChangeValue(num).Nullify();
335   DeclareAndCast(Interface_HArray1OfHAsciiString,hs,theany);
336   if (!hs.IsNull()) hs->ChangeValue(num).Nullify();
337 }
338
339     void  StepData_Field::SetInt
340   (const Standard_Integer num, const Standard_Integer val, const Standard_Integer kind)
341 {
342   DeclareAndCast(TColStd_HArray1OfInteger,hi,theany);
343   if (!hi.IsNull())  {  hi->SetValue(num,val);  return;  }
344 //   Si deja commence sur autre chose, changer et mettre des select
345   DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
346   if (ht.IsNull()) return;  // yena erreur, ou alors OfReal
347   thekind = KindAny | KindList;
348   DeclareAndCast(StepData_SelectMember,sm,ht->Value(num));
349   if (sm.IsNull())  {  sm = new StepData_SelectInt;  ht->SetValue(num,sm);  }
350   sm->SetKind(kind);  sm->SetInt (val);
351 }
352
353     void  StepData_Field::SetInteger
354   (const Standard_Integer num, const Standard_Integer val)
355       {  SetInt (num,val,KindInteger);  }
356
357     void  StepData_Field::SetBoolean
358   (const Standard_Integer num, const Standard_Boolean val)
359       {  SetInt (num, (val ? 1 : 0),KindBoolean);  }
360
361     void  StepData_Field::SetLogical
362   (const Standard_Integer num, const StepData_Logical val)
363 {
364   if (val == StepData_LFalse)   SetInt (num, 0,KindLogical);
365   if (val == StepData_LTrue)    SetInt (num, 1,KindLogical);
366   if (val == StepData_LUnknown) SetInt (num, 2,KindLogical);
367 }
368
369     void  StepData_Field::SetEnum
370   (const Standard_Integer num, const Standard_Integer val, const Standard_CString text)
371 {
372   DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
373   if (ht.IsNull()) { SetInteger (num,val); return; }
374   DeclareAndCast(StepData_SelectMember,sm,ht->Value(num));
375   thekind = KindAny | KindList;
376   if (sm.IsNull()) {  sm = new StepData_SelectNamed;  ht->SetValue(num,sm);  }
377   sm->SetEnum (val,text);
378 }
379
380     void  StepData_Field::SetReal
381   (const Standard_Integer num, const Standard_Real val)
382 {
383   DeclareAndCast(TColStd_HArray1OfReal,hr,theany);
384   if (!hr.IsNull())  {  hr->SetValue(num,val);  return;  }
385 //   Si deja commence sur autre chose, changer et mettre des select
386   DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
387   if (ht.IsNull()) return;  // yena erreur, ou alors OfInteger
388   thekind = KindAny | KindList;
389   DeclareAndCast(StepData_SelectMember,sm,ht->Value(num));
390   if (sm.IsNull())  {  sm = new StepData_SelectReal;  ht->SetValue(num,sm);  }
391   sm->SetReal (val);
392 }
393
394
395     void  StepData_Field::SetString
396   (const Standard_Integer num, const Standard_CString val)
397 {
398   DeclareAndCast(Interface_HArray1OfHAsciiString,hs,theany);
399   if (!hs.IsNull()) { hs->SetValue (num,new TCollection_HAsciiString(val)); return; }
400 //    et si OfInteger ou OfReal ?
401   DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
402   if ( ht.IsNull()) return;
403   thekind = KindAny | KindList;
404   ht->SetValue (num,new TCollection_HAsciiString(val));
405 }
406
407
408     void  StepData_Field::SetEntity
409   (const Standard_Integer num, const Handle(Standard_Transient)& val)
410 {
411   DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
412   if (!ht.IsNull()) { ht->SetValue (num,val); return; }
413   DeclareAndCast(TColStd_HArray1OfInteger,hi,theany);
414   if (!hi.IsNull()) {
415     Standard_Integer low = hi->Lower(), up = hi->Upper();
416     Handle(TColStd_HArray1OfTransient) ht = new TColStd_HArray1OfTransient(low,up);
417     Handle(StepData_SelectMember) sm;
418     Standard_Integer kind = Kind();
419     for (Standard_Integer i = low; i <= up; i ++) {
420       if (i == num) ht->SetValue(i,val);
421       else {
422         sm = new StepData_SelectInt;
423         sm->SetKind(kind); sm->SetInt(hi->Value(i));
424         ht->SetValue(i,sm);
425       }
426     }
427     thekind = KindAny | KindList;
428     return;
429   }
430   DeclareAndCast(TColStd_HArray1OfReal,hr,theany);
431   if (!hr.IsNull()) {
432     Standard_Integer low = hr->Lower(), up = hr->Upper();
433     Handle(TColStd_HArray1OfTransient) ht = new TColStd_HArray1OfTransient(low,up);
434     Handle(StepData_SelectMember) sm;
435     for (Standard_Integer i = low; i <= up; i ++) {
436       if (i == num) ht->SetValue(i,val);
437       else {
438         sm = new StepData_SelectReal;
439         sm->SetReal(hr->Value(i));
440         ht->SetValue(i,sm);
441       }
442     }
443     thekind = KindAny | KindList;
444     return;
445   }
446   DeclareAndCast(Interface_HArray1OfHAsciiString,hs,theany);
447   if (!hs.IsNull()) {
448     Standard_Integer low = hs->Lower(), up = hs->Upper();
449     Handle(TColStd_HArray1OfTransient) ht = new TColStd_HArray1OfTransient(low,up);
450     for (Standard_Integer i = low; i <= up; i ++) {
451       if (i == num) ht->SetValue(i,val);
452       else ht->SetValue(i,hs->Value(i));
453     }
454     thekind = KindAny | KindList;
455     return;
456   }
457 }
458
459
460 //     QUERIES
461
462     Standard_Boolean  StepData_Field::IsSet
463   (const Standard_Integer n1, const Standard_Integer n2) const
464 {
465   if (thekind == 0) return Standard_False;
466   if (thekind == KindSelect) {
467     DeclareAndCast(StepData_SelectMember,sm,theany);
468     if (sm.IsNull()) return Standard_False;
469     return (sm->Kind() != 0);
470   }
471   if ((thekind & KindArity) == KindList) {
472     DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
473     if (!ht.IsNull()) return (!ht->Value(n1).IsNull());
474     DeclareAndCast(Interface_HArray1OfHAsciiString,hs,theany);
475     if (!hs.IsNull()) return (!hs->Value(n1).IsNull());
476   }
477   if ((thekind & KindArity) == KindList2) {
478     DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
479     if (!ht.IsNull()) return (!ht->Value(n1,n2).IsNull());
480   }
481   return Standard_True;
482 }
483
484
485     Standard_Integer  StepData_Field::ItemKind
486   (const Standard_Integer n1, const Standard_Integer n2) const
487 {
488   if ((thekind & KindArity) == 0) return Kind(Standard_True);
489   Standard_Integer kind = TrueKind(thekind);    // si Any, evaluer ...
490   if (kind != KindAny) return kind;
491 //  Sinon, chercher un Transient
492   Handle(Standard_Transient) item;
493   if ((thekind & KindArity) == KindList) {
494     DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
495     if (!ht.IsNull()) return kind;
496     item = ht->Value(n1);
497   } else if ((thekind & KindArity) == KindList2) {
498     DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
499     if (!ht.IsNull()) return kind;
500     item = ht->Value(n1,n2);
501   }
502   if (item.IsNull()) return 0;
503   if (item->IsKind(STANDARD_TYPE(TCollection_HAsciiString))) return KindString;
504   DeclareAndCast(StepData_SelectMember,sm,item);
505   if (sm.IsNull()) return KindEntity;
506   return sm->Kind();
507 }
508
509     Standard_Integer  StepData_Field::Kind (const Standard_Boolean type) const
510 {
511   if (!type) return thekind;
512   if (thekind == KindSelect) {
513     DeclareAndCast(StepData_SelectMember,sm,theany);
514     if (!sm.IsNull())  return TrueKind(sm->Kind());
515   }
516   return TrueKind (thekind);
517 }
518
519
520     Standard_Integer  StepData_Field::Arity () const
521       {  return (thekind & KindArity) >> ShiftArity;  }
522
523     Standard_Integer  StepData_Field::Length (const Standard_Integer index) const
524 {
525   if ((thekind & KindArity) == KindList)  return theint;
526   if ((thekind & KindArity) == KindList2) {
527     if (index == 2) return Standard_Integer (thereal);
528     else return theint;
529   }
530   return 0;
531 }
532
533     Standard_Integer  StepData_Field::Lower (const Standard_Integer index) const
534 {
535   if ((thekind & KindArity) == KindList)  {
536     DeclareAndCast(TColStd_HArray1OfInteger,hi,theany);
537     if (!hi.IsNull()) return hi->Lower();
538     DeclareAndCast(TColStd_HArray1OfReal,hr,theany);
539     if (!hr.IsNull()) return hr->Lower();
540     DeclareAndCast(Interface_HArray1OfHAsciiString,hs,theany);
541     if (!hs.IsNull()) return hs->Lower();
542     DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
543     if (!ht.IsNull()) return ht->Lower();
544   }
545   if ((thekind & KindArity) == KindList2) {
546     DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
547     if ( ht.IsNull()) return 0;
548     if (index == 1) return ht->LowerCol();
549     if (index == 2) return ht->LowerRow();
550   }
551   return 0;
552 }
553
554     Standard_Integer  StepData_Field::Int () const
555       {  return theint;  }
556
557     Standard_Integer  StepData_Field::Integer
558   (const Standard_Integer n1, const Standard_Integer n2) const
559 {
560   if ((thekind & KindArity) == 0) {
561     if (thekind == KindSelect) {
562       DeclareAndCast(StepData_SelectMember,sm,theany);
563       if (!sm.IsNull()) return sm->Int();
564     }
565     return theint;
566   }
567   if ((thekind & KindArity) == KindList) {
568     DeclareAndCast(TColStd_HArray1OfInteger,hi,theany);
569     if (!hi.IsNull()) return hi->Value(n1);
570     DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
571     if (ht.IsNull()) return 0;
572     DeclareAndCast(StepData_SelectMember,sm,ht->Value(n1));
573     if (!sm.IsNull()) return sm->Int();
574   }
575   if ((thekind & KindArity) == KindList2) {
576     DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
577     if (ht.IsNull()) return 0;
578     DeclareAndCast(StepData_SelectMember,sm,ht->Value(n1,n2));
579     if (!sm.IsNull()) return sm->Int();
580   }
581   return 0;
582 }
583
584     Standard_Boolean  StepData_Field::Boolean
585   (const Standard_Integer n1, const Standard_Integer n2) const
586       {  return (Integer(n1,n2) > 0);  }
587
588     StepData_Logical  StepData_Field::Logical
589   (const Standard_Integer n1, const Standard_Integer n2) const
590 {
591   Standard_Integer ival = Integer(n1,n2);
592   if (ival == 0) return StepData_LFalse;
593   if (ival == 1) return StepData_LTrue;
594   return StepData_LUnknown;
595 }
596
597     Standard_Real     StepData_Field::Real
598   (const Standard_Integer n1, const Standard_Integer n2) const
599 {
600   if ((thekind & KindArity) == 0) {
601     if (thekind == KindSelect) {
602       DeclareAndCast(StepData_SelectMember,sm,theany);
603       if (!sm.IsNull()) return sm->Real();
604     }
605     return thereal;
606   }
607   if ((thekind & KindArity) == KindList) {
608     DeclareAndCast(TColStd_HArray1OfReal,hr,theany);
609     if (!hr.IsNull()) return hr->Value(n1);
610     DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
611     if (ht.IsNull()) return 0;
612     DeclareAndCast(StepData_SelectMember,sm,ht->Value(n1));
613     if (!sm.IsNull()) return sm->Real();
614   }
615   if ((thekind & KindArity) == KindList2) {
616     DeclareAndCast(TColStd_HArray2OfReal,hr,theany);
617     if (!hr.IsNull()) return hr->Value(n1,n2);
618     DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
619     if (ht.IsNull()) return 0;
620     DeclareAndCast(StepData_SelectMember,sm,ht->Value(n1,n2));
621     if (!sm.IsNull()) return sm->Int();
622   }
623   return 0.0;
624 }
625
626     Standard_CString  StepData_Field::String
627   (const Standard_Integer n1, const Standard_Integer n2) const
628 {
629   if (thekind == KindString || thekind == KindEnum) {
630     DeclareAndCast(TCollection_HAsciiString,str,theany);
631     if (!str.IsNull()) return str->ToCString();
632     else return "";
633   }
634   if (thekind == KindSelect) {
635     DeclareAndCast(StepData_SelectMember,sm,theany);
636     if (!sm.IsNull()) return sm->String();
637   }
638   if ((thekind & KindArity) == KindList) {
639     DeclareAndCast(Interface_HArray1OfHAsciiString,hs,theany);
640     if (!hs.IsNull()) {
641       if (hs->Value(n1).IsNull()) return "";
642       else return hs->Value(n1)->ToCString();
643     }
644     DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
645     if (ht.IsNull()) return "";
646     DeclareAndCast(TCollection_HAsciiString,str,ht->Value(n1));
647     if (!str.IsNull()) return str->ToCString();
648     DeclareAndCast(StepData_SelectMember,sm,ht->Value(n1));
649     if (!sm.IsNull()) return sm->String();
650   }
651   if ((thekind & KindArity) == KindList2) {
652     DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
653     if (ht.IsNull()) return "";
654     DeclareAndCast(TCollection_HAsciiString,str,ht->Value(n1,n2));
655     if (!str.IsNull()) return str->ToCString();
656     DeclareAndCast(StepData_SelectMember,sm,ht->Value(n1,n2));
657     if (!sm.IsNull()) return sm->String();
658   }
659   return "";
660 }
661
662
663     Standard_Integer  StepData_Field::Enum
664   (const Standard_Integer n1, const Standard_Integer n2) const
665       {  return Integer(n1,n2);  }
666
667     Standard_CString  StepData_Field::EnumText
668   (const Standard_Integer n1, const Standard_Integer n2) const
669       {  return String (n1,n2);  }
670
671     Handle(Standard_Transient)  StepData_Field::Entity
672   (const Standard_Integer n1, const Standard_Integer n2) const
673 {
674   Handle(Standard_Transient) nulval;  // null handle
675   if ((thekind & KindArity) == 0) {
676     if (thekind == KindEntity) return theany;
677     return nulval;
678   }
679   if ((thekind & KindArity) == KindList) {
680     DeclareAndCast(TColStd_HArray1OfTransient,ht,theany);
681     if (ht.IsNull()) return nulval;
682     nulval = ht->Value(n1);
683     if (nulval.IsNull()) return nulval;
684     if (nulval->IsKind(STANDARD_TYPE(StepData_SelectMember)) ||
685         nulval->IsKind(STANDARD_TYPE(TCollection_HAsciiString)) )
686       nulval.Nullify();
687     return nulval;
688   }
689   if ((thekind & KindArity) == KindList2) {
690     DeclareAndCast(TColStd_HArray2OfTransient,ht,theany);
691     if (ht.IsNull()) return nulval;
692     nulval = ht->Value(n1,n2);
693     if (nulval.IsNull()) return nulval;
694     if (nulval->IsKind(STANDARD_TYPE(StepData_SelectMember))
695         || nulval->IsKind(STANDARD_TYPE(TCollection_HAsciiString)) )
696       nulval.Nullify();
697     return nulval;
698   }
699   return nulval;
700 }
701
702     Handle(Standard_Transient)  StepData_Field::Transient () const
703       {  return theany;  }