0024624: Lost word in license statement in source files
[occt.git] / src / RWStepBasic / RWStepBasic_RWSiUnitAndTimeUnit.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 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
973c2be1 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.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14#include <RWStepBasic_RWSiUnitAndTimeUnit.ixx>
15#include <StepBasic_SiUnit.hxx>
16#include <StepBasic_TimeUnit.hxx>
17#include <StepBasic_DimensionalExponents.hxx>
18#include <StepBasic_SiPrefix.hxx>
19#include <StepBasic_SiUnitName.hxx>
20#include <RWStepBasic_RWSiUnit.hxx>
21
22
23//=======================================================================
24//function : RWStepBasic_RWSiUnitAndTimeUnit
25//purpose :
26//=======================================================================
27
28RWStepBasic_RWSiUnitAndTimeUnit::RWStepBasic_RWSiUnitAndTimeUnit ()
29{
30}
31
32
33//=======================================================================
34//function : ReadStep
35//purpose :
36//=======================================================================
37
38void RWStepBasic_RWSiUnitAndTimeUnit::ReadStep (const Handle(StepData_StepReaderData)& data,
39 const Standard_Integer num0,
40 Handle(Interface_Check)& ach,
41 const Handle(StepBasic_SiUnitAndTimeUnit)& ent) const
42{
43 Standard_Integer num = num0;
44
45 // --- Instance of common supertype NamedUnit ---
46 if (!data->CheckNbParams(num,1,ach,"named_unit")) return;
47
48 // --- field : dimensions ---
49 // --- this field is redefined ---
50 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =`
51 data->CheckDerived(num,1,"dimensions",ach,Standard_False);
52
53 // --- Instance of plex componant SiUnit ---
54 num = data->NextForComplex(num);
55 if (!data->CheckNbParams(num,2,ach,"si_unit")) return;
56
57 // --- field : prefix ---
58 RWStepBasic_RWSiUnit reader;
a8195d65 59 StepBasic_SiPrefix aPrefix = StepBasic_spExa;
7fd59977 60 Standard_Boolean hasAprefix = Standard_False;
61 if (data->IsParamDefined(num,1)) {
62 if (data->ParamType(num,1) == Interface_ParamEnum) {
63 Standard_CString text = data->ParamCValue(num,1);
64 hasAprefix = reader.DecodePrefix(aPrefix,text);
4e76d93b 65 if(!hasAprefix){
66 ach->AddFail("Enumeration si_prefix has not an allowed value");
67 return;
68 }
69 }
70 else{
71 ach->AddFail("Parameter #1 (prefix) is not an enumeration");
72 return;
7fd59977 73 }
7fd59977 74 }
75
76 // --- field : name ---
77 StepBasic_SiUnitName aName;
78 if (data->ParamType(num,2) == Interface_ParamEnum) {
79 Standard_CString text = data->ParamCValue(num,2);
4e76d93b 80 if(!reader.DecodeName(aName,text)){
7fd59977 81 ach->AddFail("Enumeration si_unit_name has not an allowed value");
4e76d93b 82 return;
83 }
84 }
85 else{
86 ach->AddFail("Parameter #2 (name) is not an enumeration");
87 return;
7fd59977 88 }
7fd59977 89
90 // --- Instance of plex componant TimeUnit ---
91 num = data->NextForComplex(num);
92 if (!data->CheckNbParams(num,0,ach,"time_unit")) return;
93
94 //--- Initialisation of the red entity ---
95 ent->Init(hasAprefix,aPrefix,aName);
96}
97
98
99//=======================================================================
100//function : WriteStep
101//purpose :
102//=======================================================================
103
104void RWStepBasic_RWSiUnitAndTimeUnit::WriteStep (StepData_StepWriter& SW,
105 const Handle(StepBasic_SiUnitAndTimeUnit)& ent) const
106{
107
108 // --- Instance of plex componant TimeUnit ---
109 //SW.StartEntity("TIME_UNIT");
110
111 // --- Instance of common supertype NamedUnit ---
112 SW.StartEntity("NAMED_UNIT");
113
114 // --- field : dimensions ---
115 // --- redefined field ---
116 SW.SendDerived();
117
118 // --- Instance of plex componant SiUnit ---
119 SW.StartEntity("SI_UNIT");
120
121 // --- field : prefix ---
122 RWStepBasic_RWSiUnit writer;
123 Standard_Boolean hasAprefix = ent->HasPrefix();
124 if (hasAprefix)
125 SW.SendEnum(writer.EncodePrefix(ent->Prefix()));
126 else
127 SW.SendUndef();
128
129 // --- field : name ---
130 SW.SendEnum(writer.EncodeName(ent->Name()));
131
132 // --- Instance of plex componant TimeUnit ---
133 SW.StartEntity("TIME_UNIT");
134
135}