0022627: Change OCCT memory management defaults
[occt.git] / src / RWStepBasic / RWStepBasic_RWSiUnitAndAreaUnit.cxx
CommitLineData
7fd59977 1// File: RWStepBasic_RWSiUnitAndAreaUnit.cxx
2// Created: Mon Oct 11 15:37:59 1999
3// Author: data exchange team
4// <det@friendox>
5
6
7#include <RWStepBasic_RWSiUnitAndAreaUnit.ixx>
8#include <StepBasic_SiUnit.hxx>
9#include <RWStepBasic_RWSiUnit.hxx>
10#include <StepBasic_DimensionalExponents.hxx>
11
12
13RWStepBasic_RWSiUnitAndAreaUnit::RWStepBasic_RWSiUnitAndAreaUnit ()
14{
15}
16
17void RWStepBasic_RWSiUnitAndAreaUnit::ReadStep(const Handle(StepData_StepReaderData)& data,
18 const Standard_Integer num0,
19 Handle(Interface_Check)& ach,
20 const Handle(StepBasic_SiUnitAndAreaUnit)& ent) const
21{
22 Standard_Integer num = 0;
23 data->NamedForComplex("AREA_UNIT",num0,num,ach);
24 if (!data->CheckNbParams(num,0,ach,"area_unit")) return;
25
26 data->NamedForComplex("NAMED_UNIT NMDUNT",num0,num,ach);
27 if (!data->CheckNbParams(num,1,ach,"named_unit")) return;
28 Handle(StepBasic_DimensionalExponents) aDimensions;
29 data->ReadEntity(num, 1,"dimensions", ach, STANDARD_TYPE(StepBasic_DimensionalExponents), aDimensions);
30
31 data->NamedForComplex("SI_UNIT SUNT",num0,num,ach);
32 if (!data->CheckNbParams(num,2,ach,"si_unit")) return;
33
34 RWStepBasic_RWSiUnit reader;
35 StepBasic_SiPrefix aPrefix;
36 Standard_Boolean hasAprefix = Standard_False;
37 if (data->IsParamDefined(num,1)) {
38 if (data->ParamType(num,1) == Interface_ParamEnum) {
39 Standard_CString text = data->ParamCValue(num,1);
40 hasAprefix = reader.DecodePrefix(aPrefix,text);
41 if(!hasAprefix)
42 ach->AddFail("Enumeration si_prefix has not an allowed value");
43 }
44 else ach->AddFail("Parameter #2 (prefix) is not an enumeration");
45 }
46
47 StepBasic_SiUnitName aName;
48 if (data->ParamType(num,2) == Interface_ParamEnum) {
49 Standard_CString text = data->ParamCValue(num,2);
50 if(!reader.DecodeName(aName,text))
51 ach->AddFail("Enumeration si_unit_name has not an allowed value");
52 }
53 else ach->AddFail("Parameter #3 (name) is not an enumeration");
54
55 ent->Init(hasAprefix,aPrefix,aName);
56 ent->SetDimensions(aDimensions);
57}
58
59void RWStepBasic_RWSiUnitAndAreaUnit::WriteStep(StepData_StepWriter& SW,
60 const Handle(StepBasic_SiUnitAndAreaUnit)& ent) const
61{
62 SW.StartEntity("AREA_UNIT");
63 SW.StartEntity("NAMED_UNIT");
64 SW.Send(ent->Dimensions());
65 SW.StartEntity("SI_UNIT");
66
67 RWStepBasic_RWSiUnit writer;
68 Standard_Boolean hasAprefix = ent->HasPrefix();
69 if (hasAprefix)
70 SW.SendEnum(writer.EncodePrefix(ent->Prefix()));
71 else
72 SW.SendUndef();
73
74 SW.SendEnum(writer.EncodeName(ent->Name()));
75}
76