1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0031481: Data Exchange - provide parser of STEP EXPRESS schema for generation of new STEP entities

Integration of ExpToCas tool ported to modern state of OCCT:
- new package Express and toolkit TKExpress for EXPRESS data structures and OCCT class generator
- executable ExpToCasExe including lax/yacc parsers, for parsing a Part 21 file and generating classes

Formatting added files from package Express following OCCT Coding Rules

Changes for correspondence generated files to OCCT Code Rules.

Add generation hxx files with declaration of arrays.
If field is a HArray1 method for get length of array and method for get element of array by its index are generated.

Changes for generation parser from Lex and YACC files.

Update description file ReadMe.md
This commit is contained in:
abv
2020-04-02 01:21:08 +03:00
committed by smoskvin
parent d7eefb11bf
commit 05cfce4d83
72 changed files with 12682 additions and 8 deletions

129
src/Express/Express.cxx Normal file
View File

@@ -0,0 +1,129 @@
// Created: Wed Nov 3 14:39:28 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express.hxx>
#include <Express_Schema.hxx>
#include <OSD_Process.hxx>
#include <OSD_Environment.hxx>
#include <Quantity_Date.hxx>
#include <TCollection_AsciiString.hxx>
//=======================================================================
// function : Schema
// purpose :
//=======================================================================
Handle(Express_Schema)& Express::Schema()
{
static Handle(Express_Schema) aSchema;
return aSchema;
}
//=======================================================================
// function : WriteFileStamp
// purpose : Write header of HXX or CXX file
//=======================================================================
void Express::WriteFileStamp (Standard_OStream& theOS)
{
static const char* EC_VERSION = "2.0";
OSD_Process aProcess;
Quantity_Date aCurTime = aProcess.SystemDate();
OSD_Environment anEnv ("EXPTOCAS_TIME");
TCollection_AsciiString aTimeString = anEnv.Value();
if (aTimeString.IsEmpty())
{
aTimeString += aCurTime.Year();
aTimeString += "-";
aTimeString += aCurTime.Month();
aTimeString += "-";
aTimeString += aCurTime.Day();
}
theOS << "// Created on : " << aTimeString << "\n"
"// Created by: " << aProcess.UserName() << "\n"
"// Generator: ExpToCasExe (EXPRESS -> CASCADE/XSTEP Translator) V" << EC_VERSION << "\n"
"// Copyright (c) Open CASCADE " << aCurTime.Year() << "\n"
"//\n"
"// This file is part of Open CASCADE Technology software library.\n"
"//\n"
"// This library is free software; you can redistribute it and/or modify it under\n"
"// the terms of the GNU Lesser General Public License version 2.1 as published\n"
"// by the Free Software Foundation, with special exception defined in the file\n"
"// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT\n"
"// distribution for complete text of the license and disclaimer of any warranty.\n"
"//\n"
"// Alternatively, this file may be used under the terms of Open CASCADE\n"
"// commercial license or contractual agreement.\n"
"\n";
}
//=======================================================================
// function : WriteMethodStamp
// purpose :
//=======================================================================
void Express::WriteMethodStamp (Standard_OStream& theOS, const TCollection_AsciiString& theName)
{
theOS << "\n"
"//=======================================================================\n"
"// function : " << theName << "\n"
"// purpose :\n"
"//=======================================================================\n"
"\n";
}
//=======================================================================
// function : ToStepName
// purpose :
//=======================================================================
TCollection_AsciiString Express::ToStepName (const TCollection_AsciiString& theName)
{
TCollection_AsciiString aStepName(theName);
for (Standard_Integer i = 2; i <= aStepName.Length(); i++)
{
if (isupper (aStepName.Value (i)))
{
aStepName.Insert (i++, '_');
}
}
aStepName.LowerCase();
return aStepName;
}
//=======================================================================
// function : GetPrefixEnum
// purpose :
//=======================================================================
TCollection_AsciiString Express::EnumPrefix (const TCollection_AsciiString& theName)
{
TCollection_AsciiString aStepName;
for (Standard_Integer i = 1; i <= theName.Length(); i++)
{
if (isupper (theName.Value (i)))
{
aStepName += theName.Value (i);
}
}
aStepName.LowerCase();
return aStepName;
}

52
src/Express/Express.hxx Normal file
View File

@@ -0,0 +1,52 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_HeaderFile
#define _Express_HeaderFile
#include <Standard_Boolean.hxx>
#include <Standard_Type.hxx>
#include <Standard_OStream.hxx>
class Express_Schema;
class TCollection_AsciiString;
//! Provides data structures for representation of EXPRESS schema
//! (items, types, entities etc.)
//! and tools for generating XSTEP classes (HXX and CXX) from
//! items of the schema
class Express
{
public:
DEFINE_STANDARD_ALLOC
//! Returns (modifiable) handle to static schema object
Standard_EXPORT static Handle(Express_Schema)& Schema();
//! Writes standard copyright stamp (creation date/time, user, etc.)
Standard_EXPORT static void WriteFileStamp (Standard_OStream& theOS);
//! Writes standard comment for method in CXX file
Standard_EXPORT static void WriteMethodStamp (Standard_OStream& theOS, const TCollection_AsciiString& theName);
//! Converts item name from CASCADE to STEP style
//! e.g. BoundedCurve -> bounded_curve
Standard_EXPORT static TCollection_AsciiString ToStepName (const TCollection_AsciiString& theName);
//! Converts item name from CASCADE to STEP style
//! e.g. BoundedCurve -> bounded_curve
Standard_EXPORT static TCollection_AsciiString EnumPrefix (const TCollection_AsciiString& theName);
};
#endif // _Express_HeaderFile

View File

@@ -0,0 +1,71 @@
// Created: Tue Nov 2 14:40:06 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_Alias.hxx>
#include <Message.hxx>
#include <TCollection_AsciiString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_Alias, Express_Item)
//=======================================================================
// function : Express_Alias
// purpose :
//=======================================================================
Express_Alias::Express_Alias (const Standard_CString theName, const Handle(Express_Type)& theType)
: Express_Item (theName), myType (theType)
{
}
//=======================================================================
// function : Type
// purpose :
//=======================================================================
const Handle(Express_Type)& Express_Alias::Type() const
{
return myType;
}
//=======================================================================
// function : CPPName
// purpose :
//=======================================================================
const TCollection_AsciiString Express_Alias::CPPName() const
{
return myType->CPPName();
}
//=======================================================================
// function : GenerateClass
// purpose :
//=======================================================================
Standard_Boolean Express_Alias::GenerateClass() const
{
Message::SendInfo() << "ALIAS " << Name() << " = " << Type()->CPPName() << " used; no generation is needed";
return Standard_False;
}
//=======================================================================
// function : PropagateUse
// purpose :
//=======================================================================
void Express_Alias::PropagateUse() const
{
}

View File

@@ -0,0 +1,55 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Alias_HeaderFile
#define _Express_Alias_HeaderFile
#include <Express_Item.hxx>
#include <Express_Type.hxx>
#include <Standard_Type.hxx>
class TCollection_AsciiString;
//! Implements TYPE = type (alias) item of the EXPRESS
//! schema, with interface for deferred Item class.
class Express_Alias : public Express_Item
{
public:
//! Create ALIAS item and initialize it
Standard_EXPORT Express_Alias (const Standard_CString theName, const Handle(Express_Type)& theType);
//! Returns aliased type
Standard_EXPORT const Handle(Express_Type)& Type() const;
//! Returns name of aliased type
Standard_EXPORT virtual const TCollection_AsciiString CPPName() const Standard_OVERRIDE;
//! Create HXX/CXX files from item
Standard_EXPORT virtual Standard_Boolean GenerateClass() const Standard_OVERRIDE;
//! Propagates the calls of Use function
Standard_EXPORT virtual void PropagateUse() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(Express_Alias, Express_Item)
protected:
private:
Handle(Express_Type) myType;
};
#endif // _Express_Alias_HeaderFile

View File

@@ -0,0 +1,21 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Array_HeaderFile
#define _Express_Array_HeaderFile
#include <Express_ComplexType.hxx>
typedef Express_ComplexType Express_Array;
#endif // _Express_Array_HeaderFile

View File

@@ -0,0 +1,21 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Bag_HeaderFile
#define _Express_Bag_HeaderFile
#include <Express_ComplexType.hxx>
typedef Express_ComplexType Express_Bag;
#endif // _Express_Bag_HeaderFile

View File

@@ -0,0 +1,39 @@
// Created: Tue Nov 2 15:27:26 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_Boolean.hxx>
#include <TCollection_AsciiString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_Boolean, Express_PredefinedType)
//=======================================================================
// function : Express_Boolean
// purpose :
//=======================================================================
Express_Boolean::Express_Boolean()
{
}
//=======================================================================
// function : CPPName
// purpose :
//=======================================================================
const TCollection_AsciiString Express_Boolean::CPPName() const
{
return "Standard_Boolean";
}

View File

@@ -0,0 +1,42 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Boolean_HeaderFile
#define _Express_Boolean_HeaderFile
#include <Express_PredefinedType.hxx>
#include <Standard_Type.hxx>
class TCollection_AsciiString;
//! Implements EXPRESS type 'BOOLEAN'
class Express_Boolean : public Express_PredefinedType
{
public:
//! Empty constructor
Standard_EXPORT Express_Boolean();
//! Returns "Standard_Boolean"
Standard_EXPORT virtual const TCollection_AsciiString CPPName() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(Express_Boolean, Express_PredefinedType)
protected:
private:
};
#endif // _Express_Boolean_HeaderFile

View File

@@ -0,0 +1,114 @@
// Created: Tue Nov 2 15:13:31 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_ComplexType.hxx>
#include <TCollection_AsciiString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_ComplexType, Express_Type)
//=======================================================================
// function : Express_ComplexType
// purpose :
//=======================================================================
Express_ComplexType::Express_ComplexType (const Standard_Integer theImin,
const Standard_Integer theImax,
const Handle(Express_Type)& theType)
{
myMin = theImin;
myMax = theImax;
myType = theType;
}
//=======================================================================
// function : Type
// purpose :
//=======================================================================
const Handle(Express_Type)& Express_ComplexType::Type() const
{
return myType;
}
//=======================================================================
// function : CPPName
// purpose :
//=======================================================================
const TCollection_AsciiString Express_ComplexType::CPPName() const
{
// check if array 2
Handle(Express_Type) aType = myType;
if (aType->IsKind (STANDARD_TYPE(Express_ComplexType)))
{
Handle(Express_ComplexType) aType2 = Handle(Express_ComplexType)::DownCast (aType);
aType = aType2->Type();
}
// parse name of array argument
TCollection_AsciiString aName = aType->CPPName();
Standard_Integer aSplitIdx = aName.Location (1, '_', 1, aName.Length());
TCollection_AsciiString aClassName;
if (aSplitIdx)
{
aClassName = aName.Split (aSplitIdx);
}
else
{
aClassName = aName;
}
Standard_Integer anIdx = aName.Location ("TCollection", 1, aName.Length());
if (anIdx)
{
aName = "Interface_";
}
// generate name
if (aType->IsStandard() || !aSplitIdx)
{
aName = "TColStd_";
}
if (aType == myType)
{
aName += "HArray1Of";
}
else
{
aName += "HArray2Of";
}
aName += aClassName;
return aName;
}
//=======================================================================
// function : Use
// purpose :
//=======================================================================
Standard_Boolean Express_ComplexType::Use() const
{
return myType->Use();
}
//=======================================================================
// function : Use2
// purpose :
//=======================================================================
void Express_ComplexType::Use2 (const TCollection_AsciiString& theRefName, const TCollection_AsciiString& theRefPack) const
{
myType->Use2 (theRefName, theRefPack);
}

View File

@@ -0,0 +1,61 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_ComplexType_HeaderFile
#define _Express_ComplexType_HeaderFile
#include <Express_Type.hxx>
#include <Standard_Type.hxx>
class TCollection_AsciiString;
//! Base class for complex types (ARRAY, LIST, BAG, SET)
//! in EXPRESS schema
//! Stores type of elements and
class Express_ComplexType : public Express_Type
{
public:
//! Creates an object and initializes fields
Standard_EXPORT Express_ComplexType (const Standard_Integer theImin,
const Standard_Integer theImax,
const Handle(Express_Type)& theType);
//! Returns type of complex type items
Standard_EXPORT const Handle(Express_Type)& Type() const;
//! Returns CPP-style name of the type
Standard_EXPORT virtual const TCollection_AsciiString CPPName() const Standard_OVERRIDE;
//! Declares type as used by some item being generated.
//! Calls Use() for type of elements
Standard_EXPORT virtual Standard_Boolean Use() const Standard_OVERRIDE;
//! Declares type as used by some item being generated.
//! Calls Use() for type of elements
Standard_EXPORT virtual void Use2 (const TCollection_AsciiString& theRefName, const TCollection_AsciiString& theRefPack) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(Express_ComplexType, Express_Type)
protected:
private:
Standard_Integer myMin;
Standard_Integer myMax;
Handle(Express_Type) myType;
};
#endif // _Express_ComplexType_HeaderFile

View File

@@ -0,0 +1,24 @@
// Copyright (c) 1999-2020 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.
#ifndef Express_DataMapOfAsciiStringItem_HeaderFile
#define Express_DataMapOfAsciiStringItem_HeaderFile
#include <Express_Item.hxx>
#include <NCollection_DataMap.hxx>
#include <TCollection_AsciiString.hxx>
typedef NCollection_DataMap<TCollection_AsciiString, Handle(Express_Item),
TCollection_AsciiString> Express_DataMapOfAsciiStringItem;
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,114 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Entity_HeaderFile
#define _Express_Entity_HeaderFile
#include <Express_Item.hxx>
#include <Standard_OStream.hxx>
#include <Standard_Type.hxx>
#include <TColStd_HSequenceOfHAsciiString.hxx>
#include <NCollection_DataMap.hxx>
class Express_HSequenceOfEntity;
class Express_HSequenceOfField;
class Dico_DictionaryOfInteger;
//! Implements ENTITY item of the EXPRESS
//! schema, with interface for deferred Item class.
class Express_Entity : public Express_Item
{
public:
//! Create ENTITY item and initialize it
//! flags hasCheck and hasFillShared mark if generated class has
//! methods Check and FillShared correspondingly.
Standard_EXPORT Express_Entity (const Standard_CString theName,
const Handle(TColStd_HSequenceOfHAsciiString)& theInherit,
const Handle(Express_HSequenceOfField)& theFields);
//! Returns sequence of inherited classes (names)
Standard_EXPORT const Handle(TColStd_HSequenceOfHAsciiString)& SuperTypes() const;
//! Returns sequence of inherited items
Standard_EXPORT const Handle(Express_HSequenceOfEntity)& Inherit() const;
//! Returns sequence of fields
Standard_EXPORT const Handle(Express_HSequenceOfField)& Fields() const;
//! Returns number of fields (only own fields if inherited is False
//! and including fields of all supertypes if it is True)
Standard_EXPORT Standard_Integer NbFields (const Standard_Boolean theInherited = Standard_False) const;
//! Sets abstruct flag for entity;
Standard_EXPORT void SetAbstractFlag (const Standard_Boolean theIsAbstract);
//! Returns abstract flag.
Standard_EXPORT inline Standard_Boolean AbstractFlag() const;
DEFINE_STANDARD_RTTIEXT(Express_Entity, Express_Item)
protected:
private:
typedef NCollection_DataMap<TCollection_AsciiString, Standard_Integer, TCollection_AsciiString> DataMapOfStringInteger;
//! Create HXX/CXX files from item
Standard_EXPORT virtual Standard_Boolean GenerateClass() const Standard_OVERRIDE;
//! Propagates the calls of Use function
Standard_EXPORT virtual void PropagateUse() const Standard_OVERRIDE;
//! Writes includes section of HXX
Standard_EXPORT Standard_Boolean writeIncludes (Standard_OStream& theOS) const;
//! Writes code for reading all fields
Standard_EXPORT Standard_Integer writeRWReadCode (Standard_OStream& theOS,
const Standard_Integer theStart,
const Standard_Integer theOwn) const;
//! Writes code for writing all fields
Standard_EXPORT Standard_Integer writeRWWriteCode (Standard_OStream& theOS,
const Standard_Integer theStart,
const Standard_Integer theOwn) const;
//! Writes code for adding shared entities to the graph
Standard_EXPORT Standard_Integer writeRWShareCode (Standard_OStream& theOS,
const Standard_Integer theStart,
const Standard_Integer theOwn) const;
//! Writes arguments and code for method Init()
//! Mode identifies what code is being written:
//! 0 - HXX declaration
//! 1 - CXX declaration
//! 2 - call (argument list)
//! 3 - implementation
//! 4 - call (argument list for RW)
Standard_EXPORT Standard_Integer makeInit (Standard_OStream& theOS,
const Standard_Integer theShift,
const Standard_Integer theOwn,
const Standard_Integer theMode) const;
private:
Handle(TColStd_HSequenceOfHAsciiString) mySupers;
Handle(Express_HSequenceOfEntity) myInherit;
Handle(Express_HSequenceOfField) myFields;
Standard_Boolean myIsAbstract;
};
#endif // _Express_Entity_HeaderFile

View File

@@ -0,0 +1,107 @@
// Created: Tue Nov 2 14:40:06 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_Enum.hxx>
#include <Express.hxx>
#include <Message.hxx>
#include <OSD_Directory.hxx>
#include <OSD_FileSystem.hxx>
#include <OSD_Path.hxx>
#include <OSD_Protection.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_Enum, Express_Item)
//=======================================================================
// function : Express_Enum
// purpose :
//=======================================================================
Express_Enum::Express_Enum (const Standard_CString theName, const Handle(TColStd_HSequenceOfHAsciiString)& theNames)
: Express_Item (theName), myNames (theNames)
{
}
//=======================================================================
// function : Names
// purpose :
//=======================================================================
const Handle(TColStd_HSequenceOfHAsciiString)& Express_Enum::Names() const
{
return myNames;
}
//=======================================================================
// function : GenerateClass
// purpose :
//=======================================================================
Standard_Boolean Express_Enum::GenerateClass() const
{
const TCollection_AsciiString aCPPName = CPPName();
Message::SendInfo() << "Generating ENUMERATION " << aCPPName;
// create a package directory (if not yet exist)
OSD_Protection aProt (OSD_RWXD, OSD_RWXD, OSD_RX, OSD_RX);
TCollection_AsciiString aPack = GetPackageName();
OSD_Path aPath (aPack);
OSD_Directory aDir (aPath);
aDir.Build (aProt);
aPack += "/";
aPack += aCPPName;
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
// Open HXX file
std::shared_ptr<std::ostream> aStreamPtr = aFileSystem->OpenOStream (aPack.Cat (".hxx"), std::ios::out | std::ios::ate);
Standard_OStream& anOS = *aStreamPtr;
// write header
Express::WriteFileStamp (anOS);
// write defines
anOS << "#ifndef _" << aCPPName << "_HeaderFile\n"
"#define _" << aCPPName << "_HeaderFile\n"
"\n"
"enum " << aCPPName << "\n"
"{\n";
TCollection_AsciiString aPrefix = Express::EnumPrefix (Name());
for (Standard_Integer i = 1; i <= myNames->Length(); i++)
{
if (i > 1)
{
anOS << ",\n";
}
anOS << " " << GetPackageName() << "_" << aPrefix << myNames->Value (i)->String();
}
anOS << "\n"
"};\n"
"\n"
"#endif // _" << aCPPName << "_HeaderFile\n";
aStreamPtr.reset();
return Standard_False;
}
//=======================================================================
// function : PropagateUse
// purpose :
//=======================================================================
void Express_Enum::PropagateUse() const
{
}

View File

@@ -0,0 +1,50 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Enum_HeaderFile
#define _Express_Enum_HeaderFile
#include <Express_Item.hxx>
#include <Standard_Type.hxx>
#include <TColStd_HSequenceOfHAsciiString.hxx>
//! Implements TYPE ENUMERATION item of the EXPRESS
//! schema, with interface for deferred Item class.
class Express_Enum : public Express_Item
{
public:
//! Create ENUM item and initialize it
Standard_EXPORT Express_Enum (const Standard_CString theName, const Handle(TColStd_HSequenceOfHAsciiString)& theNames);
//! Returns names of enumeration variants
Standard_EXPORT const Handle(TColStd_HSequenceOfHAsciiString)& Names() const;
//! Create HXX/CXX files from item
Standard_EXPORT virtual Standard_Boolean GenerateClass() const Standard_OVERRIDE;
//! Propagates the calls of Use function
Standard_EXPORT virtual void PropagateUse() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(Express_Enum, Express_Item)
protected:
private:
Handle(TColStd_HSequenceOfHAsciiString) myNames;
};
#endif // _Express_Enum_HeaderFile

View File

@@ -0,0 +1,89 @@
// Created: Tue Nov 2 16:40:51 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_Field.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_HAsciiString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_Field, Standard_Transient)
//=======================================================================
// function : Express_Field
// purpose :
//=======================================================================
Express_Field::Express_Field (const Standard_CString theName,
const Handle(Express_Type)& theType,
const Standard_Boolean theOpt)
{
myName = new TCollection_HAsciiString (theName);
myType = theType;
myOpt = theOpt;
}
//=======================================================================
// function : Express_Field
// purpose :
//=======================================================================
Express_Field::Express_Field (const Handle(TCollection_HAsciiString)& theName,
const Handle(Express_Type)& theType,
const Standard_Boolean theOpt)
{
myName = theName;
myType = theType;
myOpt = theOpt;
}
//=======================================================================
// function : Name
// purpose :
//=======================================================================
const TCollection_AsciiString& Express_Field::Name() const
{
return myName->String();
}
//=======================================================================
// function : HName
// purpose :
//=======================================================================
Handle(TCollection_HAsciiString) Express_Field::HName() const
{
return myName;
}
//=======================================================================
// function : Type
// purpose :
//=======================================================================
const Handle(Express_Type)& Express_Field::Type() const
{
return myType;
}
//=======================================================================
// function : IsOptional
// purpose :
//=======================================================================
Standard_Boolean Express_Field::IsOptional() const
{
return myOpt;
}

View File

@@ -0,0 +1,63 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Field_HeaderFile
#define _Express_Field_HeaderFile
#include <Standard_Type.hxx>
class Express_Type;
class TCollection_HAsciiString;
class TCollection_AsciiString;
//! Represents field of the ENTITY item in the EXPRESS schema
class Express_Field : public Standard_Transient
{
public:
//! Create object and initialize it
Standard_EXPORT Express_Field (const Standard_CString theName,
const Handle(Express_Type)& theType,
const Standard_Boolean theOpt);
//! Create object and initialize it
Standard_EXPORT Express_Field (const Handle(TCollection_HAsciiString)& theName,
const Handle(Express_Type)& theType,
const Standard_Boolean theOpt);
//! Returns field name
Standard_EXPORT const TCollection_AsciiString& Name() const;
//! Returns a pointer to the field name to modify it
Standard_EXPORT Handle(TCollection_HAsciiString) HName() const;
//! Returns field type
Standard_EXPORT const Handle(Express_Type)& Type() const;
//! Returns True if field is optional
Standard_EXPORT Standard_Boolean IsOptional() const;
DEFINE_STANDARD_RTTIEXT(Express_Field, Standard_Transient)
protected:
private:
Handle(TCollection_HAsciiString) myName;
Handle(Express_Type) myType;
Standard_Boolean myOpt;
};
#endif // _Express_Field_HeaderFile

View File

@@ -0,0 +1,22 @@
// Copyright (c) 1999-2020 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.
#ifndef Express_HSequenceOfEntity_HeaderFile
#define Express_HSequenceOfEntity_HeaderFile
#include <Express_SequenceOfEntity.hxx>
#include <NCollection_DefineHSequence.hxx>
DEFINE_HSEQUENCE(Express_HSequenceOfEntity, Express_SequenceOfEntity)
#endif

View File

@@ -0,0 +1,22 @@
// Copyright (c) 1999-2020 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.
#ifndef Express_HSequenceOfField_HeaderFile
#define Express_HSequenceOfField_HeaderFile
#include <Express_SequenceOfField.hxx>
#include <NCollection_DefineHSequence.hxx>
DEFINE_HSEQUENCE(Express_HSequenceOfField, Express_SequenceOfField)
#endif

View File

@@ -0,0 +1,22 @@
// Copyright (c) 1999-2020 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.
#ifndef Express_HSequenceOfItem_HeaderFile
#define Express_HSequenceOfItem_HeaderFile
#include <Express_SequenceOfItem.hxx>
#include <NCollection_DefineHSequence.hxx>
DEFINE_HSEQUENCE(Express_HSequenceOfItem, Express_SequenceOfItem)
#endif

View File

@@ -0,0 +1,39 @@
// Created: Tue Nov 2 15:27:26 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_Integer.hxx>
#include <TCollection_AsciiString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_Integer, Express_PredefinedType)
//=======================================================================
// function : Express_Integer
// purpose :
//=======================================================================
Express_Integer::Express_Integer()
{
}
//=======================================================================
// function : CPPName
// purpose :
//=======================================================================
const TCollection_AsciiString Express_Integer::CPPName() const
{
return "Standard_Integer";
}

View File

@@ -0,0 +1,42 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Integer_HeaderFile
#define _Express_Integer_HeaderFile
#include <Express_PredefinedType.hxx>
#include <Standard_Type.hxx>
class TCollection_AsciiString;
//! Implements EXPRESS type 'INTEGER'
class Express_Integer : public Express_PredefinedType
{
public:
//! Empty constructor
Standard_EXPORT Express_Integer();
//! Returns "Standard_Integer"
Standard_EXPORT virtual const TCollection_AsciiString CPPName() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(Express_Integer, Express_PredefinedType)
protected:
private:
};
#endif // _Express_Integer_HeaderFile

View File

@@ -0,0 +1,335 @@
// Created: Tue Nov 2 13:14:31 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_Item.hxx>
#include <Message.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_HAsciiString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_Item, Standard_Transient)
Standard_Integer Express_Item::myIndex = -1;
//=======================================================================
// function : Express_Item
// purpose :
//=======================================================================
Express_Item::Express_Item (const Standard_CString theName)
{
myName = new TCollection_HAsciiString (theName);
myGenMode = GM_Undefined;
myShortName = new TCollection_HAsciiString;
myCategory = new TCollection_HAsciiString;
myhasCheck = Standard_False;
myhasFillShared = Standard_False;
myLoopFlag = Standard_False;
}
//=======================================================================
// function : Express_Item
// purpose :
//=======================================================================
Express_Item::Express_Item (const Handle(TCollection_HAsciiString)& theName)
{
myName = theName;
myGenMode = GM_Undefined;
myShortName = new TCollection_HAsciiString;
myCategory = new TCollection_HAsciiString;
myhasCheck = Standard_False;
myhasFillShared = Standard_False;
myLoopFlag = Standard_False;
}
//=======================================================================
// function : Name
// purpose :
//=======================================================================
const TCollection_AsciiString& Express_Item::Name() const
{
return myName->String();
}
//=======================================================================
// function : HName
// purpose :
//=======================================================================
Handle(TCollection_HAsciiString) Express_Item::HName() const
{
return myName;
}
//=======================================================================
// function : CPPName
// purpose :
//=======================================================================
const TCollection_AsciiString Express_Item::CPPName() const
{
TCollection_AsciiString aName = GetPackageName();
aName += "_";
aName += Name();
return aName;
}
//=======================================================================
// function : SetPackageName
// purpose :
//=======================================================================
void Express_Item::SetPackageName (const TCollection_AsciiString& thePack)
{
myPack = new TCollection_HAsciiString(thePack);
}
//=======================================================================
// function : GetPackageName
// purpose :
//=======================================================================
const TCollection_AsciiString& Express_Item::GetPackageName() const
{
if (myPack.IsNull())
{
Message::SendWarning() << "Warning: item " << Name() << " still has no package assigned, used " << GetUnknownPackageName();
return GetUnknownPackageName();
}
return myPack->String();
}
//=======================================================================
// function : IsPackageNameSet
// purpose :
//=======================================================================
Standard_Boolean Express_Item::IsPackageNameSet() const
{
return !myPack.IsNull();
}
//=======================================================================
// function : GetUnknownPackageName
// purpose :
//=======================================================================
TCollection_AsciiString& Express_Item::GetUnknownPackageName()
{
static TCollection_AsciiString aUnknownPackageName = "StepStep";
return aUnknownPackageName;
}
//=======================================================================
// function : GetGenMode
// purpose :
//=======================================================================
Express_Item::GenMode Express_Item::GetGenMode() const
{
return myGenMode;
}
//=======================================================================
// function : SetGenMode
// purpose :
//=======================================================================
void Express_Item::SetGenMode (const Express_Item::GenMode theGenMode)
{
myGenMode = theGenMode;
}
//=======================================================================
// function : ResetLoopFlag
// purpose :
//=======================================================================
void Express_Item::ResetLoopFlag()
{
myLoopFlag = Standard_False;
}
//=======================================================================
// function : Generate
// purpose :
//=======================================================================
Standard_Boolean Express_Item::Generate()
{
// skip items without "generate" mark
GenMode aMode = GetGenMode();
if (!(aMode == GM_GenByUser || aMode == GM_GenByAlgo))
{
return Standard_False;
}
// manage indent for cout in order to mark structure of calls
static Standard_Integer aShift = -1;
aShift++;
for (Standard_Integer i = 0; i < aShift; i++)
{
std::cout << " ";
}
// sets the mode to generated before "GenerateClass" function to avoid looping
SetGenMode (GM_Generated);
Standard_Boolean aRes = GenerateClass();
aShift--;
return aRes;
}
//=======================================================================
// function : Use
// purpose :
//=======================================================================
Standard_Boolean Express_Item::Use()
{
// if Item is not mentioned by the user but is used, then it is necessary to generate
if (GetGenMode() != GM_Undefined)
{
return Standard_False;
}
SetGenMode (GM_GenByAlgo);
return Generate();
}
//=======================================================================
// function : Use2
// purpose :
//=======================================================================
void Express_Item::Use2 (const TCollection_AsciiString& theRefName, const TCollection_AsciiString& theRefPack)
{
if (myLoopFlag)
{
return;
}
else
{
myLoopFlag = Standard_True;
}
// issue a warning message if item does not have package assigned
if (!IsPackageNameSet())
{
Message::SendWarning() << "Warning: item " << Name() << " has no package assigned but used by " << theRefName << ", setting " << theRefPack;
SetPackageName (theRefPack);
}
PropagateUse();
}
//=======================================================================
// function : SetCategory
// purpose :
//=======================================================================
void Express_Item::SetCategory (const Handle(TCollection_HAsciiString)& theCateg)
{
myCategory = theCateg;
}
//=======================================================================
// function : Cartegory
// purpose :
//=======================================================================
const TCollection_AsciiString& Express_Item::Category() const
{
return myCategory->String();
}
//=======================================================================
// function : SetShortName
// purpose :
//=======================================================================
void Express_Item::SetShortName (const Handle(TCollection_HAsciiString)& theShName)
{
myShortName = theShName;
}
//=======================================================================
// function : ShortName
// purpose :
//=======================================================================
Handle(TCollection_HAsciiString) Express_Item::ShortName() const
{
return myShortName;
}
//=======================================================================
// function : SetCheckFlag
// purpose :
//=======================================================================
void Express_Item::SetCheckFlag (const Standard_Boolean theCheckFlag)
{
myhasCheck = theCheckFlag;
}
//=======================================================================
// function : CheckFlag
// purpose :
//=======================================================================
Standard_Boolean Express_Item::CheckFlag() const
{
return myhasCheck;
}
//=======================================================================
// function : SetFillSharedFlag
// purpose :
//=======================================================================
void Express_Item::SetFillSharedFlag (const Standard_Boolean theFillSharedFlag)
{
myhasFillShared = theFillSharedFlag;
}
//=======================================================================
// function : FillSharedFlag
// purpose :
//=======================================================================
Standard_Boolean Express_Item::FillSharedFlag() const
{
return myhasFillShared;
}
//=======================================================================
// function : SetIndex
// purpose :
//=======================================================================
void Express_Item::SetIndex (const Standard_Integer theIndex)
{
myIndex = theIndex;
}
//=======================================================================
// function : Index
// purpose :
//=======================================================================
Standard_Integer Express_Item::Index()
{
return myIndex;
}

View File

@@ -0,0 +1,150 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Item_HeaderFile
#define _Express_Item_HeaderFile
#include <Standard.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_CString.hxx>
#include <Standard_DefineHandle.hxx>
#include <Standard_Transient.hxx>
class TCollection_AsciiString;
class TCollection_HAsciiString;
//! Base class for items of the schema. Stores a name of the class,
//! package name and flag used to mark items for generation.
//! Provides interface for writing generated class definitions to HXX
//! and CXX files.
class Express_Item : public Standard_Transient
{
public:
enum GenMode
{
GM_NoGen, // Item in existed list - no need to generate
GM_GenByUser, // Item in new list - need to generate
GM_GenByAlgo, // Item isn't in any list but is used by needed item
GM_Undefined, // Item isn't in any list
GM_Generated // Item has been generated
};
//! Returns item name
Standard_EXPORT const TCollection_AsciiString& Name() const;
//! Returns a pointer to the item name to modify it
Standard_EXPORT Handle(TCollection_HAsciiString) HName() const;
//! Returns (generated) name for the item in CXX-style (Package_Class)
Standard_EXPORT virtual const TCollection_AsciiString CPPName() const;
//! Returns package name
//! If not defined, returns unknown package name: "StepStep"
Standard_EXPORT const TCollection_AsciiString& GetPackageName() const;
//! Returns whether the package name is set.
Standard_EXPORT Standard_Boolean IsPackageNameSet() const;
//! Returns unknown package name: "StepStep"
Standard_EXPORT static TCollection_AsciiString& GetUnknownPackageName();
//! Sets package name
Standard_EXPORT void SetPackageName (const TCollection_AsciiString& thePack);
//! Returns item generation mode
Standard_EXPORT GenMode GetGenMode() const;
//! Change generation mode for item
Standard_EXPORT void SetGenMode (const GenMode theGenMode);
//! Reset loop flag
Standard_EXPORT void ResetLoopFlag();
//! General interface for creating HXX/CXX files from item
Standard_EXPORT virtual Standard_Boolean GenerateClass() const = 0;
//! Propagates the calls of Use function
Standard_EXPORT virtual void PropagateUse() const = 0;
//! Checks that item is marked for generation and if yes,
//! generate it by calling GenerateClass. But firstly define
//! PackageName to "StepStep" if not yet defined and drop Mark flag.
Standard_EXPORT Standard_Boolean Generate();
//! Declares item as used by other item being generated
//! If Item is not mentioned by the user (as new or existed) but is used,
//! then it sets GenMode to GM_GenByAlgo and Calls Generate().
Standard_EXPORT Standard_Boolean Use();
//! Mark Item as visited in PropagateUse flow and defined the package name if not set.
Standard_EXPORT void Use2 (const TCollection_AsciiString& theRefName, const TCollection_AsciiString& theRefPack);
//! Set category for item
Standard_EXPORT void SetCategory (const Handle(TCollection_HAsciiString)& theCateg);
//! Get item category
Standard_EXPORT const TCollection_AsciiString& Category() const;
//! Set short name for item
Standard_EXPORT void SetShortName (const Handle(TCollection_HAsciiString)& theShName);
//! Get item short name
Standard_EXPORT Handle(TCollection_HAsciiString) ShortName() const;
//! Set flag for presence of method Check in the class
Standard_EXPORT void SetCheckFlag (const Standard_Boolean theCheckFlag);
//! Get flag resposible for presence of method Check in the class
Standard_EXPORT Standard_Boolean CheckFlag() const;
//! Set flag for presence of method FillShared in the class
Standard_EXPORT void SetFillSharedFlag (const Standard_Boolean theFillSharedFlag);
//! Get flag resposible for presence of method FillShared in the class
Standard_EXPORT Standard_Boolean FillSharedFlag() const;
//! Set start entity index
Standard_EXPORT static void SetIndex (const Standard_Integer theIndex);
//! Get current entity index
Standard_EXPORT static Standard_Integer Index();
DEFINE_STANDARD_RTTIEXT(Express_Item, Standard_Transient)
protected:
//! Creates object and initializes fields PackageName and
//! CreateFlag by 0
Standard_EXPORT Express_Item (const Standard_CString theName);
//! Creates object and initializes fields PackageName and
//! CreateFlag by 0
Standard_EXPORT Express_Item (const Handle(TCollection_HAsciiString)& theName);
private:
Handle(TCollection_HAsciiString) myName;
Handle(TCollection_HAsciiString) myPack;
// "Generate" mark. If is TRUE a class will be generated for the item
GenMode myGenMode;
// Flag to avoid looping
Standard_Boolean myLoopFlag;
Handle(TCollection_HAsciiString) myShortName;
Handle(TCollection_HAsciiString) myCategory;
Standard_Boolean myhasCheck;
Standard_Boolean myhasFillShared;
static Standard_Integer myIndex;
};
#endif // _Express_Item_HeaderFile

View File

@@ -0,0 +1,21 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_List_HeaderFile
#define _Express_List_HeaderFile
#include <Express_ComplexType.hxx>
typedef Express_ComplexType Express_List;
#endif // _Express_List_HeaderFile

View File

@@ -0,0 +1,70 @@
// Created: Tue Nov 2 15:27:26 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_Logical.hxx>
#include <TCollection_AsciiString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_Logical, Express_PredefinedType)
//=======================================================================
// function : Express_Logical
// purpose :
//=======================================================================
Express_Logical::Express_Logical()
{
}
//=======================================================================
// function : CPPName
// purpose :
//=======================================================================
const TCollection_AsciiString Express_Logical::CPPName() const
{
return "StepData_Logical";
}
//=======================================================================
// function : IsStandard
// purpose :
//=======================================================================
Standard_Boolean Express_Logical::IsStandard() const
{
return Standard_False;
}
//=======================================================================
// function : IsSimple
// purpose :
//=======================================================================
Standard_Boolean Express_Logical::IsSimple() const
{
return Standard_True;
}
//=======================================================================
// function : IsHandle
// purpose :
//=======================================================================
Standard_Boolean Express_Logical::IsHandle() const
{
return Standard_False;
}

View File

@@ -0,0 +1,51 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Logical_HeaderFile
#define _Express_Logical_HeaderFile
#include <Express_PredefinedType.hxx>
#include <Standard_Type.hxx>
class TCollection_AsciiString;
//! Implements EXPRESS type 'LOGICAL'
class Express_Logical : public Express_PredefinedType
{
public:
//! Empty constructor
Standard_EXPORT Express_Logical();
//! Returns "StepData_Logical"
Standard_EXPORT virtual const TCollection_AsciiString CPPName() const Standard_OVERRIDE;
//! Return False
Standard_EXPORT virtual Standard_Boolean IsStandard() const Standard_OVERRIDE;
//! Return False
Standard_EXPORT virtual Standard_Boolean IsSimple() const Standard_OVERRIDE;
//! Return False
Standard_EXPORT virtual Standard_Boolean IsHandle() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(Express_Logical, Express_PredefinedType)
protected:
private:
};
#endif // _Express_Logical_HeaderFile

View File

@@ -0,0 +1,167 @@
// Created: Tue Nov 2 15:13:31 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_NamedType.hxx>
#include <Express_Alias.hxx>
#include <Express_Entity.hxx>
#include <Express_Enum.hxx>
#include <Express_Item.hxx>
#include <TCollection_AsciiString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_NamedType, Express_Type)
//=======================================================================
// function : Express_NamedType
// purpose :
//=======================================================================
Express_NamedType::Express_NamedType (const Standard_CString theName)
{
myName = new TCollection_HAsciiString (theName);
}
//=======================================================================
// function : Express_NamedType
// purpose :
//=======================================================================
Express_NamedType::Express_NamedType (const Handle(TCollection_HAsciiString)& theName)
{
myName = theName;
}
//=======================================================================
// function : Name
// purpose :
//=======================================================================
const TCollection_AsciiString& Express_NamedType::Name() const
{
return myName->String();
}
//=======================================================================
// function : HName
// purpose :
//=======================================================================
Handle(TCollection_HAsciiString) Express_NamedType::HName() const
{
return myName;
}
//=======================================================================
// function : Item
// purpose :
//=======================================================================
const Handle(Express_Item)& Express_NamedType::Item() const
{
return myItem;
}
//=======================================================================
// function : SetItem
// purpose :
//=======================================================================
void Express_NamedType::SetItem (const Handle(Express_Item)& theItem)
{
myItem = theItem;
}
//=======================================================================
// function : CPPName
// purpose :
//=======================================================================
const TCollection_AsciiString Express_NamedType::CPPName() const
{
return myItem->CPPName();
}
//=======================================================================
// function : IsStandard
// purpose :
//=======================================================================
Standard_Boolean Express_NamedType::IsStandard() const
{
if (myItem->IsKind (STANDARD_TYPE(Express_Alias)))
{
Handle(Express_Alias) anAlias = Handle(Express_Alias)::DownCast (myItem);
return anAlias->Type()->IsStandard();
}
return Standard_False;
}
//=======================================================================
// function : IsSimple
// purpose :
//=======================================================================
Standard_Boolean Express_NamedType::IsSimple() const
{
if (myItem->IsKind (STANDARD_TYPE(Express_Alias)))
{
Handle(Express_Alias) anAlias = Handle(Express_Alias)::DownCast (myItem);
return anAlias->Type()->IsSimple();
}
if (myItem->IsKind (STANDARD_TYPE(Express_Enum)))
{
return Standard_True;
}
return Standard_False; // SELECT & ENTITY
}
//=======================================================================
// function : IsHandle
// purpose :
//=======================================================================
Standard_Boolean Express_NamedType::IsHandle() const
{
if (myItem->IsKind (STANDARD_TYPE(Express_Alias)))
{
Handle(Express_Alias) alias = Handle(Express_Alias)::DownCast (myItem);
return alias->Type()->IsHandle();
}
if (myItem->IsKind (STANDARD_TYPE(Express_Entity)))
{
return Standard_True;
}
return Standard_False; // SELECT & ENUMERATION
}
//=======================================================================
// function : Use
// purpose :
//=======================================================================
Standard_Boolean Express_NamedType::Use() const
{
return myItem->Use();
}
//=======================================================================
// function : Use2
// purpose :
//=======================================================================
void Express_NamedType::Use2 (const TCollection_AsciiString& theRefName, const TCollection_AsciiString& theRefPack) const
{
myItem->Use2 (theRefName, theRefPack);
}

View File

@@ -0,0 +1,81 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_NamedType_HeaderFile
#define _Express_NamedType_HeaderFile
#include <Express_Type.hxx>
#include <Standard_Type.hxx>
class Express_Item;
class TCollection_AsciiString;
class TCollection_HAsciiString;
//! Base class for complex types (ARRAY, LIST, BAG, SET)
//! in EXPRESS schema
//! Stores type of elements and
class Express_NamedType : public Express_Type
{
public:
//! Creates an object and initializes by name
Standard_EXPORT Express_NamedType (const Standard_CString theName);
//! Creates an object and initializes by name
Standard_EXPORT Express_NamedType (const Handle(TCollection_HAsciiString)& theName);
//! Returns name of type (item in schema)
Standard_EXPORT const TCollection_AsciiString& Name() const;
//! Returns a pointer to the type name to modify it
Standard_EXPORT Handle(TCollection_HAsciiString) HName() const;
//! Returns handle to referred item in schema
Standard_EXPORT const Handle(Express_Item)& Item() const;
//! Sets handle to referred item in schema
Standard_EXPORT void SetItem (const Handle(Express_Item)& theItem);
//! Returns CPP-style name of the type
Standard_EXPORT virtual const TCollection_AsciiString CPPName() const Standard_OVERRIDE;
//! Return True if type is defined in package Standard
Standard_EXPORT virtual Standard_Boolean IsStandard() const Standard_OVERRIDE;
//! Return True if type is simple (not a class)
Standard_EXPORT virtual Standard_Boolean IsSimple() const Standard_OVERRIDE;
//! Return True if type is inherited from Transient
Standard_EXPORT virtual Standard_Boolean IsHandle() const Standard_OVERRIDE;
//! Declares type as used by some item being generated.
//! Calls Use() for referred item (found by name).
Standard_EXPORT virtual Standard_Boolean Use() const Standard_OVERRIDE;
//! Declares type as used by some item being generated.
//! Calls Use() for referred item (found by name).
Standard_EXPORT virtual void Use2 (const TCollection_AsciiString& theRefName, const TCollection_AsciiString& theRefPack) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(Express_NamedType, Express_Type)
protected:
private:
Handle(TCollection_HAsciiString) myName;
Handle(Express_Item) myItem;
};
#endif // _Express_NamedType_HeaderFile

View File

@@ -0,0 +1,21 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Number_HeaderFile
#define _Express_Number_HeaderFile
#include <Express_Integer.hxx>
typedef Express_Integer Express_Number;
#endif // _Express_Number_HeaderFile

View File

@@ -0,0 +1,38 @@
// Created: Tue Nov 2 15:13:31 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_PredefinedType.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_PredefinedType, Express_Type)
//=======================================================================
// function : Express_PredefinedType
// purpose :
//=======================================================================
Express_PredefinedType::Express_PredefinedType()
{
}
//=======================================================================
// function : IsStandard
// purpose :
//=======================================================================
Standard_Boolean Express_PredefinedType::IsStandard() const
{
return Standard_True;
}

View File

@@ -0,0 +1,41 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_PredefinedType_HeaderFile
#define _Express_PredefinedType_HeaderFile
#include <Standard_Type.hxx>
#include <Express_Type.hxx>
//! Base class for predefined types (like NUMBER or STRING)
//! in EXPRESS schema
class Express_PredefinedType : public Express_Type
{
public:
//! Returns True
Standard_EXPORT virtual Standard_Boolean IsStandard() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(Express_PredefinedType, Express_Type)
protected:
//! Empty constructor
Standard_EXPORT Express_PredefinedType();
private:
};
#endif // _Express_PredefinedType_HeaderFile

View File

@@ -0,0 +1,39 @@
// Created: Tue Nov 2 15:27:26 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_Real.hxx>
#include <TCollection_AsciiString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_Real,Express_PredefinedType)
//=======================================================================
// function : Express_Real
// purpose :
//=======================================================================
Express_Real::Express_Real()
{
}
//=======================================================================
// function : CPPName
// purpose :
//=======================================================================
const TCollection_AsciiString Express_Real::CPPName() const
{
return "Standard_Real";
}

View File

@@ -0,0 +1,42 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Real_HeaderFile
#define _Express_Real_HeaderFile
#include <Express_PredefinedType.hxx>
#include <Standard_Type.hxx>
class TCollection_AsciiString;
//! Implements EXPRESS type 'REAL'
class Express_Real : public Express_PredefinedType
{
public:
//! Empty constructor
Standard_EXPORT Express_Real();
//! Returns "Standard_Real"
Standard_EXPORT virtual const TCollection_AsciiString CPPName() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(Express_Real, Express_PredefinedType)
protected:
private:
};
#endif // _Express_Real_HeaderFile

View File

@@ -0,0 +1,49 @@
// Created: Fri Nov 22 13:32:26 2002
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_Reference.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_Reference, Express_Item)
//=======================================================================
// function : Express_Reference
// purpose :
//=======================================================================
Express_Reference::Express_Reference (const Standard_CString theName,
const Handle(TColStd_HSequenceOfHAsciiString)& theTypes)
: Express_Item (theName)
{
myTypes = theTypes;
}
//=======================================================================
// function : GenerateClass
// purpose : dummy method
//=======================================================================
Standard_Boolean Express_Reference::GenerateClass() const
{
return Standard_False;
}
//=======================================================================
// function : PropagateUse
// purpose : dummy method
//=======================================================================
void Express_Reference::PropagateUse() const
{
}

View File

@@ -0,0 +1,65 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Reference_HeaderFile
#define _Express_Reference_HeaderFile
#include <Express_Item.hxx>
#include <Standard_Type.hxx>
#include <TColStd_HSequenceOfHAsciiString.hxx>
class Express_HSequenceOfItem;
//! Implements REFERENCE FROM (list of types used from other schema)
//! item of the EXPRESS schema, with interface for Item class.
class Express_Reference : public Express_Item
{
public:
//! Create Reference item and initialize it
Standard_EXPORT Express_Reference (const Standard_CString theName,
const Handle(TColStd_HSequenceOfHAsciiString)& theTypes);
//! Returns list of types referenced
const Handle(TColStd_HSequenceOfHAsciiString)& Types() const
{
return myTypes;
}
//! Returns handle to sequence of items corresponding to
//! listed types
const Handle(Express_HSequenceOfItem)& Items() const
{
return myItems;
}
//! Redefined to empty (in order to be able to instantiate)
//! Return False
Standard_EXPORT virtual Standard_Boolean GenerateClass() const Standard_OVERRIDE;
//! Propagates the calls of Use function
Standard_EXPORT virtual void PropagateUse() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(Express_Reference, Express_Item)
protected:
private:
Handle(TColStd_HSequenceOfHAsciiString) myTypes;
Handle(Express_HSequenceOfItem) myItems;
};
#endif // _Express_Reference_HeaderFile

View File

@@ -0,0 +1,330 @@
// Created: Tue Nov 2 12:29:06 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_Schema.hxx>
#include <Express_Alias.hxx>
#include <Express_ComplexType.hxx>
#include <Express_Entity.hxx>
#include <Express_Enum.hxx>
#include <Express_HSequenceOfEntity.hxx>
#include <Express_HSequenceOfField.hxx>
#include <Express_NamedType.hxx>
#include <Express_Select.hxx>
#include <Express_Type.hxx>
#include <Message.hxx>
#include <TColStd_HSequenceOfHAsciiString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_Schema, Standard_Transient)
//=======================================================================
// function : Express_Schema
// purpose :
//=======================================================================
Express_Schema::Express_Schema (const Standard_CString theName,
const Handle(Express_HSequenceOfItem)& theItems)
{
myName = new TCollection_HAsciiString (theName);
myItems = theItems;
Prepare();
}
//=======================================================================
// function : Express_Schema
// purpose :
//=======================================================================
Express_Schema::Express_Schema (const Handle(TCollection_HAsciiString)& theName,
const Handle(Express_HSequenceOfItem)& theItems)
{
myName = theName;
myItems = theItems;
Prepare();
}
//=======================================================================
// function : Name
// purpose :
//=======================================================================
const Handle(TCollection_HAsciiString)& Express_Schema::Name() const
{
return myName;
}
//=======================================================================
// function : Items
// purpose :
//=======================================================================
const Handle(Express_HSequenceOfItem)& Express_Schema::Items() const
{
return myItems;
}
//=======================================================================
// function : NbItems
// purpose :
//=======================================================================
Standard_Integer Express_Schema::NbItems() const
{
return myItems->Length();
}
//=======================================================================
// function : Item
// purpose :
//=======================================================================
Handle(Express_Item) Express_Schema::Item (const Standard_Integer theNum) const
{
return myItems->Value (theNum);
}
//=======================================================================
// function : Item
// purpose :
//=======================================================================
Handle(Express_Item) Express_Schema::Item (const Standard_CString theName,
const Standard_Boolean theSilent) const
{
if (!myDict.IsBound (theName))
{
if (!theSilent)
{
Message::SendFail() << "Error: attempt to access unknown item by name " << theName;
}
return {};
}
return myDict.Find (theName);
}
//=======================================================================
// function : Item
// purpose :
//=======================================================================
Handle(Express_Item) Express_Schema::Item (const TCollection_AsciiString& theName) const
{
return Item (theName.ToCString());
}
//=======================================================================
// function : Item
// purpose :
//=======================================================================
Handle(Express_Item) Express_Schema::Item (const Handle(TCollection_HAsciiString)& theName) const
{
return Item (theName->ToCString());
}
//=======================================================================
// function : nameToCasCade
// purpose : auxilary for Prepare()
// Convert STEP-style name (lowercase, with underscores)
// to CASCADE-style name (each word starts with uppercase, no intervals)
//=======================================================================
static void nameToCasCade (const Handle(TCollection_HAsciiString)& theName)
{
if (theName.IsNull())
{
return;
}
for (Standard_Integer i = 1; i <= theName->Length(); i++)
{
if (theName->Value (i) == '_')
{
theName->Remove (i);
}
else if (i > 1)
{
continue;
}
theName->SetValue (i, UpperCase (theName->Value (i)));
}
}
//=======================================================================
// function : nameToCasCade
// purpose : auxilary for Prepare()
// Convert names for Type object
//=======================================================================
static void nameToCasCade (const Handle(Express_Type)& theType)
{
if (theType->IsKind (STANDARD_TYPE(Express_NamedType)))
{
const Handle(Express_NamedType) aNamedType = Handle(Express_NamedType)::DownCast (theType);
nameToCasCade (aNamedType->HName());
}
else if (theType->IsKind (STANDARD_TYPE(Express_ComplexType)))
{
const Handle(Express_ComplexType) aComplexType = Handle(Express_ComplexType)::DownCast (theType);
nameToCasCade (aComplexType->Type());
}
}
//=======================================================================
// function : Prepare
// purpose : Prepare data: convert names to CasCade, fill dictionary of typenames
// and set handles to items where they are referenced by names
//=======================================================================
void Express_Schema::Prepare()
{
myDict.Clear();
if (myItems.IsNull())
{
return;
}
Standard_Integer aNbItems = NbItems();
// convert names and fill dictionary
for (Standard_Integer aNum = 1; aNum <= aNbItems; aNum++)
{
// get item
const Handle(Express_Item) anItem = Item (aNum);
// change item name
nameToCasCade (anItem->HName());
// change names of referred types and other names
if (anItem->IsKind (STANDARD_TYPE(Express_Alias)))
{
const Handle(Express_Alias) anAlias = Handle(Express_Alias)::DownCast (anItem);
nameToCasCade (anAlias->Type());
}
else if (anItem->IsKind (STANDARD_TYPE(Express_Select)))
{
const Handle(Express_Select) aSelect = Handle(Express_Select)::DownCast (anItem);
for (Standard_Integer i = 1; i <= aSelect->Names()->Length(); i++)
{
nameToCasCade (aSelect->Names()->Value (i));
}
}
else if (anItem->IsKind (STANDARD_TYPE(Express_Enum)))
{
const Handle(Express_Enum) anEnum = Handle(Express_Enum)::DownCast (anItem);
for (Standard_Integer i = 1; i <= anEnum->Names()->Length(); i++)
{
nameToCasCade (anEnum->Names()->Value (i));
}
}
else if (anItem->IsKind (STANDARD_TYPE(Express_Entity)))
{
const Handle(Express_Entity) anEntity = Handle(Express_Entity)::DownCast (anItem);
for (Standard_Integer i = 1; i <= anEntity->SuperTypes()->Length(); i++)
{
nameToCasCade (anEntity->SuperTypes()->Value (i));
}
const Handle(Express_HSequenceOfField) aFields = anEntity->Fields();
for (Standard_Integer i = 1; i <= aFields->Length(); i++)
{
nameToCasCade (aFields->Value (i)->HName());
nameToCasCade (aFields->Value (i)->Type());
}
}
// add to dictionary
myDict.Bind (anItem->Name(), anItem);
}
// set references to items from other items and types
for (Standard_Integer aNum = 1; aNum <= aNbItems; aNum++)
{
const Handle(Express_Item) anItem = Item (aNum);
if (anItem->IsKind (STANDARD_TYPE(Express_Alias)))
{
const Handle(Express_Alias) anAlias = Handle(Express_Alias)::DownCast (anItem);
PrepareType (anAlias->Type());
// for aliases, define package to avoid warnings
anAlias->SetPackageName ("Standard");
continue;
}
else if (anItem->IsKind (STANDARD_TYPE(Express_Select)))
{
const Handle(Express_Select) aSelect = Handle(Express_Select)::DownCast (anItem);
Handle(TColStd_HSequenceOfHAsciiString) aNames = aSelect->Names();
Handle(Express_HSequenceOfItem) anItems = aSelect->Items();
for (Standard_Integer i = 1; i <= aNames->Length(); i++)
{
Handle(Express_Item) aSubItem = Item (aNames->Value (i));
// if select refers to another select, expand it
if (aSubItem->IsKind (STANDARD_TYPE(Express_Select)))
{
Message::SendInfo() << "Info: SELECT " << anItem->Name() << " refers to another SELECT " << aSubItem->Name() << "; expanded";
const Handle(Express_Select) aSubSelect = Handle(Express_Select)::DownCast (aSubItem);
Standard_Integer j = 1;
for (; j <= aSubSelect->Names()->Length(); j++)
{
aNames->InsertBefore (i + j - 1, aSubSelect->Names()->Value (j));
}
aNames->Remove (i + j - 1);
i--;
continue;
}
anItems->Append (aSubItem);
}
}
else if (anItem->IsKind (STANDARD_TYPE(Express_Entity)))
{
const Handle(Express_Entity) anEntity = Handle(Express_Entity)::DownCast (anItem);
Handle(TColStd_HSequenceOfHAsciiString) aNames = anEntity->SuperTypes();
Handle(Express_HSequenceOfEntity) anInhItems = anEntity->Inherit();
for (Standard_Integer i = 1; i <= aNames->Length(); i++)
{
Handle(Express_Entity) aSubEntity = Handle(Express_Entity)::DownCast (Item (aNames->Value (i)));
if (!aSubEntity.IsNull())
{
anInhItems->Append (aSubEntity);
}
else
{
Message::SendFail() << "Error in " << anItem->Name() << ": supertype " << aNames->Value (i)->String() << " is not an ENTITY; ignored";
}
}
const Handle(Express_HSequenceOfField) aFields = anEntity->Fields();
for (Standard_Integer i = 1; i <= aFields->Length(); i++)
{
PrepareType (aFields->Value (i)->Type());
}
}
}
}
//=======================================================================
// function : PrepareType
// purpose :
//=======================================================================
void Express_Schema::PrepareType (const Handle(Express_Type)& theType) const
{
if (theType->IsKind (STANDARD_TYPE(Express_NamedType)))
{
Handle(Express_NamedType) aNamedType = Handle(Express_NamedType)::DownCast (theType);
aNamedType->SetItem (Item (aNamedType->Name()));
}
else if (theType->IsKind (STANDARD_TYPE(Express_ComplexType)))
{
Handle(Express_ComplexType) aComplexType = Handle(Express_ComplexType)::DownCast (theType);
PrepareType (aComplexType->Type());
}
}

View File

@@ -0,0 +1,92 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Schema_HeaderFile
#define _Express_Schema_HeaderFile
#include <Express_DataMapOfAsciiStringItem.hxx>
#include <Express_HSequenceOfItem.hxx>
#include <Standard_Type.hxx>
class TCollection_HAsciiString;
class Express_HSequenceOfItem;
class Express_Item;
class TCollection_AsciiString;
class Express_Type;
//! Represents a schema as a list of items and provides general
//! tools for generating HXX/CXX files (including dictionary of
//! item names)
class Express_Schema : public Standard_Transient
{
public:
//! Creates a schema with given name and given set of items
//! and calls Prepare()
Standard_EXPORT Express_Schema (const Standard_CString theName,
const Handle(Express_HSequenceOfItem)& theItems);
//! Creates a schema with given name and given set of items
//! and calls Prepare()
Standard_EXPORT Express_Schema (const Handle(TCollection_HAsciiString)& theName,
const Handle(Express_HSequenceOfItem)& theItems);
//! Returns schema name
Standard_EXPORT const Handle(TCollection_HAsciiString)& Name() const;
//! Returns sequence of items
Standard_EXPORT const Handle(Express_HSequenceOfItem)& Items() const;
//! Returns number of items
Standard_EXPORT Standard_Integer NbItems() const;
//! Returns item by index
Standard_EXPORT Handle(Express_Item) Item (const Standard_Integer theNum) const;
//! Returns item by name
Standard_EXPORT Handle(Express_Item) Item (const Standard_CString theName,
const Standard_Boolean theSilent = Standard_False) const;
//! Returns item by name
Standard_EXPORT Handle(Express_Item) Item (const TCollection_AsciiString& theName) const;
//! Returns item by name
Standard_EXPORT Handle(Express_Item) Item (const Handle(TCollection_HAsciiString)& theName) const;
DEFINE_STANDARD_RTTIEXT(Express_Schema, Standard_Transient)
protected:
private:
//! Prepares data for further work. Converts all item names
//! from EXPRESS style (aaa_bb) to CASCADE style (AaaBb).
//! Then, makes a dictionary of item names and sets handles
//! to all items referred initially by name
Standard_EXPORT void Prepare();
//! Prepares type for work by setting its handle to item in the
//! schema according to dictionary (for types which refer items
//! by name)
Standard_EXPORT void PrepareType (const Handle(Express_Type)& theType) const;
private:
Handle(TCollection_HAsciiString) myName;
Handle(Express_HSequenceOfItem) myItems;
Express_DataMapOfAsciiStringItem myDict;
};
#endif // _Express_Schema_HeaderFile

View File

@@ -0,0 +1,650 @@
// Created: Tue Nov 2 14:40:06 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_Select.hxx>
#include <Express.hxx>
#include <Express_Alias.hxx>
#include <Express_ComplexType.hxx>
#include <Express_Entity.hxx>
#include <Express_Enum.hxx>
#include <Express_HSequenceOfItem.hxx>
#include <Express_Type.hxx>
#include <Message.hxx>
#include <OSD_Directory.hxx>
#include <OSD_FileSystem.hxx>
#include <OSD_Path.hxx>
#include <OSD_Protection.hxx>
#include <TColStd_HSequenceOfHAsciiString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_Select, Express_Item)
//=======================================================================
// function : Express_Select
// purpose :
//=======================================================================
Express_Select::Express_Select ( const Standard_CString theName,
const Handle(TColStd_HSequenceOfHAsciiString)& theNames)
: Express_Item (theName), myNames (theNames)
{
myItems = new Express_HSequenceOfItem;
}
//=======================================================================
// function : Names
// purpose :
//=======================================================================
const Handle(TColStd_HSequenceOfHAsciiString)& Express_Select::Names() const
{
return myNames;
}
//=======================================================================
// function : Items
// purpose :
//=======================================================================
const Handle(Express_HSequenceOfItem)& Express_Select::Items() const
{
return myItems;
}
//=======================================================================
// function : GenerateClass
// purpose :
//=======================================================================
Standard_Boolean Express_Select::GenerateClass() const
{
const TCollection_AsciiString aCPPName = CPPName();
Handle(TColStd_HSequenceOfInteger) aSeqMember = new TColStd_HSequenceOfInteger;
Handle(TColStd_HSequenceOfInteger) aSeqEntities = new TColStd_HSequenceOfInteger;
for (Standard_Integer i = 1; i <= myItems->Length(); i++)
{
Handle(Express_Item) anItem = myItems->Value (i);
if (anItem->IsKind (STANDARD_TYPE(Express_Entity)) || anItem->IsKind (STANDARD_TYPE(Express_Select))
|| anItem->IsKind (STANDARD_TYPE(Express_Alias)) || anItem->IsKind (STANDARD_TYPE(Express_ComplexType)))
{
aSeqEntities->Append (i);
}
else
{
aSeqMember->Append (i);
}
}
Message::SendInfo() << "Generating SELECT " << aCPPName;
if (!aSeqMember->IsEmpty())
{
Message::SendInfo() << "Generating SELECTMember " << aCPPName << "Member";
generateSelectMember (aSeqMember);
}
// create a package directory (if not yet exist)
OSD_Protection aProt (OSD_RWXD, OSD_RWXD, OSD_RX, OSD_RX);
TCollection_AsciiString aPack = GetPackageName();
OSD_Path aPath (aPack);
OSD_Directory aDir (aPath);
aDir.Build (aProt);
aPack += "/";
aPack += aCPPName;
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
//===============================
// Step 1: generating HXX
{
// Open HXX file
std::shared_ptr<std::ostream> aStreamPtr = aFileSystem->OpenOStream (aPack.Cat (".hxx"), std::ios::out | std::ios::binary);
Standard_OStream& anOS = *aStreamPtr;
// write header
Express::WriteFileStamp (anOS);
// write start define
anOS << "#ifndef _" << aCPPName << "_HeaderFile\n"
"#define _" << aCPPName << "_HeaderFile\n"
"\n";
// write common includes
anOS << "#include <Standard.hxx>\n"
"#include <Standard_DefineAlloc.hxx>\n"
"#include <Standard_Handle.hxx>\n"
"#include <StepData_SelectType.hxx>\n"
"#include <Standard_Integer.hxx>\n"
"\n";
anOS << "class Standard_Transient;\n";
if (!aSeqMember->IsEmpty())
anOS << "class StepData_SelectMember;\n";
Standard_Integer jj = 1;
for (Standard_Integer i = 1; i <= myItems->Length(); i++)
{
Handle(Express_Item) anItem = myItems->Value (i);
anItem->Use();
if (anItem->IsKind (STANDARD_TYPE(Express_Alias)))
{
Handle(Express_Type) aType = Handle(Express_Alias)::DownCast (anItem)->Type();
if (aType->IsStandard())
{
continue;
}
}
anOS << "class " << anItem->CPPName() << ";\n";
jj++;
}
anOS << "\n";
// class declaration
anOS << "//! Representation of STEP SELECT type " << Name() << "\n"
"class " << aCPPName << " : public StepData_SelectType\n"
"{\n"
"\n"
"public:\n"
"\n"
" DEFINE_STANDARD_ALLOC\n"
"\n";
// default constructor
anOS << " //! Empty constructor\n"
" Standard_EXPORT " << aCPPName << "();\n"
"\n";
// write common methods section
anOS << " //! Recognizes a kind of " << Name() << " select type\n";
for (Standard_Integer i = 1; i <= aSeqEntities->Length(); i++)
{
Standard_Integer anIdx = aSeqEntities->Value (i);
anOS << " //! -- " << i << " -> " << myNames->Value (anIdx)->String() << "\n";
}
anOS << " Standard_EXPORT Standard_Integer CaseNum (const Handle(Standard_Transient)& theEnt) const Standard_OVERRIDE;\n"
"\n";
if (!aSeqMember->IsEmpty())
{
anOS << " //! Recognizes items of select member " << Name() << "Member\n";
for (Standard_Integer i = 1; i <= aSeqMember->Length(); i++)
{
Standard_Integer anIdx = aSeqMember->Value (i);
anOS << " //! -- " << i << " -> " << myNames->Value (anIdx)->String() << "\n";
}
anOS << " //! -- 0 else\n"
" Standard_EXPORT virtual Standard_Integer CaseMem (const Handle(StepData_SelectMember)& theEnt) const Standard_OVERRIDE;\n"
"\n"
" //! Returns a new select member the type " << Name() << "Member\n"
" Standard_EXPORT virtual Handle(StepData_SelectMember) NewMember() const Standard_OVERRIDE;\n"
"\n";
}
// write methods get for entities
for (Standard_Integer i = 1; i <= aSeqEntities->Length(); i++)
{
Standard_Integer anIdx = aSeqEntities->Value (i);
Handle(Express_Item) anItem = myItems->Value (anIdx);
const TCollection_AsciiString& aName = anItem->Name();
anOS << " //! Returns Value as " << aName << " (or Null if another type)\n"
" Standard_EXPORT Handle(" << anItem->CPPName() << ") " << aName << "() const;\n"
"\n";
}
// writes method set and get for enum , integer, real and string.
for (Standard_Integer i = 1; i <= aSeqMember->Length(); i++)
{
Standard_Integer anIdx = aSeqMember->Value (i);
Handle(Express_Item) anItem = myItems->Value (anIdx);
const TCollection_AsciiString& aName = anItem->Name();
const TCollection_AsciiString& anItemCPPName = anItem->CPPName();
anOS << " //! Set Value for " << aName << "\n"
" Standard_EXPORT void Set" << aName << " (const " << anItemCPPName << " theVal);\n"
"\n"
" //! Returns Value as " << aName << " (or Null if another type)\n"
" " << anItemCPPName << " " << aName << "() const;\n"
"\n";
}
// write end
anOS << "};\n"
"#endif // _" << aCPPName << "_HeaderFile\n";
aStreamPtr.reset();
}
//===============================
// Step 2: generating CXX
{
// Open CXX file
std::shared_ptr<std::ostream> aStreamPtr = aFileSystem->OpenOStream (aPack.Cat (".cxx"), std::ios::out | std::ios::binary);
Standard_OStream& anOS = *aStreamPtr;
// write header
Express::WriteFileStamp (anOS);
// write include section
anOS << "#include <" << aCPPName << ".hxx>\n";
if (!aSeqMember->IsEmpty())
{
anOS << "#include <" << aCPPName << "Member.hxx>\n"
"#include <TCollection_HAsciiString.hxx>\n";
}
for (Standard_Integer i = 1; i <= aSeqEntities->Length(); i++)
{
Standard_Integer anIdx = aSeqEntities->Value (i);
anOS << "#include <" << myItems->Value (anIdx)->CPPName() << ".hxx>\n";
}
// write constructor
Express::WriteMethodStamp (anOS, aCPPName);
anOS << aCPPName << "::" << aCPPName << "()\n"
"{\n"
"}\n";
// write CaseNum method
Express::WriteMethodStamp (anOS, "CaseNum");
anOS << "Standard_Integer " << aCPPName << "::CaseNum (const Handle(Standard_Transient)& theEnt) const\n"
"{\n";
if (!aSeqEntities->IsEmpty())
{
anOS << " if (theEnt.IsNull()) return 0;\n";
for (Standard_Integer i = 1; i <= aSeqEntities->Length(); i++)
{
Standard_Integer anIdx = aSeqEntities->Value (i);
anOS << " if (theEnt->IsKind (STANDARD_TYPE(" << myItems->Value (anIdx)->CPPName() << "))) return " << i << ";\n";
}
anOS << " return 0;\n"
"}\n";
}
else
{
anOS << " return 0;\n"
"}\n";
}
if (!aSeqMember->IsEmpty())
{
// write CaseMem method
Express::WriteMethodStamp (anOS, "CaseMem");
anOS << "Standard_Integer " << aCPPName << "::CaseMem (const Handle(StepData_SelectMember)& theEnt) const\n"
"{\n"
" if (theEnt.IsNull()) return 0;\n";
for (int j = 1; j <= aSeqMember->Length(); j++)
{
Standard_Integer anIdx = aSeqMember->Value (j);
if (j == 1)
{
anOS << " if (theEnt->Matches (\"" << myNames->Value (anIdx)->String() << "\")) return " << j << ";\n";
}
else
{
anOS << " else if (theEnt->Matches (\"" << myNames->Value (anIdx)->String() << "\")) return " << j << ";\n";
}
}
anOS << " else return 0;\n"
"}\n";
// write NewMember method
Express::WriteMethodStamp (anOS, "NewMember");
anOS << "Handle(StepData_SelectMember) " << aCPPName << "::NewMember() const\n"
"{\n"
" return new " << aCPPName << "Member;\n"
"}\n";
}
// write methods Get for entities.
for (Standard_Integer i = 1; i <= aSeqEntities->Length(); i++)
{
Standard_Integer anIdx = aSeqEntities->Value (i);
Handle(Express_Item) anItem = myItems->Value (anIdx);
const TCollection_AsciiString& aName = anItem->Name();
const TCollection_AsciiString& anItemCPPName = anItem->CPPName();
Express::WriteMethodStamp (anOS, aName);
anOS << "Handle(" << anItemCPPName << ") " << aCPPName << "::" << aName << "() const\n"
"{\n"
" return Handle(" << anItemCPPName << ")::DownCast(Value());\n"
"}\n";
}
// write methods Set and Get for Integer, Real, String and Enum
for (Standard_Integer i = 1; i <= aSeqMember->Length(); i++)
{
Standard_Integer anIdx = aSeqMember->Value (i);
Handle(Express_Item) anItem = myItems->Value (anIdx);
const TCollection_AsciiString& aName = anItem->Name();
const TCollection_AsciiString& anItemCPPName = anItem->CPPName();
TCollection_AsciiString aStamp = "Set";
aStamp += aName;
Express::WriteMethodStamp (anOS, aStamp);
Standard_Boolean isString = (anItemCPPName.Location ("HAsciiString", 1, anItemCPPName.Length()) > 0);
TCollection_AsciiString aNameFunc;
TCollection_AsciiString aFunc;
Standard_Boolean isEnum = anItem->IsKind (STANDARD_TYPE(Express_Enum));
if (!isEnum)
{
if (isString)
{
aFunc += "String";
}
else
{
aNameFunc += anItemCPPName;
aFunc = aNameFunc;
Standard_Integer aSplitInd = aNameFunc.Location ("_", 1, anItemCPPName.Length());
if (aSplitInd)
{
aFunc = aNameFunc.Split (aSplitInd);
}
}
}
// write method set
if (isString)
{
anOS << "void " << aCPPName << "::Set" << aName << " (const Handle(" << anItemCPPName << ") &theVal)\n";
}
else
{
anOS << "void " << aCPPName << "::Set" << aName << " (const " << anItemCPPName << " theVal)\n";
}
anOS << "{\n"
" Handle(" << aCPPName << "Member) SelMem = Handle(" << aCPPName << "Member)::DownCast(Value());\n"
" if (SelMem.IsNull()) return;\n"
" Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(\"" << aName << "\");\n"
" SelMem->SetName (aName->ToCString());\n";
if (isEnum)
{
anOS << " SelMem->SetEnum ((Standard_Integer)theVal);\n";
}
else if (isString)
{
anOS << " SelMem->Set" << aFunc << " (theVal->ToCString());\n";
}
else
{
anOS << " SelMem->Set" << aFunc << " (theVal);\n";
}
anOS << "}\n";
// write method get
Express::WriteMethodStamp (anOS, aName);
if (isString)
{
anOS << "Handle(" << anItemCPPName << ") " << aCPPName << "::" << aName << "() const\n";
}
else
{
anOS << anItemCPPName << " " << aCPPName << "::" << aName << "() const\n";
}
anOS << "{\n"
" Handle(" << aCPPName << "Member) SelMem = Handle(" << aCPPName << "Member)::DownCast (Value());\n"
" if (SelMem.IsNull()) return 0;\n"
" Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString;\n"
" aName->AssignCat (SelMem->Name());\n"
" Handle(TCollection_HAsciiString) aNameItem = new TCollection_HAsciiString(\"" << aName << "\");\n"
" if (aName->IsDifferent (aNameItem)) return 0;\n";
if (isEnum)
{
anOS << " Standard_Integer aNumIt = SelMem->Enum();\n"
" " << anItemCPPName << " aVal;\n"
" switch (aNumIt)\n"
" {\n";
Handle(Express_Enum) anEnum = Handle(Express_Enum)::DownCast (anItem);
Handle(TColStd_HSequenceOfHAsciiString) anEnItems = anEnum->Names();
TCollection_AsciiString aPrefix = Express::EnumPrefix (aName);
for (Standard_Integer k = 1; k <= anEnItems->Length(); k++)
{
anOS << " case " << k << " : aVal = " << aName << "_" << aPrefix << anEnItems->Value (k)->String() << "; break;\n";
}
anOS << " default : return 0; break;\n"
" }\n";
}
else if (isString)
{
anOS << " Handle(TCollection_HAsciiString) aVal = new TCollection_HAsciiString;\n"
" aVal->AssignCat (SelMem->String());\n";
}
else
{
anOS << " " << anItemCPPName << " aVal = SelMem->" << aFunc << "();\n";
}
anOS << " return aVal;\n"
"}\n";
}
aStreamPtr.reset();
}
return Standard_True;
}
//=======================================================================
// function : PropagateUse
// purpose :
//=======================================================================
void Express_Select::PropagateUse() const
{
const TCollection_AsciiString& aPack = GetPackageName();
const TCollection_AsciiString& aName = Name();
for (Standard_Integer i = 1; i <= myItems->Length(); i++)
{
Handle(Express_Item) anItem = myItems->Value (i);
anItem->Use2 (aName, aPack);
}
}
//=======================================================================
// function : GenerateSelectMember
// purpose :
//=======================================================================
Standard_Boolean Express_Select::generateSelectMember (const Handle(TColStd_HSequenceOfInteger)& theSeqMember) const
{
TCollection_AsciiString aCPPname = CPPName();
aCPPname += "Member";
// create a package directory (if not yet exist)
OSD_Protection aProt (OSD_RWXD, OSD_RWXD, OSD_RX, OSD_RX);
TCollection_AsciiString aPack = GetPackageName();
OSD_Path aPath (aPack);
OSD_Directory aDir (aPath);
aDir.Build (aProt);
aPack += "/";
aPack += aCPPname;
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
// Step 1: generating HXX
{
// Open HXX file
std::shared_ptr<std::ostream> aStreamPtr = aFileSystem->OpenOStream (aPack.Cat (".hxx"), std::ios::out | std::ios::binary);
Standard_OStream& anOS = *aStreamPtr;
// write header
Express::WriteFileStamp (anOS);
// write start define
anOS << "#ifndef _" << aCPPname << "_HeaderFile\n"
"#define _" << aCPPname << "_HeaderFile\n"
"\n";
// includes
anOS << "#include <Standard.hxx>\n"
"#include <Standard_Type.hxx>\n"
"#include <Standard_Boolean.hxx>\n"
"#include <Standard_CString.hxx>\n"
"#include <Standard_Integer.hxx>\n"
"#include <StepData_SelectNamed.hxx>\n"
"\n"
"DEFINE_STANDARD_HANDLE(" << aCPPname << ", StepData_SelectNamed)\n"
"\n";
// write start of declaration (inheritance)
anOS << " //! Representation of member for STEP SELECT type " << Name() << "\n"
"class " << aCPPname << " : public StepData_SelectNamed\n"
"{\n"
"public:\n";
// write methods
anOS << " //! Empty constructor\n"
" Standard_EXPORT " << aCPPname << "();\n"
"\n"
" //! Returns True if has name\n"
" Standard_EXPORT virtual Standard_Boolean HasName() const Standard_OVERRIDE;\n"
"\n"
" //! Returns name\n"
" Standard_EXPORT virtual Standard_CString Name() const Standard_OVERRIDE;\n"
"\n"
" //! Set name\n"
" Standard_EXPORT virtual Standard_Boolean SetName(const Standard_CString name) Standard_OVERRIDE;\n"
"\n"
" //! Tells if the name of a SelectMember matches a given one;\n"
" Standard_EXPORT virtual Standard_Boolean Matches (const Standard_CString name) const Standard_OVERRIDE;\n"
"\n";
// write fields
anOS << "private:\n"
" Standard_Integer myCase;\n"
"\n";
// write end
anOS << "};\n"
"#endif // _" << aCPPname << "_HeaderFile\n";
aStreamPtr.reset();
}
//===============================
// Step 2: generating CXX
{
// Open CXX file
std::shared_ptr<std::ostream> aStreamPtr = aFileSystem->OpenOStream (aPack.Cat (".cxx"), std::ios::out | std::ios::binary);
Standard_OStream& anOS = *aStreamPtr;
// write header
Express::WriteFileStamp (anOS);
// write include section
anOS << "#include <" << aCPPname << ".hxx>\n"
"#include <TCollection_HAsciiString.hxx>\n";
// write constructor
Express::WriteMethodStamp (anOS, aCPPname);
anOS << aCPPname << "::" << aCPPname << "() : myCase(0) \n"
"{\n"
"}\n";
// write method HasName
Express::WriteMethodStamp (anOS, "HasName");
anOS << "Standard_Boolean " << aCPPname << "::HasName() const\n"
"{\n"
" return myCase > 0;\n"
"}\n";
Standard_Boolean hasEnum = Standard_False;
// write method Name
Express::WriteMethodStamp (anOS, "Name");
anOS << "Standard_CString " << aCPPname << "::Name() const\n"
"{\n"
" Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString;\n"
" switch (myCase)"
" {\n";
for (Standard_Integer i = 1; i <= theSeqMember->Length(); i++)
{
Standard_Integer anIdx = theSeqMember->Value (i);
Handle(Express_Item) anItem = myItems->Value (anIdx);
if (anItem->IsKind (STANDARD_TYPE(Express_Enum)))
{
hasEnum = Standard_True;
}
anOS << " case " << i << " : aName->AssignCat (\"" << myNames->Value (anIdx)->String() << "\"); break;\n";
}
anOS << " default : break;\n"
" }\n"
" return aName->String();\n"
"}\n";
// write static method for compare name
Express::WriteMethodStamp (anOS, "CompareNames");
anOS << "static Standard_Integer CompareNames (const Standard_CString theName";
if (hasEnum)
{
anOS << ", Standard_Integer &theNumEn)\n";
}
else
{
anOS << ")\n";
}
anOS << "{\n"
" Standard_Integer aCase = 0;\n"
" if (!theName || theName[0] == \'/0\') aCase = 0;\n";
for (Standard_Integer i = 1; i <= theSeqMember->Length(); i++)
{
Standard_Integer anIdx = theSeqMember->Value (i);
Handle(Express_Item) anItem = myItems->Value (anIdx);
if (anItem->IsKind (STANDARD_TYPE(Express_Enum)))
{
Handle(Express_Enum) en = Handle(Express_Enum)::DownCast (anItem);
for (Standard_Integer k = 1; k <= en->Names()->Length(); k++)
{
anOS << " else if (!strcmp (theName, \"" << en->Names()->Value (k)->String() << "\"))\n"
" {\n"
" aCase = " << i << ";\n"
" theNumEn = " << k << ";\n"
" }\n";
}
}
else
{
anOS << " else if (!strcmp (theName, \"" << myNames->Value (anIdx)->String() << "\")) aCase = " << i << ";\n";
}
}
anOS << " return aCase;\n"
"}\n";
// write method SetName
Express::WriteMethodStamp (anOS, "SetName");
anOS << "Standard_Boolean " << aCPPname << "::SetName (const Standard_CString theName) \n"
"{\n";
if (hasEnum)
{
anOS << " Standard_Integer aNumIt = 0;\n"
" myCase = CompareNames (theName, aNumIt);\n"
" if (aNumIt) SetInteger (aNumIt);\n";
}
else
{
anOS << " myCase = CompareNames (theName);\n";
}
anOS << " return (myCase > 0);\n"
"}\n";
// write method Matches
Express::WriteMethodStamp (anOS, "Matches");
anOS << "Standard_Boolean " << aCPPname << "::Matches (const Standard_CString theName) const\n"
"{\n";
if (hasEnum)
{
anOS << " Standard_Integer aNumIt = 0;\n"
" Standard_Integer aCase = CompareNames (theName, aNumIt);\n";
}
else
{
anOS << " Standard_Integer aCase = CompareNames (theName);\n";
}
anOS << " return (aCase > 0);\n"
"}\n";
aStreamPtr.reset();
}
return Standard_True;
}

View File

@@ -0,0 +1,63 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Select_HeaderFile
#define _Express_Select_HeaderFile
#include <Standard_Type.hxx>
#include <Express_Item.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_CString.hxx>
#include <TColStd_HSequenceOfHAsciiString.hxx>
#include <TColStd_HSequenceOfInteger.hxx>
class Express_HSequenceOfItem;
//! Implements TYPE SELECT item of the EXPRESS
//! schema, with interface for deferred Item class.
class Express_Select : public Express_Item
{
public:
//! Create SELECT item and initialize it
Standard_EXPORT Express_Select (const Standard_CString theName,
const Handle(TColStd_HSequenceOfHAsciiString)& theNames);
//! Returns names of types included in this SELECT
Standard_EXPORT const Handle(TColStd_HSequenceOfHAsciiString)& Names() const;
//! Returns sequence of items corresponding to typenames
Standard_EXPORT const Handle(Express_HSequenceOfItem)& Items() const;
//! Create HXX/CXX files from item
Standard_EXPORT virtual Standard_Boolean GenerateClass() const Standard_OVERRIDE;
//! Propagates the calls of Use function
Standard_EXPORT virtual void PropagateUse() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(Express_Select, Express_Item)
protected:
private:
Standard_EXPORT Standard_Boolean generateSelectMember (const Handle(TColStd_HSequenceOfInteger)& theSeqMember) const;
Handle(TColStd_HSequenceOfHAsciiString) myNames;
Handle(Express_HSequenceOfItem) myItems;
};
#endif // _Express_Select_HeaderFile

View File

@@ -0,0 +1,22 @@
// Copyright (c) 1999-2020 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.
#ifndef Express_SequenceOfEntity_HeaderFile
#define Express_SequenceOfEntity_HeaderFile
#include <Express_Entity.hxx>
#include <NCollection_Sequence.hxx>
typedef NCollection_Sequence<Handle(Express_Entity)> Express_SequenceOfEntity;
#endif

View File

@@ -0,0 +1,22 @@
// Copyright (c) 1999-2020 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.
#ifndef Express_SequenceOfField_HeaderFile
#define Express_SequenceOfField_HeaderFile
#include <Express_Field.hxx>
#include <NCollection_Sequence.hxx>
typedef NCollection_Sequence<Handle(Express_Field)> Express_SequenceOfField;
#endif

View File

@@ -0,0 +1,22 @@
// Copyright (c) 1999-2020 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.
#ifndef Express_SequenceOfItem_HeaderFile
#define Express_SequenceOfItem_HeaderFile
#include <Express_Item.hxx>
#include <NCollection_Sequence.hxx>
typedef NCollection_Sequence<Handle(Express_Item)> Express_SequenceOfItem;
#endif

View File

@@ -0,0 +1,21 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Set_HeaderFile
#define _Express_Set_HeaderFile
#include <Express_ComplexType.hxx>
typedef Express_ComplexType Express_Set;
#endif // _Express_Set_HeaderFile

View File

@@ -0,0 +1,49 @@
// Created: Tue Nov 2 15:27:26 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_String.hxx>
#include <TCollection_AsciiString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_String, Express_PredefinedType)
//=======================================================================
// function : Express_String
// purpose :
//=======================================================================
Express_String::Express_String()
{
}
//=======================================================================
// function : CPPName
// purpose :
//=======================================================================
const TCollection_AsciiString Express_String::CPPName() const
{
return "TCollection_HAsciiString";
}
//=======================================================================
// function : IsStandard
// purpose :
//=======================================================================
Standard_Boolean Express_String::IsStandard() const
{
return Standard_False;
}

View File

@@ -0,0 +1,45 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_String_HeaderFile
#define _Express_String_HeaderFile
#include <Express_PredefinedType.hxx>
#include <Standard_Type.hxx>
class TCollection_AsciiString;
//! Implements EXPRESS type 'STRING'
class Express_String : public Express_PredefinedType
{
public:
//! Empty constructor
Standard_EXPORT Express_String();
//! Returns "TCollection_HAsciiString"
Standard_EXPORT virtual const TCollection_AsciiString CPPName() const Standard_OVERRIDE;
//! Returns False
Standard_EXPORT virtual Standard_Boolean IsStandard() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(Express_String, Express_PredefinedType)
protected:
private:
};
#endif // _Express_String_HeaderFile

View File

@@ -0,0 +1,76 @@
// Created: Tue Nov 2 15:11:36 1999
// Author: Andrey BETENEV
// Copyright (c) 1999-2020 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 <Express_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Express_Type, Standard_Transient)
//=======================================================================
// function : Express_Type
// purpose :
//=======================================================================
Express_Type::Express_Type()
{
}
//=======================================================================
// function : IsStandard
// purpose :
//=======================================================================
Standard_Boolean Express_Type::IsStandard() const
{
return Standard_False;
}
//=======================================================================
// function : IsSimple
// purpose :
//=======================================================================
Standard_Boolean Express_Type::IsSimple() const
{
return IsStandard();
}
//=======================================================================
// function : IsHandle
// purpose :
//=======================================================================
Standard_Boolean Express_Type::IsHandle() const
{
return !IsSimple();
}
//=======================================================================
// function : Use
// purpose :
//=======================================================================
Standard_Boolean Express_Type::Use() const
{
return Standard_False;
}
//=======================================================================
// function : Use2
// purpose :
//=======================================================================
void Express_Type::Use2 (const TCollection_AsciiString&, const TCollection_AsciiString&) const
{
}

View File

@@ -0,0 +1,63 @@
// Copyright (c) 1999-2020 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.
#ifndef _Express_Type_HeaderFile
#define _Express_Type_HeaderFile
#include <Standard_Type.hxx>
class TCollection_AsciiString;
//! Provides basis for identification (reference) to some type
//! in express schema
class Express_Type : public Standard_Transient
{
public:
//! Returns CPP-style name of the type
Standard_EXPORT virtual const TCollection_AsciiString CPPName() const = 0;
//! Return True if type is defined in package Standard (False by default)
Standard_EXPORT virtual Standard_Boolean IsStandard() const;
//! Return True if type is simple (not a class)
//! (by default returns IsStandard())
Standard_EXPORT virtual Standard_Boolean IsSimple() const;
//! Return True if type is Transient
//! (by default returns ! IsSimple())
Standard_EXPORT virtual Standard_Boolean IsHandle() const;
//! Declares type as used by some item being generated.
//! Calls Use() for all referred types and schema items.
//! Default instantiation does nothing
Standard_EXPORT virtual Standard_Boolean Use() const;
//! Declares type as used by some item being generated.
//! Calls Use() for all referred types and schema items.
//! Default instantiation does nothing
Standard_EXPORT virtual void Use2 (const TCollection_AsciiString& theRefName, const TCollection_AsciiString& theRefPack) const;
DEFINE_STANDARD_RTTIEXT(Express_Type, Standard_Transient)
protected:
//! Empty constructor
Standard_EXPORT Express_Type();
private:
};
#endif // _Express_Type_HeaderFile

48
src/Express/FILES Normal file
View File

@@ -0,0 +1,48 @@
Express.cxx
Express.hxx
Express_Alias.cxx
Express_Alias.hxx
Express_Array.hxx
Express_Bag.hxx
Express_Boolean.cxx
Express_Boolean.hxx
Express_ComplexType.cxx
Express_ComplexType.hxx
Express_DataMapOfAsciiStringItem.hxx
Express_Entity.cxx
Express_Entity.hxx
Express_Enum.cxx
Express_Enum.hxx
Express_Field.cxx
Express_Field.hxx
Express_HSequenceOfEntity.hxx
Express_HSequenceOfField.hxx
Express_HSequenceOfItem.hxx
Express_Integer.cxx
Express_Integer.hxx
Express_Item.cxx
Express_Item.hxx
Express_List.hxx
Express_Logical.cxx
Express_Logical.hxx
Express_NamedType.cxx
Express_NamedType.hxx
Express_Number.hxx
Express_PredefinedType.cxx
Express_PredefinedType.hxx
Express_Real.cxx
Express_Real.hxx
Express_Reference.cxx
Express_Reference.hxx
Express_Schema.cxx
Express_Schema.hxx
Express_Select.cxx
Express_Select.hxx
Express_SequenceOfEntity.hxx
Express_SequenceOfField.hxx
Express_SequenceOfItem.hxx
Express_Set.hxx
Express_String.cxx
Express_String.hxx
Express_Type.cxx
Express_Type.hxx