1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <Interface_Check.hxx>
16 #include <RWStepBasic_RWCoordinatedUniversalTimeOffset.hxx>
17 #include <StepBasic_AheadOrBehind.hxx>
18 #include <StepBasic_CoordinatedUniversalTimeOffset.hxx>
19 #include <StepData_StepReaderData.hxx>
20 #include <StepData_StepWriter.hxx>
21 #include <TCollection_AsciiString.hxx>
23 // --- Enum : AheadOrBehind ---
24 static TCollection_AsciiString aobAhead(".AHEAD.");
25 static TCollection_AsciiString aobExact(".EXACT.");
26 static TCollection_AsciiString aobBehind(".BEHIND.");
28 RWStepBasic_RWCoordinatedUniversalTimeOffset::RWStepBasic_RWCoordinatedUniversalTimeOffset () {}
30 void RWStepBasic_RWCoordinatedUniversalTimeOffset::ReadStep
31 (const Handle(StepData_StepReaderData)& data,
32 const Standard_Integer num,
33 Handle(Interface_Check)& ach,
34 const Handle(StepBasic_CoordinatedUniversalTimeOffset)& ent) const
38 // --- Number of Parameter Control ---
40 if (!data->CheckNbParams(num,3,ach,"coordinated_universal_time_offset")) return;
42 // --- own field : hourOffset ---
44 Standard_Integer aHourOffset;
45 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
46 data->ReadInteger (num,1,"hour_offset",ach,aHourOffset);
48 // --- own field : minuteOffset ---
50 Standard_Integer aMinuteOffset;
51 Standard_Boolean hasAminuteOffset = Standard_True;
52 if (data->IsParamDefined(num,2)) {
53 //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
54 data->ReadInteger (num,2,"minute_offset",ach,aMinuteOffset);
57 hasAminuteOffset = Standard_False;
61 // --- own field : sense ---
63 StepBasic_AheadOrBehind aSense = StepBasic_aobAhead;
64 if (data->ParamType(num,3) == Interface_ParamEnum) {
65 Standard_CString text = data->ParamCValue(num,3);
66 if (aobAhead.IsEqual(text)) aSense = StepBasic_aobAhead;
67 else if (aobExact.IsEqual(text)) aSense = StepBasic_aobExact;
68 else if (aobBehind.IsEqual(text)) aSense = StepBasic_aobBehind;
69 else ach->AddFail("Enumeration ahead_or_behind has not an allowed value");
71 else ach->AddFail("Parameter #3 (sense) is not an enumeration");
73 //--- Initialisation of the read entity ---
76 ent->Init(aHourOffset, hasAminuteOffset, aMinuteOffset, aSense);
80 void RWStepBasic_RWCoordinatedUniversalTimeOffset::WriteStep
81 (StepData_StepWriter& SW,
82 const Handle(StepBasic_CoordinatedUniversalTimeOffset)& ent) const
85 // --- own field : hourOffset ---
87 SW.Send(ent->HourOffset());
89 // --- own field : minuteOffset ---
91 Standard_Boolean hasAminuteOffset = ent->HasMinuteOffset();
92 if (hasAminuteOffset) {
93 SW.Send(ent->MinuteOffset());
99 // --- own field : sense ---
101 switch(ent->Sense()) {
102 case StepBasic_aobAhead : SW.SendEnum (aobAhead); break;
103 case StepBasic_aobExact : SW.SendEnum (aobExact); break;
104 case StepBasic_aobBehind : SW.SendEnum (aobBehind); break;