Files
OCCT/src/RWHeaderSection/RWHeaderSection_ReadWriteModule.cxx
abv d5f74e42d6 0024624: Lost word in license statement in source files
License statement text corrected; compiler warnings caused by Bison 2.41 disabled for MSVC; a few other compiler warnings on 54-bit Windows eliminated by appropriate type cast
Wrong license statements corrected in several files.
Copyright and license statements added in XSD and GLSL files.
Copyright year updated in some files.
Obsolete documentation files removed from DrawResources.
2014-02-20 16:15:17 +04:00

201 lines
5.6 KiB
C++

// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <RWHeaderSection_ReadWriteModule.ixx>
#include <Interface_ReaderLib.hxx>
#include <StepData_WriterLib.hxx>
#include <HeaderSection_Protocol.hxx>
#include <Interface_Macros.hxx>
#include <Interface_ParamType.hxx>
#include <HeaderSection_FileName.hxx>
#include <HeaderSection_FileDescription.hxx>
#include <HeaderSection_FileSchema.hxx>
#include <StepData_UndefinedEntity.hxx>
#include <RWHeaderSection_RWFileName.hxx>
#include <RWHeaderSection_RWFileDescription.hxx>
#include <RWHeaderSection_RWFileSchema.hxx>
// -- General Declarations (Recognize, StepType) ---
static TCollection_AsciiString PasReco(""); // neutralise StartEntity de SW
static TCollection_AsciiString Reco_FileName ("FILE_NAME");
static TCollection_AsciiString Reco_FileDescription ("FILE_DESCRIPTION");
static TCollection_AsciiString Reco_FileSchema ("FILE_SCHEMA");
// -- Definition of the libraries --
RWHeaderSection_ReadWriteModule::RWHeaderSection_ReadWriteModule ()
{
Handle(HeaderSection_Protocol) protocol = new HeaderSection_Protocol;
StepData_WriterLib::SetGlobal(this,protocol);
Interface_ReaderLib::SetGlobal(this,protocol);
}
// --- Case Recognition ---
Standard_Integer RWHeaderSection_ReadWriteModule::CaseStep
(const TCollection_AsciiString& key) const
{
if (key.IsEqual(Reco_FileName)) return 1;
if (key.IsEqual(Reco_FileDescription)) return 2;
if (key.IsEqual(Reco_FileSchema)) return 3;
return 0;
}
// --- External Mapping Case Recognition ---
#ifdef DEB
Standard_Integer RWHeaderSection_ReadWriteModule::CaseStep (const TColStd_SequenceOfAsciiString& types) const
{
Standard_Integer NbComp = types.Length();
if (NbComp < 2) {
cout << "Plex Instance illegal " << endl;
}
return 0;
}
#else
Standard_Integer RWHeaderSection_ReadWriteModule::CaseStep (const TColStd_SequenceOfAsciiString&) const
{ return 0; }
#endif
// --- External Mapping Recognition ---
Standard_Boolean RWHeaderSection_ReadWriteModule::IsComplex
(const Standard_Integer /*CN*/) const
{
return Standard_False;
}
const TCollection_AsciiString& RWHeaderSection_ReadWriteModule::StepType
(const Standard_Integer CN) const
{
switch (CN) {
case 1 : return Reco_FileName;
case 2 : return Reco_FileDescription;
case 3 : return Reco_FileSchema;
default : return PasReco;
}
}
// -- Reading of a file --
void RWHeaderSection_ReadWriteModule::ReadStep
(const Standard_Integer CN,
const Handle(StepData_StepReaderData)& data,
const Standard_Integer num,
Handle(Interface_Check)& ach,
const Handle(Standard_Transient)&ent) const
{
if (CN == 0) return;
switch (CN) {
case 1 :
{
DeclareAndCast(HeaderSection_FileName, anent, ent);
RWHeaderSection_RWFileName tool;
if (anent.IsNull()) ach->AddFail("Type Mismatch on FileName");
else tool.ReadStep (data,num,ach,anent);
}
break;
case 2 :
{
DeclareAndCast(HeaderSection_FileDescription, anent, ent);
RWHeaderSection_RWFileDescription tool;
if (anent.IsNull()) ach->AddFail("Type Mismatch on FileDescription");
else tool.ReadStep (data,num,ach,anent);
}
break;
case 3 :
{
DeclareAndCast(HeaderSection_FileSchema, anent, ent);
RWHeaderSection_RWFileSchema tool;
if (anent.IsNull()) ach->AddFail("Type Mismatch on FileSchema");
else tool.ReadStep (data,num,ach,anent);
}
break;
case 4 :
{
DeclareAndCast(StepData_UndefinedEntity,und,ent);
if (und.IsNull()) ach->AddFail
("# Entity neither Recognized nor set as UndefinedEntity from StepData #");
else und->ReadRecord(data,num,ach);
}
break;
default : ach->AddFail("Type Mismatch when reading - Entity");
}
return;}
// -- Writing of a file --
void RWHeaderSection_ReadWriteModule::WriteStep
(const Standard_Integer CN,
StepData_StepWriter& SW,
const Handle(Standard_Transient)&ent) const
{
if (CN == 0) return;
switch (CN) {
case 1 :
{
DeclareAndCast(HeaderSection_FileName, anent, ent);
RWHeaderSection_RWFileName tool;
if (anent.IsNull()) return;
else tool.WriteStep (SW,anent);
}
break;
case 2 :
{
DeclareAndCast(HeaderSection_FileDescription, anent, ent);
RWHeaderSection_RWFileDescription tool;
if (anent.IsNull()) return;
else tool.WriteStep (SW,anent);
}
break;
case 3 :
{
DeclareAndCast(HeaderSection_FileSchema, anent, ent);
RWHeaderSection_RWFileSchema tool;
if (anent.IsNull()) return;
else tool.WriteStep (SW,anent);
}
break;
case 4 :
{
DeclareAndCast(StepData_UndefinedEntity,und,ent);
if (und.IsNull()) break;
// Parentheses gerees par StepWriter lui-meme
// car en recevant le type PasReco, StepWriter ne l'affiche pas,
// mais il gere les parentheses comme si de rien n etait
if (und->IsComplex()) SW.StartComplex();
und->WriteParams(SW);
if (und->IsComplex()) SW.EndComplex();
}
break;
default : return;
}
}