0029151: GCC 7.1 warnings "this statement may fall through" [-Wimplicit-fallthrough=]
[occt.git] / src / APIHeaderSection / APIHeaderSection_EditHeader.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
42cf5bc1 15#include <APIHeaderSection_EditHeader.hxx>
7fd59977 16#include <APIHeaderSection_MakeHeader.hxx>
42cf5bc1 17#include <IFSelect_EditForm.hxx>
18#include <Interface_InterfaceModel.hxx>
19#include <Interface_TypedValue.hxx>
20#include <Standard_Transient.hxx>
21#include <Standard_Type.hxx>
ec357c5c 22#include <StepData_StepModel.hxx>
42cf5bc1 23#include <TCollection_AsciiString.hxx>
24#include <TCollection_HAsciiString.hxx>
7fd59977 25
92efcf78 26IMPLEMENT_STANDARD_RTTIEXT(APIHeaderSection_EditHeader,IFSelect_Editor)
27
7fd59977 28static Standard_Boolean IsTimeStamp
29 (const Handle(TCollection_HAsciiString)& val)
30{
31 if (val.IsNull()) return Standard_False;
32 if (val->Length() != 19) return Standard_False;
33// On y va
34 char dizmois = val->Value(6);
35 char dizjour = val->Value(9);
36 char dizheur = val->Value(12);
c48e2889 37 for (Standard_Integer i = 1; i <= 19; i ++)
38 {
7fd59977 39 char uncar = val->Value(i);
40 switch (i) {
c48e2889 41 case 1 : if (uncar != '1' && uncar != '2') return Standard_False;
42 break;
7fd59977 43 case 2 :
44 case 3 :
c48e2889 45 case 4 : if (uncar < '0' || uncar > '9') return Standard_False;
46 break;
7fd59977 47 case 5 : if (uncar != '-') return Standard_False;
b1811c1d 48 Standard_FALLTHROUGH
c48e2889 49 case 6 : if (uncar != '0' && uncar != '1') return Standard_False;
50 break;
51 case 7 : if (uncar < '0' || uncar > '9') return Standard_False;
52 if (dizmois == '1' && (uncar < '0' || uncar > '2')) return Standard_False;
53 break;
7fd59977 54 case 8 : if (uncar != '-') return Standard_False;
b1811c1d 55 Standard_FALLTHROUGH
c48e2889 56 case 9 : if (uncar < '0' || uncar > '3') return Standard_False;
57 break;
7fd59977 58 case 10 : if (uncar < '0' || uncar > '9') return Standard_False;
c48e2889 59 if (dizjour == '3' && (uncar != '0' && uncar != '1')) return Standard_False;
60 break;
7fd59977 61 case 11 : if (uncar != 'T') return Standard_False;
b1811c1d 62 Standard_FALLTHROUGH
c48e2889 63 case 12 : if (uncar < '0' || uncar > '2') return Standard_False;
64 break;
7fd59977 65 case 13 : if (uncar < '0' || uncar > '9') return Standard_False;
c48e2889 66 if (dizheur == '2' && (uncar < '0' || uncar > '3')) return Standard_False;
67 break;
7fd59977 68 case 14 : if (uncar != ':') return Standard_False;
b1811c1d 69 Standard_FALLTHROUGH
c48e2889 70 case 15 : if (uncar < '0' || uncar > '5') return Standard_False;
71 break;
72 case 16 : if (uncar < '0' || uncar > '9') return Standard_False;
73 break;
7fd59977 74 case 17 : if (uncar != ':') return Standard_False;
b1811c1d 75 Standard_FALLTHROUGH
c48e2889 76 case 18 : if (uncar < '0' || uncar > '5') return Standard_False;
77 break;
78 case 19 : if (uncar < '0' || uncar > '9') return Standard_False;
79 break;
80 default :
81 break;
7fd59977 82 }
83 }
84 return Standard_True;
85}
86
87
88 APIHeaderSection_EditHeader::APIHeaderSection_EditHeader ()
89 : IFSelect_Editor (10)
90{
91// Definition
92 Handle(Interface_TypedValue) fn_name = new Interface_TypedValue("fn_name");
93 SetValue (1,fn_name,"name");
94 Handle(Interface_TypedValue) fn_time = new Interface_TypedValue("fn_time_stamp");
95 fn_time->SetSatisfies (IsTimeStamp,"IsTimeStamp");
96 SetValue (2,fn_time,"time");
97 Handle(Interface_TypedValue) fn_author = new Interface_TypedValue("fn_author");
98 SetValue (3,fn_author,"author"); // 1 seul (1er de liste)
99 Handle(Interface_TypedValue) fn_org = new Interface_TypedValue("fn_organization");
100 SetValue (4,fn_org,"org"); // 1 seul (1er de liste)
101 Handle(Interface_TypedValue) fn_preproc = new Interface_TypedValue("fn_preprocessor_version");
102 SetValue (5,fn_preproc,"preproc");
103 Handle(Interface_TypedValue) fn_orig = new Interface_TypedValue("fn_originating_system");
104 SetValue (6,fn_orig,"orig");
105 Handle(Interface_TypedValue) fn_autorize = new Interface_TypedValue("fn_authorization");
106 SetValue (7,fn_autorize,"autorize");
107
108 Handle(Interface_TypedValue) fs_schema = new Interface_TypedValue("fs_schema_identifiers");
109 SetValue (8,fs_schema,"schema"); // 1 seul (1er de liste)
110
111 Handle(Interface_TypedValue) fd_descr = new Interface_TypedValue("fd_description");
112 SetValue (9,fd_descr,"descr"); // 1 seul (1er de liste)
113
114 Handle(Interface_TypedValue) fd_level = new Interface_TypedValue("fd_implementation_level");
115 SetValue (10,fd_level,"level");
116
117}
118
119 TCollection_AsciiString APIHeaderSection_EditHeader::Label () const
120 { return TCollection_AsciiString ("Step Header"); }
121
122 Standard_Boolean APIHeaderSection_EditHeader::Recognize
35e08fe8 123 (const Handle(IFSelect_EditForm)& /*form*/) const
7fd59977 124{ return Standard_True; } // ??
125
126 Handle(TCollection_HAsciiString) APIHeaderSection_EditHeader::StringValue
35e08fe8 127 (const Handle(IFSelect_EditForm)& /*form*/, const Standard_Integer num) const
7fd59977 128{
129// Default Values
130 return TypedValue(num)->HStringValue();
131}
132
133 Standard_Boolean APIHeaderSection_EditHeader::Load
134 (const Handle(IFSelect_EditForm)& form,
35e08fe8 135 const Handle(Standard_Transient)& /*ent*/,
7fd59977 136 const Handle(Interface_InterfaceModel)& model) const
137{
138 Handle(StepData_StepModel) modl =
139 Handle(StepData_StepModel)::DownCast(model);
140 if (modl.IsNull()) return Standard_False;
141
142 APIHeaderSection_MakeHeader mkh (modl);
143
144 form->LoadValue (1 ,mkh.Name ());
145 form->LoadValue (2 ,mkh.TimeStamp ());
146 form->LoadValue (3 ,mkh.AuthorValue (1));
147 form->LoadValue (4 ,mkh.OrganizationValue (1));
148 form->LoadValue (5 ,mkh.PreprocessorVersion ());
149 form->LoadValue (6 ,mkh.OriginatingSystem ());
150 form->LoadValue (7 ,mkh.Authorisation ());
151
152 form->LoadValue (8 ,mkh.SchemaIdentifiersValue (1));
153
154 form->LoadValue (9 ,mkh.DescriptionValue (1));
155 form->LoadValue (10,mkh.ImplementationLevel ());
156
157 return Standard_True;
158}
159
160 Standard_Boolean APIHeaderSection_EditHeader::Apply
161 (const Handle(IFSelect_EditForm)& form,
35e08fe8 162 const Handle(Standard_Transient)& /*ent*/,
7fd59977 163 const Handle(Interface_InterfaceModel)& model) const
164{
165 Handle(StepData_StepModel) modl =
166 Handle(StepData_StepModel)::DownCast(model);
167 if (modl.IsNull()) return Standard_False;
168
169 APIHeaderSection_MakeHeader mkh (modl);
170
171 if (form->IsModified(1)) mkh.SetName (form->EditedValue(1));
172 if (form->IsModified(2)) mkh.SetTimeStamp (form->EditedValue(2));
173 if (form->IsModified(3)) mkh.SetAuthorValue (1,form->EditedValue(3));
174 if (form->IsModified(4)) mkh.SetOrganizationValue (1,form->EditedValue(4));
175 if (form->IsModified(5)) mkh.SetPreprocessorVersion (form->EditedValue(5));
176 if (form->IsModified(6)) mkh.SetOriginatingSystem (form->EditedValue(6));
177 if (form->IsModified(7)) mkh.SetAuthorisation (form->EditedValue(7));
178
179 if (form->IsModified(8)) mkh.SetSchemaIdentifiersValue (1,form->EditedValue(8));
180
181 if (form->IsModified(9)) mkh.SetDescriptionValue (1,form->EditedValue(9));
182 if (form->IsModified(10)) mkh.SetImplementationLevel (form->EditedValue(10));
183
184 mkh.Apply( Handle(StepData_StepModel)::DownCast(model) );
185
186 return Standard_True;
187}