0022627: Change OCCT memory management defaults
[occt.git] / src / RWStepBasic / RWStepBasic_RWSiUnitAndTimeUnit.cxx
CommitLineData
7fd59977 1#include <RWStepBasic_RWSiUnitAndTimeUnit.ixx>
2#include <StepBasic_SiUnit.hxx>
3#include <StepBasic_TimeUnit.hxx>
4#include <StepBasic_DimensionalExponents.hxx>
5#include <StepBasic_SiPrefix.hxx>
6#include <StepBasic_SiUnitName.hxx>
7#include <RWStepBasic_RWSiUnit.hxx>
8
9
10//=======================================================================
11//function : RWStepBasic_RWSiUnitAndTimeUnit
12//purpose :
13//=======================================================================
14
15RWStepBasic_RWSiUnitAndTimeUnit::RWStepBasic_RWSiUnitAndTimeUnit ()
16{
17}
18
19
20//=======================================================================
21//function : ReadStep
22//purpose :
23//=======================================================================
24
25void RWStepBasic_RWSiUnitAndTimeUnit::ReadStep (const Handle(StepData_StepReaderData)& data,
26 const Standard_Integer num0,
27 Handle(Interface_Check)& ach,
28 const Handle(StepBasic_SiUnitAndTimeUnit)& ent) const
29{
30 Standard_Integer num = num0;
31
32 // --- Instance of common supertype NamedUnit ---
33 if (!data->CheckNbParams(num,1,ach,"named_unit")) return;
34
35 // --- field : dimensions ---
36 // --- this field is redefined ---
37 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =`
38 data->CheckDerived(num,1,"dimensions",ach,Standard_False);
39
40 // --- Instance of plex componant SiUnit ---
41 num = data->NextForComplex(num);
42 if (!data->CheckNbParams(num,2,ach,"si_unit")) return;
43
44 // --- field : prefix ---
45 RWStepBasic_RWSiUnit reader;
46 StepBasic_SiPrefix aPrefix;
47 Standard_Boolean hasAprefix = Standard_False;
48 if (data->IsParamDefined(num,1)) {
49 if (data->ParamType(num,1) == Interface_ParamEnum) {
50 Standard_CString text = data->ParamCValue(num,1);
51 hasAprefix = reader.DecodePrefix(aPrefix,text);
52 if(!hasAprefix)
53 ach->AddFail("Enumeration si_prefix has not an allowed value");
54 }
55 else ach->AddFail("Parameter #1 (prefix) is not an enumeration");
56 }
57
58 // --- field : name ---
59 StepBasic_SiUnitName aName;
60 if (data->ParamType(num,2) == Interface_ParamEnum) {
61 Standard_CString text = data->ParamCValue(num,2);
62 if(!reader.DecodeName(aName,text))
63 ach->AddFail("Enumeration si_unit_name has not an allowed value");
64 }
65 else ach->AddFail("Parameter #2 (name) is not an enumeration");
66
67 // --- Instance of plex componant TimeUnit ---
68 num = data->NextForComplex(num);
69 if (!data->CheckNbParams(num,0,ach,"time_unit")) return;
70
71 //--- Initialisation of the red entity ---
72 ent->Init(hasAprefix,aPrefix,aName);
73}
74
75
76//=======================================================================
77//function : WriteStep
78//purpose :
79//=======================================================================
80
81void RWStepBasic_RWSiUnitAndTimeUnit::WriteStep (StepData_StepWriter& SW,
82 const Handle(StepBasic_SiUnitAndTimeUnit)& ent) const
83{
84
85 // --- Instance of plex componant TimeUnit ---
86 //SW.StartEntity("TIME_UNIT");
87
88 // --- Instance of common supertype NamedUnit ---
89 SW.StartEntity("NAMED_UNIT");
90
91 // --- field : dimensions ---
92 // --- redefined field ---
93 SW.SendDerived();
94
95 // --- Instance of plex componant SiUnit ---
96 SW.StartEntity("SI_UNIT");
97
98 // --- field : prefix ---
99 RWStepBasic_RWSiUnit writer;
100 Standard_Boolean hasAprefix = ent->HasPrefix();
101 if (hasAprefix)
102 SW.SendEnum(writer.EncodePrefix(ent->Prefix()));
103 else
104 SW.SendUndef();
105
106 // --- field : name ---
107 SW.SendEnum(writer.EncodeName(ent->Name()));
108
109 // --- Instance of plex componant TimeUnit ---
110 SW.StartEntity("TIME_UNIT");
111
112}