0023286: Standard_Mutex behavior depends on platform
[occt.git] / src / RWStepBasic / RWStepBasic_RWSiUnitAndAreaUnit.cxx
CommitLineData
b311480e 1// Created on: 1999-10-11
2// Created by: data exchange team
3// Copyright (c) 1999-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22
23#include <RWStepBasic_RWSiUnitAndAreaUnit.ixx>
24#include <StepBasic_SiUnit.hxx>
25#include <RWStepBasic_RWSiUnit.hxx>
26#include <StepBasic_DimensionalExponents.hxx>
27
28
29RWStepBasic_RWSiUnitAndAreaUnit::RWStepBasic_RWSiUnitAndAreaUnit ()
30{
31}
32
33void RWStepBasic_RWSiUnitAndAreaUnit::ReadStep(const Handle(StepData_StepReaderData)& data,
34 const Standard_Integer num0,
35 Handle(Interface_Check)& ach,
36 const Handle(StepBasic_SiUnitAndAreaUnit)& ent) const
37{
38 Standard_Integer num = 0;
39 data->NamedForComplex("AREA_UNIT",num0,num,ach);
40 if (!data->CheckNbParams(num,0,ach,"area_unit")) return;
41
42 data->NamedForComplex("NAMED_UNIT NMDUNT",num0,num,ach);
43 if (!data->CheckNbParams(num,1,ach,"named_unit")) return;
44 Handle(StepBasic_DimensionalExponents) aDimensions;
45 data->ReadEntity(num, 1,"dimensions", ach, STANDARD_TYPE(StepBasic_DimensionalExponents), aDimensions);
46
47 data->NamedForComplex("SI_UNIT SUNT",num0,num,ach);
48 if (!data->CheckNbParams(num,2,ach,"si_unit")) return;
49
50 RWStepBasic_RWSiUnit reader;
51 StepBasic_SiPrefix aPrefix;
52 Standard_Boolean hasAprefix = Standard_False;
53 if (data->IsParamDefined(num,1)) {
54 if (data->ParamType(num,1) == Interface_ParamEnum) {
55 Standard_CString text = data->ParamCValue(num,1);
56 hasAprefix = reader.DecodePrefix(aPrefix,text);
57 if(!hasAprefix)
58 ach->AddFail("Enumeration si_prefix has not an allowed value");
59 }
60 else ach->AddFail("Parameter #2 (prefix) is not an enumeration");
61 }
62
63 StepBasic_SiUnitName aName;
64 if (data->ParamType(num,2) == Interface_ParamEnum) {
65 Standard_CString text = data->ParamCValue(num,2);
66 if(!reader.DecodeName(aName,text))
67 ach->AddFail("Enumeration si_unit_name has not an allowed value");
68 }
69 else ach->AddFail("Parameter #3 (name) is not an enumeration");
70
71 ent->Init(hasAprefix,aPrefix,aName);
72 ent->SetDimensions(aDimensions);
73}
74
75void RWStepBasic_RWSiUnitAndAreaUnit::WriteStep(StepData_StepWriter& SW,
76 const Handle(StepBasic_SiUnitAndAreaUnit)& ent) const
77{
78 SW.StartEntity("AREA_UNIT");
79 SW.StartEntity("NAMED_UNIT");
80 SW.Send(ent->Dimensions());
81 SW.StartEntity("SI_UNIT");
82
83 RWStepBasic_RWSiUnit writer;
84 Standard_Boolean hasAprefix = ent->HasPrefix();
85 if (hasAprefix)
86 SW.SendEnum(writer.EncodePrefix(ent->Prefix()));
87 else
88 SW.SendUndef();
89
90 SW.SendEnum(writer.EncodeName(ent->Name()));
91}
92