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 <HeaderSection_FileName.hxx>
16 #include <Interface_Check.hxx>
17 #include <Interface_HArray1OfHAsciiString.hxx>
18 #include <RWHeaderSection_RWFileName.hxx>
19 #include <StepData_StepReaderData.hxx>
20 #include <StepData_StepWriter.hxx>
22 RWHeaderSection_RWFileName::RWHeaderSection_RWFileName () {}
24 void RWHeaderSection_RWFileName::ReadStep
25 (const Handle(StepData_StepReaderData)& data,
26 const Standard_Integer num,
27 Handle(Interface_Check)& ach,
28 const Handle(HeaderSection_FileName)& ent) const
32 // --- Number of Parameter Control ---
34 if (!data->CheckNbParams(num,7,ach,"file_name has not 7 parameter(s)")) return;
36 // --- own field : name ---
38 Handle(TCollection_HAsciiString) aName;
39 data->ReadString (num,1,"name",ach,aName);
41 // --- own field : timeStamp ---
43 Handle(TCollection_HAsciiString) aTimeStamp;
44 data->ReadString (num,2,"time_stamp",ach,aTimeStamp);
46 // --- own field : author ---
48 Handle(Interface_HArray1OfHAsciiString) aAuthor;
49 Handle(TCollection_HAsciiString) aAuthorItem;
50 Standard_Integer nsub3;
51 nsub3 = data->SubListNumber(num, 3, Standard_False);
53 Standard_Integer nb3 = data->NbParams(nsub3);
54 aAuthor = new Interface_HArray1OfHAsciiString (1, nb3);
55 for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) {
56 Standard_Boolean stat3 = data->ReadString
57 (nsub3,i3,"author",ach,aAuthorItem);
58 if (stat3) aAuthor->SetValue(i3,aAuthorItem);
62 ach->AddFail("Parameter #3 (author) is not a LIST");
65 // --- own field : organization ---
67 Handle(Interface_HArray1OfHAsciiString) aOrganization;
68 Handle(TCollection_HAsciiString) aOrganizationItem;
69 Standard_Integer nsub4;
70 nsub4 = data->SubListNumber(num, 4, Standard_False);
72 Standard_Integer nb4 = data->NbParams(nsub4);
73 aOrganization = new Interface_HArray1OfHAsciiString (1, nb4);
74 for (Standard_Integer i4 = 1; i4 <= nb4; i4 ++) {
75 Standard_Boolean stat4 = data->ReadString
76 (nsub4,i4,"organization",ach,aOrganizationItem);
77 if (stat4) aOrganization->SetValue(i4,aOrganizationItem);
81 ach->AddFail("Parameter #4 (organization) is not a LIST");
84 // --- own field : preprocessorVersion ---
86 Handle(TCollection_HAsciiString) aPreprocessorVersion;
87 data->ReadString (num,5,"preprocessor_version",ach,aPreprocessorVersion);
89 // --- own field : originatingSystem ---
91 Handle(TCollection_HAsciiString) aOriginatingSystem;
92 data->ReadString (num,6,"originating_system",ach,aOriginatingSystem);
94 // --- own field : authorisation ---
96 Handle(TCollection_HAsciiString) aAuthorisation;
97 data->ReadString (num,7,"authorisation",ach,aAuthorisation);
99 //--- Initialisation of the read entity ---
102 if (!ach->HasFailed()) ent->Init(aName, aTimeStamp, aAuthor, aOrganization, aPreprocessorVersion, aOriginatingSystem, aAuthorisation);
106 void RWHeaderSection_RWFileName::WriteStep
107 (StepData_StepWriter& SW,
108 const Handle(HeaderSection_FileName)& ent) const
111 // --- own field : name ---
113 SW.Send(ent->Name());
115 // --- own field : timeStamp ---
117 SW.Send(ent->TimeStamp());
119 // --- own field : author ---
122 for (Standard_Integer i3 = 1; i3 <= ent->NbAuthor(); i3 ++) {
123 SW.Send(ent->AuthorValue(i3));
127 // --- own field : organization ---
130 for (Standard_Integer i4 = 1; i4 <= ent->NbOrganization(); i4 ++) {
131 SW.Send(ent->OrganizationValue(i4));
135 // --- own field : preprocessorVersion ---
137 SW.Send(ent->PreprocessorVersion());
139 // --- own field : originatingSystem ---
141 SW.Send(ent->OriginatingSystem());
143 // --- own field : authorisation ---
145 SW.Send(ent->Authorisation());