0024057: Eliminate compiler warning C4100 in MSVC++ with warning level 4
[occt.git] / src / StepData / StepData_DescrReadWrite.cxx
CommitLineData
b311480e 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
7fd59977 18#include <StepData_DescrReadWrite.ixx>
19#include <StepData_EDescr.hxx>
20#include <StepData_ECDescr.hxx>
21#include <StepData_ESDescr.hxx>
22#include <StepData_Simple.hxx>
23#include <StepData_Plex.hxx>
24#include <StepData_FieldListN.hxx>
25#include <TColStd_HSequenceOfAsciiString.hxx>
26#include <Interface_Macros.hxx>
27
28static TCollection_AsciiString nocp("?");
29
30
31 StepData_DescrReadWrite::StepData_DescrReadWrite
32 (const Handle(StepData_Protocol)& proto)
33 : theproto (proto) { }
34
35 Standard_Integer StepData_DescrReadWrite::CaseStep
36 (const TCollection_AsciiString& atype) const
37{
38 Handle(StepData_ESDescr) descr = theproto->ESDescr (atype.ToCString(),Standard_False);
39 if (descr.IsNull()) return 0;
40 return theproto->DescrNumber (descr);
41}
42
43 Standard_Integer StepData_DescrReadWrite::CaseStep
44 (const TColStd_SequenceOfAsciiString& types) const
45{
46 Handle(StepData_ECDescr) descr = theproto->ECDescr (types,Standard_False);
47 if (descr.IsNull()) return 0;
48 return theproto->DescrNumber (descr);
49}
50
51
52 Standard_Boolean StepData_DescrReadWrite::IsComplex
53 (const Standard_Integer CN) const
54{
55 Handle(StepData_EDescr) descr = theproto->Descr (CN);
56 if (descr.IsNull()) return Standard_False;
57 return descr->IsComplex();
58}
59
60 const TCollection_AsciiString& StepData_DescrReadWrite::StepType
61 (const Standard_Integer CN) const
62{
63 Handle(StepData_ESDescr) descr = Handle(StepData_ESDescr)::DownCast
64 (theproto->Descr (CN));
65 if (descr.IsNull()) return nocp;
66 return descr->StepType();
67}
68
69 Standard_Boolean StepData_DescrReadWrite::ComplexType
70 (const Standard_Integer CN, TColStd_SequenceOfAsciiString& types) const
71{
72 Handle(StepData_ECDescr) descr = Handle(StepData_ECDescr)::DownCast
73 (theproto->Descr (CN));
74 if (descr.IsNull()) return Standard_False;
75 Handle(TColStd_HSequenceOfAsciiString) list = descr->TypeList();
76 if (list.IsNull()) return Standard_False;
77 Standard_Integer i, nb = list->Length();
78 for (i = 1; i <= nb; i ++) types.Append (list->Value(i));
79 return Standard_True;
80}
81
82
83void StepData_DescrReadWrite::ReadStep(const Standard_Integer CN,
84 const Handle(StepData_StepReaderData)& data,
85 const Standard_Integer num,
86 Handle(Interface_Check)& ach,
87 const Handle(Standard_Transient)&ent) const
88{
89 if (CN == 0) return;
90 DeclareAndCast(StepData_Simple,sent,ent);
91 if (!sent.IsNull()) {
92 Handle(StepData_ESDescr) sdescr = sent->ESDescr();
93 StepData_FieldListN& fl = sent->CFields();
94 data->ReadList (num,ach,sdescr,fl);
95 return;
96 }
97
98 DeclareAndCast(StepData_Plex,cent,ent);
99 Standard_Integer i, nb=0;
100 if (!cent.IsNull()) nb = cent->NbMembers();
101 Standard_Integer n0 = num;
102 for (i = 1; i <= nb; i ++) {
103 Handle(StepData_Simple) si = cent->Member(i);
104 Handle(StepData_ESDescr) sdescr = si->ESDescr();
105 StepData_FieldListN& fl = si->CFields();
106 data->ReadList (n0,ach,sdescr,fl);
107 if (i < nb) n0 = data->NextForComplex(n0);
108 }
109}
110
111
112 void StepData_DescrReadWrite::WriteStep
113 (const Standard_Integer CN,
114 StepData_StepWriter& SW,
115 const Handle(Standard_Transient)&ent) const
116{
117 if (CN == 0) return;
118
119 DeclareAndCast(StepData_Simple,sent,ent);
120 if (!sent.IsNull()) {
121 Handle(StepData_ESDescr) sdescr = sent->ESDescr();
122 const StepData_FieldListN& fl = sent->Fields();
123 SW.SendList (fl,sdescr);
124 return;
125 }
126
127 DeclareAndCast(StepData_Plex,cent,ent);
128 Standard_Integer i, nb=0;
129 if (!cent.IsNull()) nb = cent->NbMembers();
130 for (i = 1; i <= nb; i ++) {
131 Handle(StepData_Simple) si = cent->Member(i);
132 Handle(StepData_ESDescr) sdescr = si->ESDescr();
133 const StepData_FieldListN& fl = si->Fields();
134 SW.StartEntity (sdescr->TypeName());
135 SW.SendList (fl,sdescr);
136 }
137}