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