//=======================================================================
//function : WriteFileStamp
-//purpose :
+//purpose : Write header of HXX or CXX file
//=======================================================================
-// Write header of HXX or CXX file
void Express::WriteFileStamp (Standard_OStream &os)
{
- static const char *EC_VERSION = "2.0";
+ static const char* EC_VERSION = "2.0";
Standard_CString comm = "//";
TCollection_AsciiString timestring;
- if ( getenv ( "EXPTOCAS_TIME" ) ) timestring = getenv ( "EXPTOCAS_TIME" );
- else {
+ if (getenv("EXPTOCAS_TIME"))
+ {
+ timestring = getenv("EXPTOCAS_TIME");
+ }
+ else
+ {
time_t curtime;
time ( &curtime );
timestring = ctime ( &curtime );
Handle(TCollection_HAsciiString) Express::ToStepName (const Handle(TCollection_HAsciiString) &name)
{
- Handle(TCollection_HAsciiString) stepname = new TCollection_HAsciiString ( name );
- for ( Standard_Integer i=2; i <= stepname->Length(); i++ )
- if ( isupper ( stepname->Value(i) ) ) stepname->Insert ( i++, '_' );
+ Handle(TCollection_HAsciiString) stepname = new TCollection_HAsciiString(name);
+ for (Standard_Integer i = 2; i <= stepname->Length(); i++)
+ {
+ if (isupper(stepname->Value(i)))
+ {
+ stepname->Insert(i++, '_');
+ }
+ }
stepname->LowerCase();
return stepname;
}
+
//=======================================================================
//function : GetPrefixEnum
//purpose :
Handle(TCollection_HAsciiString) Express::EnumPrefix (const Handle(TCollection_HAsciiString) &name)
{
Handle(TCollection_HAsciiString) stepname = new TCollection_HAsciiString;
- for ( Standard_Integer i=1; i <= name->Length(); i++ )
- if ( isupper ( name->Value(i) ) ) {
-
- stepname->AssignCat (new TCollection_HAsciiString(name->Value(i)) );
+ for (Standard_Integer i = 1; i <= name->Length(); i++)
+ {
+ if (isupper(name->Value(i)))
+ {
+ stepname->AssignCat(new TCollection_HAsciiString(name->Value(i)));
}
+ }
stepname->LowerCase();
return stepname;
}
#define _Express_HeaderFile
#include <Standard_Type.hxx>
-
#include <Standard_OStream.hxx>
#include <Standard_Boolean.hxx>
DEFINE_STANDARD_ALLOC
-
//! Returns (modifiable) handle to static schema object
Standard_EXPORT static Handle(Express_Schema)& Schema() ;
//purpose :
//=======================================================================
-Express_Alias::Express_Alias (const Standard_CString name,
- const Handle(Express_Type) &type)
- : Express_Item(name), myType(type)
+Express_Alias::Express_Alias(const Standard_CString name, const Handle(Express_Type) &type)
+ : Express_Item(name), myType(type)
{
}
Standard_Boolean Express_Alias::GenerateClass () const
{
-// std::cout << "Warning: writing ALIAS is not yet implemented, cannot generate " << Name()->ToCString() << std::endl;
- std::cout << "ALIAS " << Name()->ToCString() << " = " << Type()->CPPName()->ToCString() << " used; no generation is needed" << std::endl;
+ //std::cout << "Warning: writing ALIAS is not yet implemented, cannot generate " << Name()->ToCString() << std::endl;
+ std::cout << "ALIAS " << Name()->ToCString() << " = " << Type()->CPPName()->ToCString()
+ << " used; no generation is needed" << std::endl;
return Standard_False;
}
class TCollection_HAsciiString;
-
//! 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 name, const Handle(Express_Type)& type);
//! Create HXX/CXX files from item
Standard_EXPORT virtual Standard_Boolean GenerateClass() const Standard_OVERRIDE;
-
-
-
DEFINE_STANDARD_RTTIEXT(Express_Alias,Express_Item)
protected:
-
-
private:
-
Handle(Express_Type) myType;
-
};
-
-
-
-
-
-
#endif // _Express_Alias_HeaderFile
#define _Express_Boolean_HeaderFile
#include <Standard_Type.hxx>
-
#include <Express_PredefinedType.hxx>
class TCollection_HAsciiString;
-
//! Implements EXPRESS type 'BOOLEAN'
class Express_Boolean : public Express_PredefinedType
{
public:
-
//! Empty constructor
Standard_EXPORT Express_Boolean();
//! Returns "Standard_Boolean"
Standard_EXPORT virtual Handle(TCollection_HAsciiString) CPPName() const Standard_OVERRIDE;
-
-
-
DEFINE_STANDARD_RTTIEXT(Express_Boolean,Express_PredefinedType)
protected:
-
-
-
private:
-
-
-
};
-
-
-
-
-
-
#endif // _Express_Boolean_HeaderFile
//purpose :
//=======================================================================
-Express_ComplexType::Express_ComplexType (const Standard_Integer imin,
- const Standard_Integer imax,
- const Handle(Express_Type) &type)
+Express_ComplexType::Express_ComplexType (
+ const Standard_Integer imin,
+ const Standard_Integer imax,
+ const Handle(Express_Type) &type)
{
myMin = imin;
myMax = imax;
{
// check if array 2
Handle(Express_Type) type = myType;
- if ( type->IsKind ( STANDARD_TYPE(Express_ComplexType) ) ) {
- Handle(Express_ComplexType) c2 = Handle(Express_ComplexType)::DownCast ( type );
+ if (type->IsKind(STANDARD_TYPE(Express_ComplexType)))
+ {
+ Handle(Express_ComplexType) c2 = Handle(Express_ComplexType)::DownCast(type);
type = c2->Type();
}
// parse name of array argument
Handle(TCollection_HAsciiString) name = type->CPPName();
- Standard_Integer split = name->Location ( 1, '_', 1, name->Length() );
+ Standard_Integer split = name->Location(1, '_', 1, name->Length());
Handle(TCollection_HAsciiString) cls;
- if ( split ) cls = name->Split ( split );
- else cls = name;
+ if (split)
+ {
+ cls = name->Split(split);
+ }
+ else
+ {
+ cls = name;
+ }
Handle(TCollection_HAsciiString) str = new TCollection_HAsciiString("TCollection");
- Standard_Integer ind =name->Location(str,1,name->Length());
- if(ind)
- name = new TCollection_HAsciiString ( "Interface_" );
+ Standard_Integer ind = name->Location(str, 1, name->Length());
+ if (ind)
+ {
+ name = new TCollection_HAsciiString("Interface_");
+ }
// generate name
- if ( type->IsStandard() || ! split ) {
- name = new TCollection_HAsciiString ( "TColStd_" );
+ if (type->IsStandard() || !split)
+ {
+ name = new TCollection_HAsciiString("TColStd_");
+ }
+ if (type == myType)
+ {
+ name->AssignCat("HArray1Of");
+ }
+ else
+ {
+ name->AssignCat("HArray2Of");
}
- if ( type == myType ) name->AssignCat ( "HArray1Of" );
- else name->AssignCat ( "HArray2Of" );
- name->AssignCat ( cls );
+ name->AssignCat(cls);
return name;
}
//purpose :
//=======================================================================
-Standard_Boolean Express_ComplexType::Use (const Handle(TCollection_HAsciiString) &pack,
- const Standard_Boolean defer) const
+Standard_Boolean Express_ComplexType::Use(
+ const Handle(TCollection_HAsciiString) &pack,
+ const Standard_Boolean defer) const
{
-
return myType->Use ( pack, defer );
}
#define _Express_ComplexType_HeaderFile
#include <Standard_Type.hxx>
-
#include <Express_Type.hxx>
-
class TCollection_HAsciiString;
-
//! Base class for complex types (ARRAY, LIST, BAG, SET)
//! in EXPRESS schema
//! Stores type of elements and
{
public:
-
//! Creates an object and initializes fields
- Standard_EXPORT Express_ComplexType(const Standard_Integer imin, const Standard_Integer imax, const Handle(Express_Type)& type);
+ Standard_EXPORT Express_ComplexType(
+ const Standard_Integer imin,
+ const Standard_Integer imax,
+ const Handle(Express_Type)& type);
//! Returns type of complex type items
Standard_EXPORT const Handle(Express_Type)& Type() const;
//! Declares type as used by some item being generated.
//! Calls Use() for type of elements
- Standard_EXPORT virtual Standard_Boolean Use (const Handle(TCollection_HAsciiString)& pack, const Standard_Boolean defer = Standard_False) const Standard_OVERRIDE;
-
-
-
+ Standard_EXPORT virtual Standard_Boolean Use(
+ const Handle(TCollection_HAsciiString)& pack,
+ const Standard_Boolean defer = Standard_False) 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
#include <Express_Item.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_AsciiString,Handle(Express_Item),TCollection_AsciiString> Express_DataMapOfAsciiStringItem;
-typedef NCollection_DataMap<TCollection_AsciiString,Handle(Express_Item),TCollection_AsciiString>::Iterator Express_DataMapIteratorOfDataMapOfAsciiStringItem;
+typedef NCollection_DataMap<TCollection_AsciiString,Handle(Express_Item),
+ TCollection_AsciiString> Express_DataMapOfAsciiStringItem;
+typedef NCollection_DataMap<TCollection_AsciiString,Handle(Express_Item),
+ TCollection_AsciiString>::Iterator Express_DataMapIteratorOfDataMapOfAsciiStringItem;
#endif
//purpose :
//=======================================================================
-Express_Entity::Express_Entity (const Standard_CString name,
- const Handle(TColStd_HSequenceOfHAsciiString) &inherit,
- const Handle(Express_HSequenceOfField) &flds)
- : Express_Item(name), mySupers(inherit), myFields(flds)
-
+Express_Entity::Express_Entity(
+ const Standard_CString name,
+ const Handle(TColStd_HSequenceOfHAsciiString) &inherit,
+ const Handle(Express_HSequenceOfField) &flds)
+ : Express_Item(name), mySupers(inherit), myFields(flds)
{
// make empty lists to avoid checking every time
myInherit = new Express_HSequenceOfEntity;
- if ( mySupers.IsNull() ) mySupers = new TColStd_HSequenceOfHAsciiString;
- if ( myFields.IsNull() ) myFields = new Express_HSequenceOfField;
+ if (mySupers.IsNull())
+ {
+ mySupers = new TColStd_HSequenceOfHAsciiString;
+ }
+ if (myFields.IsNull())
+ {
+ myFields = new Express_HSequenceOfField;
+ }
myisAbstract = Standard_False;
}
Standard_Integer Express_Entity::NbFields (const Standard_Boolean inherited) const
{
Standard_Integer num = myFields->Length();
- if ( inherited ) {
- for ( Standard_Integer i=1; i <= myInherit->Length(); i++ )
- num += myInherit->Value(i)->NbFields ( inherited );
+ if (inherited)
+ {
+ for (Standard_Integer i = 1; i <= myInherit->Length(); i++)
+ {
+ num += myInherit->Value(i)->NbFields(inherited);
+ }
}
return num;
}
//purpose :
//=======================================================================
-static void WriteGetMethod (Standard_OStream &os,
- const Handle(TCollection_HAsciiString) name,
- const Handle(TCollection_HAsciiString) field,
- const Handle(TCollection_HAsciiString) type,
- const Standard_Boolean isHandle,
- const Standard_Boolean /*isSimple*/)
+static void WriteGetMethod(
+ Standard_OStream &os,
+ const Handle(TCollection_HAsciiString) name,
+ const Handle(TCollection_HAsciiString) field,
+ const Handle(TCollection_HAsciiString) type,
+ const Standard_Boolean isHandle,
+ const Standard_Boolean /*isSimple*/)
{
Handle(TCollection_HAsciiString) method = field;//new TCollection_HAsciiString ( "Get" );
-// method->AssignCat ( field );
+ //method->AssignCat ( field );
Express::WriteMethodStamp ( os, method );
os << ( isHandle ? "Handle(" : "" ) << type->ToCString() << ( isHandle ? ") " : " " ) <<
name->ToCString() << "::" << method->ToCString() << " () const" << std::endl;
//purpose :
//=======================================================================
-static void WriteSetMethod (Standard_OStream &os,
- const Handle(TCollection_HAsciiString) name,
- const Handle(TCollection_HAsciiString) field,
- const Handle(TCollection_HAsciiString) type,
- const Standard_Boolean isHandle,
- const Standard_Boolean isSimple)
+static void WriteSetMethod(
+ Standard_OStream &os,
+ const Handle(TCollection_HAsciiString) name,
+ const Handle(TCollection_HAsciiString) field,
+ const Handle(TCollection_HAsciiString) type,
+ const Standard_Boolean isHandle,
+ const Standard_Boolean isSimple)
{
- Handle(TCollection_HAsciiString) method = new TCollection_HAsciiString ( "Set" );
- method->AssignCat ( field );
- Express::WriteMethodStamp ( os, method );
+ Handle(TCollection_HAsciiString) method = new TCollection_HAsciiString("Set");
+ method->AssignCat(field);
+ Express::WriteMethodStamp(os, method);
os << "void " << name->ToCString() << "::" << method->ToCString() << " (const " <<
- ( isHandle ? "Handle(" : "" ) << type->ToCString() << ( isHandle ? ")" : "" ) <<
- ( isSimple ? "" : "&" ) << " the" << field->ToCString() << ")" << std::endl;
+ (isHandle ? "Handle(" : "") << type->ToCString() << (isHandle ? ")" : "") <<
+ (isSimple ? "" : "&") << " the" << field->ToCString() << ")" << std::endl;
os << "{" << std::endl << " my" << field->ToCString() << " = the" << field->ToCString() << ";\n}" << std::endl;
}
static inline void WriteSpaces (Standard_OStream &os, Standard_Integer num)
{
- for ( Standard_Integer i=0; i < num; i++ ) os << " ";
+ for (Standard_Integer i = 0; i < num; i++) os << " ";
}
//=======================================================================
Express::WriteFileStamp ( os );
Handle(TCollection_HAsciiString) InheritName = new TCollection_HAsciiString("Standard_Transient");
- if (myInherit->Length() > 0) { // first inherited class will be actually inherited
+ if (myInherit->Length() > 0)
+ { // first inherited class will be actually inherited
Handle(Express_Entity) it = myInherit->Value(1);
it->Use(GetPackageName());
InheritName = it->CPPName();
- if (myInherit->Length() > 1) {
+ if (myInherit->Length() > 1)
+ {
std::cout << "Warning: ENTITY " << Name()->ToCString() << " defined with multiple inheritance;" << std::endl;
std::cout << "Warning: only first base class is actually inherited, others are made fields" << std::endl;
}
os << std::endl;
// write fields section
- if ( myInherit->Length() >1 || myFields->Length() >0 ) {
+ if ( myInherit->Length() >1 || myFields->Length() >0 )
+ {
os << "private:" << std::endl;
- for (Standard_Integer i = 2; i <= myInherit->Length(); i++) {
+ for (Standard_Integer i = 2; i <= myInherit->Length(); i++)
+ {
Handle(Express_Entity) it = myInherit->Value(i);
Handle(TCollection_HAsciiString) name = it->Name();
os << " Handle(" << it->CPPName()->ToCString() << ") my" << name->ToCString() << "; //!< supertype" << std::endl;
}
- for (Standard_Integer i = 1; i <= myFields->Length(); i++) {
+ for (Standard_Integer i = 1; i <= myFields->Length(); i++)
+ {
Handle(Express_Field) field = myFields->Value(i);
if (field->Type()->IsHandle())
+ {
os << " Handle(" << field->Type()->CPPName()->ToCString() << ") my" << field->Name()->ToCString() << ";";
+ }
else
+ {
os << " " << field->Type()->CPPName()->ToCString() << " my" << field->Name()->ToCString() << ";";
- if (field->IsOptional()) os << " //!< optional";
+ }
+ if (field->IsOptional())
+ {
+ os << " //!< optional";
+ }
os << std::endl;
}
// optional fields: flag 'is field set'
- for (Standard_Integer i = 1; i <= myFields->Length(); i++) {
+ for (Standard_Integer i = 1; i <= myFields->Length(); i++)
+ {
Handle(Express_Field) field = myFields->Value(i);
- if (!field->IsOptional()) continue;
+ if (!field->IsOptional())
+ {
+ continue;
+ }
os << " Standard_Boolean def" << field->Name()->ToCString() << "; //!< flag \"is " <<
field->Name()->ToCString() << " defined\"" << std::endl;
}
Express::WriteMethodStamp ( os, CPPname );
os << CPPname->ToCString() << "::" << CPPname->ToCString() << " ()" << std::endl;
os << "{" << std::endl;
- for (Standard_Integer i=1; i <= myFields->Length(); i++ ) {
+ for (Standard_Integer i=1; i <= myFields->Length(); i++ )
+ {
Handle(Express_Field) field = myFields->Value ( i );
if ( field->IsOptional() ) os << " def" << field->Name()->ToCString() << " = Standard_False;" << std::endl;
}
os << "}" << std::endl;
// write method Init()
- if ( myInherit->Length() >1 || myFields->Length() >0 ) {
+ if ( myInherit->Length() >1 || myFields->Length() >0 )
+ {
Express::WriteMethodStamp ( os, new TCollection_HAsciiString ( "Init" ) );
os << "void " << CPPname->ToCString() << "::Init (";
MakeInit ( os, 13 + CPPname->Length(), Standard_True, 1 );
}
// write "methods" section
- for (Standard_Integer i=2; i <= myInherit->Length(); i++ ) {
+ for (Standard_Integer i=2; i <= myInherit->Length(); i++ )
+ {
Handle(Express_Entity) it = myInherit->Value(i);
WriteGetMethod ( os, CPPname, it->Name(), it->CPPName(), Standard_True, Standard_False );
WriteSetMethod ( os, CPPname, it->Name(), it->CPPName(), Standard_True, Standard_False );
}
- for (Standard_Integer i=1; i <= myFields->Length(); i++ ) {
+ for (Standard_Integer i=1; i <= myFields->Length(); i++ )
+ {
Handle(Express_Field) field = myFields->Value ( i );
Handle(Express_Type) type = field->Type();
WriteGetMethod ( os, CPPname, field->Name(), type->CPPName(), type->IsHandle(), type->IsSimple() );
WriteSetMethod ( os, CPPname, field->Name(), type->CPPName(), type->IsHandle(), type->IsSimple() );
- if ( ! field->IsOptional() ) continue;
+ if (!field->IsOptional())
+ {
+ continue;
+ }
Handle(TCollection_HAsciiString) method = new TCollection_HAsciiString ( "Has" );
method->AssignCat ( field->Name() );
Express::WriteMethodStamp ( os, method );
os << " Standard_EXPORT " << RWCPPName->ToCString() << "();" << std::endl << std::endl;
// read step
- os << " Standard_EXPORT void ReadStep(const Handle(StepData_StepReaderData)& data, const Standard_Integer num, Handle(Interface_Check)& ach, const Handle(" <<
+ os << " Standard_EXPORT void ReadStep(const Handle(StepData_StepReaderData)& data," <<
+ " const Standard_Integer num, Handle(Interface_Check)& ach, const Handle(" <<
CPPName()->ToCString() << ")& ent) const;" << std::endl << std::endl;
// write step
os << RWCPPName->ToCString() << "::" << RWCPPName->ToCString() << "() {}" << std::endl << std::endl;
// write method ReadStep
- Express::WriteMethodStamp ( os, new TCollection_HAsciiString ( "ReadStep" ) );
+ Express::WriteMethodStamp(os, new TCollection_HAsciiString("ReadStep"));
os << "void " << RWCPPName->ToCString() << "::ReadStep (const Handle(StepData_StepReaderData)& data," << std::endl;
WriteSpaces ( os, 17 + RWCPPName->Length() );
os << "const Standard_Integer num," << std::endl;
Standard_Integer nbFld = NbFields ( Standard_True );
os << " // Check number of parameters" << std::endl;
- os << " if ( ! data->CheckNbParams(num," << nbFld << ",ach,\"" <<
- Express::ToStepName ( Name() )->ToCString() << "\") ) return;" << std::endl;
- WriteRWReadCode ( os, 1, Standard_True ); // write code for reading inherited and own fields
+ os << " if ( ! data->CheckNbParams(num," << nbFld << ",ach,\"" <<
+ Express::ToStepName(Name())->ToCString() << "\") ) return;" << std::endl;
+ WriteRWReadCode(os, 1, Standard_True); // write code for reading inherited and own fields
os << std::endl;
os << " // Initialize entity" << std::endl;
os << " ent->Init(";
os << "const Handle(" << CPPname->ToCString() << ")& ent) const" << std::endl;
os << "{" << std::endl;
- WriteRWWriteCode ( os, 0, Standard_True ); // write code for writing inherited and own fields
+ WriteRWWriteCode(os, 0, Standard_True); // write code for writing inherited and own fields
os << "}" << std::endl;
// write method Share
os << "{" << std::endl;
WriteRWShareCode ( os, 1, Standard_True ); // write code for filling graph of references
os << "}" << std::endl;
- if(CheckFlag()) {
- Express::WriteMethodStamp ( os, new TCollection_HAsciiString ( "Check" ) );
+ if(CheckFlag())
+ {
+ Express::WriteMethodStamp(os, new TCollection_HAsciiString("Check"));
os << "void " << RWCPPName->ToCString() << "::Check(const Handle(Standard_Transient)& entt," << std::endl;
WriteSpaces ( os, 18 + RWCPPName->Length() );
os << "const Interface_ShareTool& shares,"<< std::endl;
os<<" Handle("<<CPPname->ToCString() << ") ent = Handle("<<CPPname->ToCString() <<")::DownCast(entt);"<< std::endl;
os << "}" << std::endl;
}
- if(FillSharedFlag()) {
- Express::WriteMethodStamp ( os, new TCollection_HAsciiString ( "FillShared" ) );
+ if(FillSharedFlag())
+ {
+ Express::WriteMethodStamp(os, new TCollection_HAsciiString("FillShared"));
os << "void " << RWCPPName->ToCString() << "::Share(const Handle(Interface_InterfaceModel)& model," << std::endl;
- WriteSpaces ( os, 18 + RWCPPName->Length() );
- os << "const Handle(Standard_Transient)& entt,"<< std::endl;
- WriteSpaces ( os, 18 + RWCPPName->Length() );
- os << "Interface_EntityIterator& iter) const"<< std::endl;
+ WriteSpaces(os, 18 + RWCPPName->Length());
+ os << "const Handle(Standard_Transient)& entt," << std::endl;
+ WriteSpaces(os, 18 + RWCPPName->Length());
+ os << "Interface_EntityIterator& iter) const" << std::endl;
os << "{" << std::endl;
//DownCast entity to it's type
- os<<" Handle("<<CPPname->ToCString() << ") ent = Handle("<<CPPname->ToCString() <<")::DownCast(entt)"<< std::endl;
+ os << " Handle(" << CPPname->ToCString() << ") ent = Handle(" << CPPname->ToCString() << ")::DownCast(entt)" << std::endl;
os << "}" << std::endl;
}
TCollection_AsciiString regDir = "Registration";
OSD_Path path_reg(regDir);
OSD_Directory dir_reg(regDir);
- dir_reg.Build ( prot );
+ dir_reg.Build(prot);
regDir += "/";
-
+
TCollection_AsciiString packname_inc = "inc.txt";
TCollection_AsciiString packname_rwinc = "rwinc.txt";
// write file with includes
os.open(regDir.Cat(packname_inc).ToCString(), std::ios::app);
- os <<"#include <" << CPPName()->ToCString() << ".hxx>" << std::endl;
+ os << "#include <" << CPPName()->ToCString() << ".hxx>" << std::endl;
os.close();
// write file with RW includes
os.open(regDir.Cat(packname_rwinc).ToCString(), std::ios::app);
os.close();
// generate data for entity registration
- if (anIndex > 0) {
+ if (anIndex > 0)
+ {
// StepAP214_Protocol.cxx
TCollection_AsciiString packname_protocol = "protocol.txt";
os.open(regDir.Cat(packname_protocol).ToCString(), std::ios::app);
TCollection_AsciiString packname_reco = "reco.txt";
os.open(regDir.Cat(packname_reco).ToCString(), std::ios::app);
os << " static TCollection_AsciiString Reco_" << Name()->ToCString() << "(\""
- << recoName->ToCString() << "\");" << std::endl;
+ << recoName->ToCString() << "\");" << std::endl;
os.close();
//type bind
TCollection_AsciiString packname_typebind = "typebind.txt";
//purpose :
//=======================================================================
-Standard_Boolean Express_Entity::WriteIncludes (Standard_OStream &os,
- DataMapOfStringInteger &dict) const
+Standard_Boolean Express_Entity::WriteIncludes(
+ Standard_OStream &os,
+ DataMapOfStringInteger &dict) const
{
- for ( Standard_Integer i=1; i <= myInherit->Length(); i++ ) {
+ for (Standard_Integer i = 1; i <= myInherit->Length(); i++)
+ {
Handle(Express_Entity) it = myInherit->Value(i);
- it->WriteIncludes ( os, dict );
- if ( i <= 1 ) continue;
+ it->WriteIncludes(os, dict);
+ if (i <= 1)
+ {
+ continue;
+ }
- if ( dict.IsBound ( it->CPPName()->String() ) ) continue; // avoid duplicating
- dict.Bind ( it->CPPName()->String(), 1 );
- it->Use ( GetPackageName() );
+ if (dict.IsBound(it->CPPName()->String()))
+ {
+ continue; // avoid duplicating
+ }
+ dict.Bind(it->CPPName()->String(), 1);
+ it->Use(GetPackageName());
os << "#include <" << it->CPPName()->ToCString() << ".hxx>" << std::endl;
}
- for (Standard_Integer i=1; i <= myFields->Length(); i++ ) {
+ for (Standard_Integer i = 1; i <= myFields->Length(); i++)
+ {
Handle(Express_Type) type = myFields->Value(i)->Type();
- if ( dict.IsBound ( type->CPPName()->String() ) ) continue; // avoid duplicating
- dict.Bind ( type->CPPName()->String(), 1 );
- type->Use ( GetPackageName() );
- if ( type->IsStandard() ) continue;
+ if (dict.IsBound(type->CPPName()->String()))
+ {
+ continue; // avoid duplicating
+ }
+ dict.Bind(type->CPPName()->String(), 1);
+ type->Use(GetPackageName());
+ if (type->IsStandard())
+ {
+ continue;
+ }
os << "#include <" << type->CPPName()->ToCString() << ".hxx>" << std::endl;
}
return Standard_True;
void Express_Entity::WriteRWInclude (Standard_OStream &os, DataMapOfStringInteger &dict) const
{
- for ( Standard_Integer i=1; i <= myInherit->Length(); i++ ) {
+ for (Standard_Integer i = 1; i <= myInherit->Length(); i++)
+ {
Handle(Express_Entity) it = myInherit->Value(i);
- if ( i >1 ) { // include HXX for base classes which are implemented as fields
+ if (i > 1)
+ { // include HXX for base classes which are implemented as fields
os << "#include <" << it->CPPName()->ToCString() << ".hxx>" << std::endl;
}
- it->WriteRWInclude ( os, dict );
+ it->WriteRWInclude(os, dict);
}
- for (Standard_Integer i=1; i <= myFields->Length(); i++ ) {
+ for (Standard_Integer i = 1; i <= myFields->Length(); i++)
+ {
Handle(Express_Type) type = myFields->Value(i)->Type();
- for ( Standard_Integer deep=0; deep < 10; deep++ ) {
- if ( dict.IsBound ( type->CPPName()->String() ) ) break; // avoid duplicating
- dict.Bind ( type->CPPName()->String(), 1 );
+ for (Standard_Integer deep = 0; deep < 10; deep++)
+ {
+ if (dict.IsBound(type->CPPName()->String()))
+ {
+ break; // avoid duplicating
+ }
+ dict.Bind(type->CPPName()->String(), 1);
os << "#include <" << type->CPPName()->ToCString() << ".hxx>" << std::endl;
-
- Handle(Express_ComplexType) complex = Handle(Express_ComplexType)::DownCast ( type );
+
+ Handle(Express_ComplexType) complex = Handle(Express_ComplexType)::DownCast(type);
if (complex.IsNull())
+ {
break;
+ }
type = complex->Type();
}
}
}
//=======================================================================
-//function : WriteRWReadField
-//purpose :
+//function : typeToSTEPName
+//purpose : auxilary for WriteRWReadField
//=======================================================================
-static Handle(TCollection_HAsciiString) TypeToSTEPName (const Handle(Express_Type) &type)
+static Handle(TCollection_HAsciiString) typeToSTEPName (const Handle(Express_Type) &type)
{
Handle(TCollection_HAsciiString) cppname = type->CPPName();
Handle(TCollection_HAsciiString) cls = cppname->Token ( "_", 2 );
- if ( cls->Length() <1 ) cls = cppname;
- return Express::ToStepName ( cls );
+ if (cls->Length() < 1)
+ {
+ cls = cppname;
+ }
+ return Express::ToStepName(cls);
}
-static void WriteRWReadField (Standard_OStream &os,
- const Standard_CString index,
- const Standard_CString STEPName,
- const Standard_CString varname,
- const Handle(Express_Type) &vartype,
- const Standard_Integer lev,
- const Standard_Boolean optional)
+//=======================================================================
+//function : WriteRWReadField
+//purpose :
+//=======================================================================
+
+static void WriteRWReadField(
+ Standard_OStream &os,
+ const Standard_CString index,
+ const Standard_CString STEPName,
+ const Standard_CString varname,
+ const Handle(Express_Type) &vartype,
+ const Standard_Integer lev,
+ const Standard_Boolean optional)
{
// indent
TCollection_AsciiString shift ( " " );
Standard_Integer level = 0;
- for (; level < lev; level++ ) shift += " ";
+ for (; level < lev; level++)
+ {
+ shift += " ";
+ }
level += 2;
// name of variable identifying number of parameter in data
TCollection_AsciiString param ( "num" );
- if ( lev >0 ) param += TCollection_AsciiString ( lev );
+ if (lev > 0)
+ {
+ param += TCollection_AsciiString(lev);
+ }
// decode aliased types
Handle(Express_Type) type = vartype;
- while ( type->IsKind(STANDARD_TYPE(Express_NamedType)) ) {
- Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast ( type );
- if ( ! named->Item()->IsKind(STANDARD_TYPE(Express_Alias)) ) break;
- Handle(Express_Alias) alias = Handle(Express_Alias)::DownCast ( named->Item() );
+ while (type->IsKind(STANDARD_TYPE(Express_NamedType)))
+ {
+ Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast(type);
+ if (!named->Item()->IsKind(STANDARD_TYPE(Express_Alias)))
+ {
+ break;
+ }
+ Handle(Express_Alias) alias = Handle(Express_Alias)::DownCast(named->Item());
type = alias->Type();
}
-
+
// declare variable
- if ( type->IsHandle() ) os << shift << "Handle(" << type->CPPName()->ToCString() << ") a";
- else os << shift << type->CPPName()->ToCString() << " a";
+ if (type->IsHandle())
+ {
+ os << shift << "Handle(" << type->CPPName()->ToCString() << ") a";
+ }
+ else
+ {
+ os << shift << type->CPPName()->ToCString() << " a";
+ }
os << varname << ";" << std::endl;
- if ( optional ) {
+ if (optional)
+ {
os << shift << "Standard_Boolean has" << varname << " = Standard_True;" << std::endl;
os << shift << "if ( data->IsParamDefined (" << param << "," << index << ") ) {" << std::endl;
shift += " ";
}
// read variable depending on its type
- if ( type->IsKind(STANDARD_TYPE(Express_NamedType)) ) {
- Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast ( type );
- if ( named->Item()->IsKind(STANDARD_TYPE(Express_Entity)) ) {
+ if (type->IsKind(STANDARD_TYPE(Express_NamedType)))
+ {
+ Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast(type);
+ if (named->Item()->IsKind(STANDARD_TYPE(Express_Entity)))
+ {
os << shift << "data->ReadEntity (" << param << ", " << index << ", \"" << STEPName <<
- "\", ach, STANDARD_TYPE(" << named->CPPName()->ToCString() << "), a" <<
- varname << ");" << std::endl;
+ "\", ach, STANDARD_TYPE(" << named->CPPName()->ToCString() << "), a" <<
+ varname << ");" << std::endl;
}
- else if ( named->Item()->IsKind(STANDARD_TYPE(Express_Select)) ) {
+ else if (named->Item()->IsKind(STANDARD_TYPE(Express_Select)))
+ {
os << shift << "data->ReadEntity (" << param << ", " << index << ", \"" << STEPName <<
- "\", ach, a" << varname << ");" << std::endl;
+ "\", ach, a" << varname << ");" << std::endl;
}
- else if ( named->Item()->IsKind(STANDARD_TYPE(Express_Enum)) ) {
- os << shift << "if (data->ParamType (" << param << ", " <<
- index << ") == Interface_ParamEnum) {" << std::endl;
- os << shift << " Standard_CString text = data->ParamCValue(" <<
- param << ", " << index << ");" << std::endl;
- Handle(Express_Enum) en = Handle(Express_Enum)::DownCast ( named->Item() );
+ else if (named->Item()->IsKind(STANDARD_TYPE(Express_Enum)))
+ {
+ os << shift << "if (data->ParamType (" << param << ", " <<
+ index << ") == Interface_ParamEnum) {" << std::endl;
+ os << shift << " Standard_CString text = data->ParamCValue(" <<
+ param << ", " << index << ");" << std::endl;
+ Handle(Express_Enum) en = Handle(Express_Enum)::DownCast(named->Item());
Handle(TCollection_HAsciiString) prefix = Express::EnumPrefix(en->Name());
Handle(TColStd_HSequenceOfHAsciiString) names = en->Names();
TCollection_AsciiString enpack = en->GetPackageName()->String();
- for ( Standard_Integer i=1; i <= names->Length(); i++ ) {
- Handle(TCollection_HAsciiString) ename = Express::ToStepName ( names->Value(i) );
- ename->UpperCase();
- os << shift << ( i==1 ? " if " : " else if" ) <<
- " (strcmp(text, \"." << ename->ToCString() << ".\")) a" <<
- varname << " = " << enpack.ToCString() << "_" << prefix->ToCString()<<
- names->Value(i)->ToCString() << ";" << std::endl;
+ for (Standard_Integer i = 1; i <= names->Length(); i++)
+ {
+ Handle(TCollection_HAsciiString) ename = Express::ToStepName(names->Value(i));
+ ename->UpperCase();
+ os << shift << (i == 1 ? " if " : " else if") <<
+ " (strcmp(text, \"." << ename->ToCString() << ".\")) a" <<
+ varname << " = " << enpack.ToCString() << "_" << prefix->ToCString() <<
+ names->Value(i)->ToCString() << ";" << std::endl;
}
os << shift << " else ach->AddFail(\"Parameter #" << index << " (" <<
- STEPName << ") has not allowed value\");" << std::endl;
+ STEPName << ") has not allowed value\");" << std::endl;
os << shift << "}" << std::endl;
os << shift << "else ach->AddFail(\"Parameter #" << index << " (" <<
- STEPName << ") is not enumeration\");" << std::endl;
-// os << "!!! READING/WRITING ENUM NOT IMPLEMENTED !!!" << std::endl;
-// std::cout << "Warning: Reading/Writing ENUMERATION not yet implemented (" <<
-// STEPName << ", " << varname << ", " << type->CPPName()->ToCString() << ")" << std::endl;
+ STEPName << ") is not enumeration\");" << std::endl;
+ //os << "!!! READING/WRITING ENUM NOT IMPLEMENTED !!!" << std::endl;
+ //std::cout << "Warning: Reading/Writing ENUMERATION not yet implemented (" <<
+ //STEPName << ", " << varname << ", " << type->CPPName()->ToCString() << ")" << std::endl;
}
}
- else if ( type->IsKind(STANDARD_TYPE(Express_ComplexType)) ) {
-
- Handle(Express_ComplexType) complex = Handle(Express_ComplexType)::DownCast ( type );
+ else if (type->IsKind(STANDARD_TYPE(Express_ComplexType)))
+ {
+ Handle(Express_ComplexType) complex = Handle(Express_ComplexType)::DownCast(type);
os << shift << "Standard_Integer sub" << index << " = 0;" << std::endl;
- os << shift << "if ( data->ReadSubList (" << param << ", " << index << ", \"" <<
- STEPName << "\", ach, sub" << index << ") ) {" << std::endl;
+ os << shift << "if ( data->ReadSubList (" << param << ", " << index << ", \"" <<
+ STEPName << "\", ach, sub" << index << ") ) {" << std::endl;
os << shift << " Standard_Integer nb" << lev << " = data->NbParams(sub" << index << ");" << std::endl;
TCollection_AsciiString iter = lev;
- iter.Prepend ( "i" );
+ iter.Prepend("i");
TCollection_AsciiString var = lev;
var.Prepend("nIt");
- if ( complex->Type()->IsKind(STANDARD_TYPE(Express_ComplexType)) ) { // array 2
- Handle(Express_ComplexType) complex2 = Handle(Express_ComplexType)::DownCast ( complex->Type() );
+ if (complex->Type()->IsKind(STANDARD_TYPE(Express_ComplexType)))
+ { // array 2
+ Handle(Express_ComplexType) complex2 = Handle(Express_ComplexType)::DownCast(complex->Type());
TCollection_AsciiString jter = lev;
- jter.Prepend ( "j" );
- os << shift << " Standard_Integer nbj" << lev << " = data->NbParams(data->ParamNumber(sub" << index << ",1));" << std::endl;
- os << shift << " a" << varname << " = new " << type->CPPName()->ToCString() << " (1, nb" << lev << ", 1, nbj" << lev << ");" << std::endl;
- os << shift << " for ( Standard_Integer " << iter << "=1; " << iter << " <= nb" << lev << "; " << iter << "++ ) {" << std::endl;
+ jter.Prepend("j");
+ os << shift << " Standard_Integer nbj" << lev <<
+ " = data->NbParams(data->ParamNumber(sub" << index << ",1));" << std::endl;
+ os << shift << " a" << varname << " = new " << type->CPPName()->ToCString() <<
+ " (1, nb" << lev << ", 1, nbj" << lev << ");" << std::endl;
+ os << shift << " for ( Standard_Integer " << iter << "=1; " << iter << " <= nb" << lev <<
+ "; " << iter << "++ ) {" << std::endl;
os << shift << " Standard_Integer subj" << index << " = 0;" << std::endl;
- os << shift << " if ( data->ReadSubList (sub" << index << ", " << iter << ", \"sub-part(" <<
- STEPName << ")\", ach, subj" << index << ") ) {" << std::endl;
- os << shift << " Standard_Integer num" << level+2 << " = subj" << index << ";" << std::endl;
- os << shift << " for ( Standard_Integer " << jter << "=1; " << jter << " <= nbj" << lev << "; " << jter << "++ ) {" << std::endl;
- Handle(TCollection_HAsciiString) subName = TypeToSTEPName ( complex2->Type() );
- WriteRWReadField (os, jter.ToCString(), subName->ToCString(), var.ToCString(), complex2->Type(), level+2, Standard_False );
- os << shift << " a" << varname << "->SetValue(" << iter << "," << jter << ", a" << var << ");" << std::endl;
+ os << shift << " if ( data->ReadSubList (sub" << index << ", " << iter << ", \"sub-part(" <<
+ STEPName << ")\", ach, subj" << index << ") ) {" << std::endl;
+ os << shift << " Standard_Integer num" << level + 2 << " = subj" << index << ";" << std::endl;
+ os << shift << " for ( Standard_Integer " << jter << "=1; " << jter << " <= nbj" << lev <<
+ "; " << jter << "++ ) {" << std::endl;
+ Handle(TCollection_HAsciiString) subName = typeToSTEPName(complex2->Type());
+ WriteRWReadField(os, jter.ToCString(), subName->ToCString(), var.ToCString(),
+ complex2->Type(), level + 2, Standard_False);
+ os << shift << " a" << varname << "->SetValue(" << iter << "," <<
+ jter << ", a" << var << ");" << std::endl;
os << shift << " }" << std::endl;
os << shift << " }" << std::endl;
- }
- else { // simple array
- os << shift << " a" << varname << " = new " << type->CPPName()->ToCString() << " (1, nb" << lev << ");" << std::endl;
+ }
+ else
+ { // simple array
+ os << shift << " a" << varname << " = new " << type->CPPName()->ToCString() <<
+ " (1, nb" << lev << ");" << std::endl;
os << shift << " Standard_Integer num" << level << " = sub" << index << ";" << std::endl;
- os << shift << " for ( Standard_Integer " << iter << "=1; " << iter << " <= nb" << lev << "; " << iter << "++ ) {" << std::endl;
- Handle(TCollection_HAsciiString) subName = TypeToSTEPName ( complex->Type() );
- WriteRWReadField (os, iter.ToCString(), subName->ToCString(), var.ToCString(), complex->Type(), level, Standard_False );
+ os << shift << " for ( Standard_Integer " << iter << "=1; " << iter << " <= nb" << lev <<
+ "; " << iter << "++ ) {" << std::endl;
+ Handle(TCollection_HAsciiString) subName = typeToSTEPName(complex->Type());
+ WriteRWReadField(os, iter.ToCString(), subName->ToCString(), var.ToCString(),
+ complex->Type(), level, Standard_False);
os << shift << " a" << varname << "->SetValue(" << iter << ", a" << var << ");" << std::endl;
}
os << shift << " }" << std::endl;
os << shift << "}" << std::endl;
}
- else if ( type->IsKind(STANDARD_TYPE(Express_String)) ) {
+ else if (type->IsKind(STANDARD_TYPE(Express_String)))
+ {
os << shift << "data->ReadString (" << param << ", " << index << ", \"" << STEPName <<
- "\", ach, a" << varname << ");" << std::endl;
+ "\", ach, a" << varname << ");" << std::endl;
}
- else if ( type->IsKind(STANDARD_TYPE(Express_Logical)) ) {
+ else if (type->IsKind(STANDARD_TYPE(Express_Logical)))
+ {
os << shift << "data->ReadLogical (" << param << ", " << index << ", \"" << STEPName <<
- "\", ach, a" << varname << ");" << std::endl;
+ "\", ach, a" << varname << ");" << std::endl;
}
- else if ( type->IsKind(STANDARD_TYPE(Express_Boolean)) ) {
+ else if (type->IsKind(STANDARD_TYPE(Express_Boolean)))
+ {
os << shift << "data->ReadBoolean (" << param << ", " << index << ", \"" << STEPName <<
- "\", ach, a" << varname << ");" << std::endl;
+ "\", ach, a" << varname << ");" << std::endl;
}
- else if ( type->IsKind(STANDARD_TYPE(Express_Number)) ||
- type->IsKind(STANDARD_TYPE(Express_Integer)) ) {
+ else if (type->IsKind(STANDARD_TYPE(Express_Number)) || type->IsKind(STANDARD_TYPE(Express_Integer)))
+ {
os << shift << "data->ReadInteger (" << param << ", " << index << ", \"" << STEPName <<
- "\", ach, a" << varname << ");" << std::endl;
+ "\", ach, a" << varname << ");" << std::endl;
}
- else if ( type->IsKind(STANDARD_TYPE(Express_Real)) ) {
+ else if (type->IsKind(STANDARD_TYPE(Express_Real)))
+ {
os << shift << "data->ReadReal (" << param << ", " << index << ", \"" << STEPName <<
- "\", ach, a" << varname << ");" << std::endl;
+ "\", ach, a" << varname << ");" << std::endl;
}
- if ( optional ) {
- shift.Remove ( 1, 2 );
+ if (optional)
+ {
+ shift.Remove(1, 2);
os << shift << "}" << std::endl;
os << shift << "else {" << std::endl;
os << shift << " has" << varname << " = Standard_False;" << std::endl;
os << shift << " a" << varname;
if (type->IsHandle())
+ {
os << ".Nullify();";
+ }
else if (type->IsStandard())
+ {
os << " = 0;";
+ }
else
+ {
os << " = " << type->CPPName()->ToCString() << "();";
+ }
os << std::endl;
os << shift << "}" << std::endl;
}
Standard_Integer num = start;
// write code for reading inherited fields
- for ( Standard_Integer i=1; i <= myInherit->Length(); i++ )
- num = myInherit->Value(i)->WriteRWReadCode ( os, num, Standard_False );
+ for (Standard_Integer i = 1; i <= myInherit->Length(); i++)
+ {
+ num = myInherit->Value(i)->WriteRWReadCode(os, num, Standard_False);
+ }
// write code for reading own fields
- if ( myFields->Length() >0 ) {
+ if ( myFields->Length() >0 )
+ {
if ( num >0 ) os << std::endl;
os << " // " << ( own ? "Own" : "Inherited" ) << " fields of " << Name()->ToCString() << std::endl;
}
- for (Standard_Integer i = 1; i <= myFields->Length(); i++) {
+ for (Standard_Integer i = 1; i <= myFields->Length(); i++)
+ {
Handle(Express_Field) field = myFields->Value(i);
Handle(TCollection_HAsciiString) STEPName = Express::ToStepName(field->Name());
- if (!own) STEPName->Prepend(Express::ToStepName(Name()->Cat(".")));
+ if (!own)
+ {
+ STEPName->Prepend(Express::ToStepName(Name()->Cat(".")));
+ }
Handle(TCollection_HAsciiString) varName = new TCollection_HAsciiString(field->Name());
- if (!own) varName->Prepend(Name()->Cat("_"));
-
+ if (!own)
+ {
+ varName->Prepend(Name()->Cat("_"));
+ }
os << std::endl;
WriteRWReadField(os, TCollection_AsciiString(num).ToCString(), STEPName->ToCString(),
varName->ToCString(), field->Type(), 0, field->IsOptional());
//purpose :
//=======================================================================
-static void WriteRWWriteField (Standard_OStream &os,
- const Standard_CString varname,
- const Handle(Express_Type) &vartype,
- const Standard_Integer index,
- const Standard_Integer lev)
+static void WriteRWWriteField(
+ Standard_OStream &os,
+ const Standard_CString varname,
+ const Handle(Express_Type) &vartype,
+ const Standard_Integer index,
+ const Standard_Integer lev)
{
// indent
TCollection_AsciiString shift ( " " );
Standard_Integer level = 0;
- for (; level < lev; level++ ) shift += " ";
+ for (; level < lev; level++)
+ {
+ shift += " ";
+ }
level++;
// decode aliased types
Handle(Express_Type) type = vartype;
- while ( type->IsKind(STANDARD_TYPE(Express_NamedType)) ) {
- Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast ( type );
- if ( ! named->Item()->IsKind(STANDARD_TYPE(Express_Alias)) ) break;
- Handle(Express_Alias) alias = Handle(Express_Alias)::DownCast ( named->Item() );
+ while (type->IsKind(STANDARD_TYPE(Express_NamedType)))
+ {
+ Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast(type);
+ if (!named->Item()->IsKind(STANDARD_TYPE(Express_Alias)))
+ {
+ break;
+ }
+ Handle(Express_Alias) alias = Handle(Express_Alias)::DownCast(named->Item());
type = alias->Type();
}
-
+
// write variable depending on its type
- if ( type->IsKind(STANDARD_TYPE(Express_ComplexType)) ) {
-
- Handle(Express_ComplexType) complex = Handle(Express_ComplexType)::DownCast ( type );
+ if (type->IsKind(STANDARD_TYPE(Express_ComplexType)))
+ {
+ Handle(Express_ComplexType) complex = Handle(Express_ComplexType)::DownCast(type);
type = complex->Type();
- TCollection_AsciiString var ( lev );
- var.Prepend ( "Var" );
+ TCollection_AsciiString var(lev);
+ var.Prepend("Var");
os << shift << "SW.OpenSub();" << std::endl;
os << shift << "for (Standard_Integer i" << index << "=1; i" << index << " <= ";
- if ( type->IsKind(STANDARD_TYPE(Express_ComplexType)) ) { // array 2
- Handle(Express_ComplexType) complex2 = Handle(Express_ComplexType)::DownCast ( type );
+ if (type->IsKind(STANDARD_TYPE(Express_ComplexType)))
+ { // array 2
+ Handle(Express_ComplexType) complex2 = Handle(Express_ComplexType)::DownCast(type);
type = complex2->Type();
os << varname << "->RowLength(); i" << index << "++ ) {" << std::endl;
os << shift << " SW.NewLine(Standard_False);" << std::endl;
os << shift << " SW.OpenSub();" << std::endl;
os << shift << " for (Standard_Integer j" << index << "=1; j" << index << " <= " <<
- varname << "->ColLength(); j" << index << "++ ) {" << std::endl;
- os << shift << " " << ( type->IsHandle() ? " Handle(" : " " ) << type->CPPName()->ToCString() <<
- ( type->IsHandle() ? ") " : " " ) << var.ToCString() << " = " <<
- varname << "->Value(i" << index << ",j" << index << ");" << std::endl;
- WriteRWWriteField (os, var.ToCString(), type, index+1, level+1 );
+ varname << "->ColLength(); j" << index << "++ ) {" << std::endl;
+ os << shift << " " << (type->IsHandle() ? " Handle(" : " ") << type->CPPName()->ToCString() <<
+ (type->IsHandle() ? ") " : " ") << var.ToCString() << " = " <<
+ varname << "->Value(i" << index << ",j" << index << ");" << std::endl;
+ WriteRWWriteField(os, var.ToCString(), type, index + 1, level + 1);
os << shift << " }" << std::endl;
os << shift << " SW.CloseSub();" << std::endl;
- }
- else { // simple array
+ }
+ else
+ { // simple array
os << varname << "->Length(); i" << index << "++ ) {" << std::endl;
- os << shift << ( type->IsHandle() ? " Handle(" : " " ) << type->CPPName()->ToCString() <<
- ( type->IsHandle() ? ") " : " " ) << var.ToCString() << " = " <<
- varname << "->Value(i" << index << ");" << std::endl;
- WriteRWWriteField (os, var.ToCString(), type, index+1, level );
+ os << shift << (type->IsHandle() ? " Handle(" : " ") << type->CPPName()->ToCString() <<
+ (type->IsHandle() ? ") " : " ") << var.ToCString() << " = " <<
+ varname << "->Value(i" << index << ");" << std::endl;
+ WriteRWWriteField(os, var.ToCString(), type, index + 1, level);
}
os << shift << "}" << std::endl;
os << shift << "SW.CloseSub();" << std::endl;
}
- else if ( type->IsKind(STANDARD_TYPE(Express_Boolean)) ) {
+ else if (type->IsKind(STANDARD_TYPE(Express_Boolean)))
+ {
os << shift << "SW.SendBoolean (" << varname << ");" << std::endl;
}
- else if ( type->IsKind(STANDARD_TYPE(Express_Logical)) ) {
+ else if (type->IsKind(STANDARD_TYPE(Express_Logical)))
+ {
os << shift << "SW.SendLogical (" << varname << ");" << std::endl;
}
- else {
- Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast ( type );
- if ( ! named.IsNull() && named->Item()->IsKind(STANDARD_TYPE(Express_Enum)) ) {
- Handle(Express_Enum) en = Handle(Express_Enum)::DownCast ( named->Item() );
+ else
+ {
+ Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast(type);
+ if (!named.IsNull() && named->Item()->IsKind(STANDARD_TYPE(Express_Enum)))
+ {
+ Handle(Express_Enum) en = Handle(Express_Enum)::DownCast(named->Item());
Handle(TCollection_HAsciiString) prefix = Express::EnumPrefix(en->Name());
-
Handle(TColStd_HSequenceOfHAsciiString) names = en->Names();
TCollection_AsciiString enpack = en->GetPackageName()->String();
os << shift << "switch (" << varname << ") {" << std::endl;
- for ( Standard_Integer i=1; i <= names->Length(); i++ ) {
- Handle(TCollection_HAsciiString) ename = Express::ToStepName ( names->Value(i) );
- ename->UpperCase();
- os << shift << " case " << enpack.ToCString() << "_" << prefix->ToCString()<<
- names->Value(i)->ToCString() << ": SW.SendEnum (\"." <<
- ename->ToCString() << ".\"); break;" << std::endl;
+ for (Standard_Integer i = 1; i <= names->Length(); i++)
+ {
+ Handle(TCollection_HAsciiString) ename = Express::ToStepName(names->Value(i));
+ ename->UpperCase();
+ os << shift << " case " << enpack.ToCString() << "_" << prefix->ToCString() <<
+ names->Value(i)->ToCString() << ": SW.SendEnum (\"." <<
+ ename->ToCString() << ".\"); break;" << std::endl;
}
os << shift << "}" << std::endl;
}
- else {
+ else
+ {
os << shift << "SW.Send (" << varname;
- if ( ! named.IsNull() && named->Item()->IsKind(STANDARD_TYPE(Express_Select)) )
- os << ".Value()";
+ if (!named.IsNull() && named->Item()->IsKind(STANDARD_TYPE(Express_Select)))
+ {
+ os << ".Value()";
+ }
os << ");" << std::endl;
}
}
//purpose :
//=======================================================================
-Standard_Integer Express_Entity::WriteRWWriteCode (Standard_OStream &os,
- const Standard_Integer start,
- const Standard_Integer own) const
+Standard_Integer Express_Entity::WriteRWWriteCode(
+ Standard_OStream &os,
+ const Standard_Integer start,
+ const Standard_Integer own) const
{
Standard_Integer num = start;
// write code for writing inherited fields
- for ( Standard_Integer i=1; i <= myInherit->Length(); i++ )
- num = myInherit->Value(i)->WriteRWWriteCode ( os, num, ( i >1 ? -1 : 1 ) );
+ for (Standard_Integer i = 1; i <= myInherit->Length(); i++)
+ {
+ num = myInherit->Value(i)->WriteRWWriteCode(os, num, (i > 1 ? -1 : 1));
+ }
// write code for writing own fields
- if ( myFields->Length() >0 ) {
+ if (myFields->Length() > 0)
+ {
os << std::endl;
os << " // " << ( own == 1 ? "Own" : "Inherited" ) << " fields of " << Name()->ToCString() << std::endl;
}
- for (Standard_Integer i=1; i <= myFields->Length(); i++ ) {
+ for (Standard_Integer i=1; i <= myFields->Length(); i++ )
+ {
Handle(Express_Field) field = myFields->Value(i);
TCollection_AsciiString varName ( field->Name()->String() );
- if ( ! own ) varName.Prepend ( CPPName()->Cat ( "::" )->String() );
- else if ( own ==-1 ) { // inherited base class implemented as field
+ if (!own)
+ {
+ varName.Prepend(CPPName()->Cat("::")->String());
+ }
+ else if (own == -1)
+ { // inherited base class implemented as field
varName.Prepend ( Name()->Cat ( "()->" )->String() );
}
varName.Prepend ( "ent->" );
varName.AssignCat ( "()" );
os << std::endl;
- if ( field->IsOptional() ) {
+ if (field->IsOptional())
+ {
os << " if ( ent->";
- if ( ! own ) os << CPPName()->ToCString() << "::";
- else if ( own ==-1 ) os << Name()->ToCString() << "()->";
+ if (!own)
+ {
+ os << CPPName()->ToCString() << "::";
+ }
+ else if (own == -1)
+ {
+ os << Name()->ToCString() << "()->";
+ }
os << "Has" << field->Name()->ToCString() << "() ) {" << std::endl;
}
- WriteRWWriteField ( os, varName.ToCString(), field->Type(), num, ( field->IsOptional() ? 1 : 0 ) );
- if ( field->IsOptional() ) {
+ WriteRWWriteField(os, varName.ToCString(), field->Type(), num, (field->IsOptional() ? 1 : 0));
+ if (field->IsOptional())
+ {
os << " }\n else SW.SendUndef();" << std::endl;
}
num++;
}
-
+
return num;
}
//purpose :
//=======================================================================
-static Standard_Boolean WriteRWShareField (Standard_OStream &os,
- const Standard_CString varname,
- const Handle(Express_Type) &vartype,
- const Standard_Integer index,
- const Standard_Integer lev)
+static Standard_Boolean WriteRWShareField(
+ Standard_OStream &os,
+ const Standard_CString varname,
+ const Handle(Express_Type) &vartype,
+ const Standard_Integer index,
+ const Standard_Integer lev)
{
// indent
- TCollection_AsciiString shift ( " " );
+ TCollection_AsciiString shift(" ");
Standard_Integer level = 0;
- for (; level < lev; level++ ) shift += " ";
+ for (; level < lev; level++)
+ {
+ shift += " ";
+ }
level++;
// decode aliased types
Handle(Express_Type) type = vartype;
- while ( type->IsKind(STANDARD_TYPE(Express_NamedType)) ) {
- Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast ( type );
- if ( ! named->Item()->IsKind(STANDARD_TYPE(Express_Alias)) ) break;
- Handle(Express_Alias) alias = Handle(Express_Alias)::DownCast ( named->Item() );
+ while (type->IsKind(STANDARD_TYPE(Express_NamedType)))
+ {
+ Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast(type);
+ if (!named->Item()->IsKind(STANDARD_TYPE(Express_Alias)))
+ {
+ break;
+ }
+ Handle(Express_Alias) alias = Handle(Express_Alias)::DownCast(named->Item());
type = alias->Type();
}
-
+
// write variable depending on its type
- if ( type->IsKind(STANDARD_TYPE(Express_ComplexType)) ) {
- Handle(Express_ComplexType) complex = Handle(Express_ComplexType)::DownCast ( type );
+ if (type->IsKind(STANDARD_TYPE(Express_ComplexType)))
+ {
+ Handle(Express_ComplexType) complex = Handle(Express_ComplexType)::DownCast(type);
type = complex->Type();
- TCollection_AsciiString var ( lev );
- var.Prepend ( "Var" );
+ TCollection_AsciiString var(lev);
+ var.Prepend("Var");
std::ostringstream oos;
- if ( ! WriteRWShareField (oos, var.ToCString(), type, index + 1, level ) )
+ if (!WriteRWShareField(oos, var.ToCString(), type, index + 1, level))
+ {
return Standard_False;
- os << shift << "for (Standard_Integer i" << index << "=1; i" << index << " <= " <<
- varname << "->Length(); i" << index << "++ ) {" << std::endl;
- os << shift << ( type->IsHandle() ? " Handle(" : " " ) << type->CPPName()->ToCString() <<
- ( type->IsHandle() ? ") " : " " ) << var.ToCString() << " = " <<
- varname << "->Value(i" << index << ");" << std::endl;
+ }
+ os << shift << "for (Standard_Integer i" << index << "=1; i" << index << " <= " <<
+ varname << "->Length(); i" << index << "++ ) {" << std::endl;
+ os << shift << (type->IsHandle() ? " Handle(" : " ") << type->CPPName()->ToCString() <<
+ (type->IsHandle() ? ") " : " ") << var.ToCString() << " = " <<
+ varname << "->Value(i" << index << ");" << std::endl;
os << oos.str();
os << shift << "}" << std::endl;
return Standard_True;
}
- if ( type->IsKind(STANDARD_TYPE(Express_NamedType)) ) {
- Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast ( type );
- if ( named->Item()->IsKind(STANDARD_TYPE(Express_Entity)) ) {
+ if (type->IsKind(STANDARD_TYPE(Express_NamedType)))
+ {
+ Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast(type);
+ if (named->Item()->IsKind(STANDARD_TYPE(Express_Entity)))
+ {
os << shift << "iter.AddItem (" << varname << ");" << std::endl;
return Standard_True;
}
- if ( named->Item()->IsKind(STANDARD_TYPE(Express_Select)) ) {
+ if (named->Item()->IsKind(STANDARD_TYPE(Express_Select)))
+ {
os << shift << "iter.AddItem (" << varname << ".Value());" << std::endl;
return Standard_True;
}
//purpose :
//=======================================================================
-Standard_Integer Express_Entity::WriteRWShareCode (Standard_OStream &os,
- const Standard_Integer start,
- const Standard_Integer own) const
+Standard_Integer Express_Entity::WriteRWShareCode(
+ Standard_OStream &os,
+ const Standard_Integer start,
+ const Standard_Integer own) const
{
Standard_Integer num = start;
// write code for sharing inherited fields
- for ( Standard_Integer i=1; i <= myInherit->Length(); i++ )
- num = myInherit->Value(i)->WriteRWShareCode ( os, num, ( i >1 ? -1 : Standard_False ) );
+ for (Standard_Integer i = 1; i <= myInherit->Length(); i++)
+ {
+ num = myInherit->Value(i)->WriteRWShareCode(os, num, (i > 1 ? -1 : Standard_False));
+ }
// write code for sharing own fields
- if ( myFields->Length() >0 ) {
+ if ( myFields->Length() >0 )
+ {
os << std::endl;
os << " // " << ( own == 1 ? "Own" : "Inherited" ) << " fields of " << Name()->ToCString() << std::endl;
}
- for (Standard_Integer i=1; i <= myFields->Length(); i++ ) {
+ for (Standard_Integer i=1; i <= myFields->Length(); i++ )
+ {
Handle(Express_Field) field = myFields->Value(i);
TCollection_AsciiString varName ( field->Name()->String() );
- if ( ! own ) varName.Prepend ( CPPName()->Cat ( "::" )->String() );
- else if ( own ==-1 ) { // inherited base class implemented as field
+ if (!own)
+ {
+ varName.Prepend(CPPName()->Cat("::")->String());
+ }
+ else if ( own ==-1 )
+ { // inherited base class implemented as field
varName.Prepend ( Name()->Cat ( "()->" )->String() );
}
varName.Prepend ( "ent->" );
varName.AssignCat ( "()" );
std::ostringstream oos;
- if ( ! WriteRWShareField ( oos, varName.ToCString(), field->Type(), num,
- ( field->IsOptional() ? 1 : 0 ) ) ) continue;
+ if (!WriteRWShareField(oos, varName.ToCString(), field->Type(), num, (field->IsOptional() ? 1 : 0)))
+ {
+ continue;
+ }
num++;
os << std::endl;
- if ( field->IsOptional() ) {
+ if (field->IsOptional())
+ {
os << " if ( ent->";
if ( ! own ) os << CPPName()->ToCString() << "::";
else if ( own ==-1 ) os << Name()->ToCString() << "()->";
}
os << oos.str();
- if ( field->IsOptional() ) {
+ if (field->IsOptional())
+ {
os << " }" << std::endl;
}
}
Standard_Integer sh = shift;
// write code for inherited fields
- for (Standard_Integer i = 1; i <= myInherit->Length(); i++) {
+ for (Standard_Integer i = 1; i <= myInherit->Length(); i++)
+ {
Handle(Express_Entity) ent = myInherit->Value(i);
- if (mode == 3) {
+ if (mode == 3)
+ {
Standard_Integer s = 0;
- if (i > 1) {
+ if (i > 1)
+ {
os << "\n my" << ent->Name()->ToCString() << " = new " << ent->CPPName()->ToCString() << ";";
os << "\n my" << ent->Name()->ToCString() << "->Init(";
s = 12 + ent->Name()->Length();
}
- else {
+ else
+ {
os << "\n " << ent->CPPName()->ToCString() << "::Init(";
s = 9 + ent->CPPName()->Length();
}
ent->MakeInit(os, s, Standard_False, 2);
os << ");";
}
- else sh = ent->MakeInit(os, sh, (i > 1 ? -1 : Standard_False), mode);
+ else
+ {
+ sh = ent->MakeInit(os, sh, (i > 1 ? -1 : Standard_False), mode);
+ }
}
// write code for own fields
-
- for (Standard_Integer i=1; i <= myFields->Length(); i++ ) {
+
+ for (Standard_Integer i = 1; i <= myFields->Length(); i++)
+ {
Handle(Express_Field) field = myFields->Value(i);
- Handle(TCollection_HAsciiString) varName = new TCollection_HAsciiString ( field->Name() );
- if ( own != 1 ) varName->Prepend ( Name()->Cat ( "_" ) );
+ Handle(TCollection_HAsciiString) varName = new TCollection_HAsciiString(field->Name());
+ if (own != 1)
+ {
+ varName->Prepend(Name()->Cat("_"));
+ }
// make CR and indent
TCollection_AsciiString space = "";
- for ( Standard_Integer sn=0; sn < abs(sh); sn++ ) space += " ";
- Standard_Character delim = ( mode == 0 ? ',' : ( mode == 3 ? '\n' : ',' ) );
- if ( sh < 0 ) os << delim << "\n" << space;
- else sh = -sh;
-
- if ( field->IsOptional() ) {
- if ( mode == 0 ) os << "const Standard_Boolean has" << varName->ToCString() << ",\n" << space;
- else if ( mode == 1 ) os << "const Standard_Boolean has" << varName->ToCString() << ",\n" << space;
- else if ( mode == 2 || mode == 4) os << "has" << varName->ToCString() << ",\n" << space;
+ for (Standard_Integer sn = 0; sn < abs(sh); sn++)
+ {
+ space += " ";
}
-
+ Standard_Character delim = (mode == 0 ? ',' : (mode == 3 ? '\n' : ','));
+ if (sh < 0)
+ {
+ os << delim << "\n" << space;
+ }
+ else
+ {
+ sh = -sh;
+ }
+
+ if (field->IsOptional())
+ {
+ if (mode == 0)
+ {
+ os << "const Standard_Boolean has" << varName->ToCString() << ",\n" << space;
+ }
+ else if (mode == 1)
+ {
+ os << "const Standard_Boolean has" << varName->ToCString() << ",\n" << space;
+ }
+ else if (mode == 2 || mode == 4)
+ {
+ os << "has" << varName->ToCString() << ",\n" << space;
+ }
+ }
+
// write field
- if ( mode == 0 || mode ==1) {
+ if (mode == 0 || mode == 1)
+ {
os << "const " << (field->Type()->IsHandle() ? "Handle(" : "") <<
field->Type()->CPPName()->ToCString() << (field->Type()->IsHandle() ? ")" : "") <<
(field->Type()->IsSimple() ? " the" : "& the") << varName->ToCString();
}
- else if ( mode == 2 ) {
+ else if (mode == 2)
+ {
os << "the" << varName->ToCString();
}
- else if (mode == 4) {
+ else if (mode == 4)
+ {
os << "a" << varName->ToCString();
}
- else {
- if (field->IsOptional()) {
+ else
+ {
+ if (field->IsOptional())
+ {
os << "def" << field->Name()->ToCString() << " = has" << varName->ToCString() << ";" << std::endl;
os << " if (def" << field->Name()->ToCString() << ") {\n ";
}
os << "my" << field->Name()->ToCString() << " = the" << varName->ToCString() << ";";
- if (field->IsOptional()) {
+ if (field->IsOptional())
+ {
os << "\n }\n else my" << field->Name()->ToCString();
if (field->Type()->IsHandle())
+ {
os << ".Nullify();";
+ }
else if (field->Type()->IsStandard())
+ {
os << " = 0;";
+ }
else
+ {
os << " = " << field->Type()->CPPName()->ToCString() << "();";
+ }
}
}
- if ( sh >0 ) sh = -sh;
+ if (sh > 0)
+ {
+ sh = -sh;
+ }
}
-
+
return sh;
}
+
//=======================================================================
//function : SetAbstractFlag
//purpose :
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 cprrespondingly.
- Standard_EXPORT Express_Entity(const Standard_CString name, const Handle(TColStd_HSequenceOfHAsciiString)& inherit, const Handle(Express_HSequenceOfField)& flds);
+ Standard_EXPORT Express_Entity(
+ const Standard_CString name,
+ const Handle(TColStd_HSequenceOfHAsciiString)& inherit,
+ const Handle(Express_HSequenceOfField)& flds);
//! Returns sequence of inherited classes (names)
Standard_EXPORT const Handle(TColStd_HSequenceOfHAsciiString)& SuperTypes() const;
//! Returns abstract flag.
Standard_EXPORT Standard_Boolean AbstractFlag() const;
-
-
-
DEFINE_STANDARD_RTTIEXT(Express_Entity,Express_Item)
protected:
-
-
-
private:
typedef NCollection_DataMap<TCollection_AsciiString,Standard_Integer,TCollection_AsciiString> DataMapOfStringInteger;
Standard_EXPORT void WriteRWInclude (Standard_OStream& os, DataMapOfStringInteger& dict) const;
//! Writes code for reading all fields
- Standard_EXPORT Standard_Integer WriteRWReadCode (Standard_OStream& os, const Standard_Integer start, const Standard_Integer own) const;
+ Standard_EXPORT Standard_Integer WriteRWReadCode(
+ Standard_OStream& os,
+ const Standard_Integer start,
+ const Standard_Integer own) const;
//! Writes code for writing all fields
- Standard_EXPORT Standard_Integer WriteRWWriteCode (Standard_OStream& os, const Standard_Integer start, const Standard_Integer own) const;
+ Standard_EXPORT Standard_Integer WriteRWWriteCode(
+ Standard_OStream& os,
+ const Standard_Integer start,
+ const Standard_Integer own) const;
//! Writes code for adding shared entities to the graph
- Standard_EXPORT Standard_Integer WriteRWShareCode (Standard_OStream& os, const Standard_Integer start, const Standard_Integer own) const;
+ Standard_EXPORT Standard_Integer WriteRWShareCode(
+ Standard_OStream& os,
+ const Standard_Integer start,
+ const Standard_Integer own) const;
//! Writes arguments and code for method Init()
//! Mode identifyes what code is being written:
//! 2 - call (argument list)
//! 3 - implementation
//! 4 - call (argument list for RW)
- Standard_EXPORT Standard_Integer MakeInit (Standard_OStream& os, const Standard_Integer shift, const Standard_Integer own, const Standard_Integer mode) const;
+ Standard_EXPORT Standard_Integer MakeInit(
+ Standard_OStream& os,
+ const Standard_Integer shift,
+ const Standard_Integer own,
+ const Standard_Integer mode) const;
Handle(TColStd_HSequenceOfHAsciiString) mySupers;
Handle(Express_HSequenceOfEntity) myInherit;
Standard_Boolean myisAbstract;
};
-
-
-
-
-
-
#endif // _Express_Entity_HeaderFile
//purpose :
//=======================================================================
-Express_Enum::Express_Enum (const Standard_CString name,
- const Handle(TColStd_HSequenceOfHAsciiString) &names)
- : Express_Item(name), myNames(names)
+Express_Enum::Express_Enum(
+ const Standard_CString name,
+ const Handle(TColStd_HSequenceOfHAsciiString) &names)
+ : Express_Item(name), myNames(names)
{
}
Standard_Boolean Express_Enum::GenerateClass () const
{
std::cout << "Generating ENUMERATION " << CPPName()->ToCString() << std::endl;
-
+
// create a package directory (if not yet exist)
- OSD_Protection prot ( OSD_RX, OSD_RWX, OSD_RX, OSD_RX );
+ OSD_Protection prot(OSD_RX, OSD_RWX, OSD_RX, OSD_RX);
TCollection_AsciiString pack = GetPackageName()->String();
- OSD_Path path ( pack );
- OSD_Directory dir ( path );
- dir.Build ( prot );
+ OSD_Path path(pack);
+ OSD_Directory dir(path);
+ dir.Build(prot);
pack += "/";
pack += CPPName()->String();
-
+
// Open HXX file
- std::ofstream os ( pack.Cat ( ".hxx" ).ToCString(), std::ios::out | std::ios::ate );
+ std::ofstream os(pack.Cat(".hxx").ToCString(), std::ios::out | std::ios::ate);
// write header
Express::WriteFileStamp(os);
os << std::endl << "enum " << CPPName()->ToCString() << std::endl;
os << "{" << std::endl;
Handle(TCollection_HAsciiString) prefix = Express::EnumPrefix(Name());
- for ( Standard_Integer i = 1; i <= myNames->Length(); i++ ) {
- if ( i > 1 ) os << "," << std::endl;
- os << " " << GetPackageName()->ToCString() << "_" << prefix->ToCString()
- << myNames->Value(i)->ToCString();
+ for (Standard_Integer i = 1; i <= myNames->Length(); i++)
+ {
+ if (i > 1)
+ {
+ os << "," << std::endl;
+ }
+ os << " " << GetPackageName()->ToCString() << "_" << prefix->ToCString()
+ << myNames->Value(i)->ToCString();
}
os << std::endl << "};" << std::endl;
os << "#endif // _" << CPPName()->ToCString() << "_HeaderFile" << std::endl;
os.close();
-
+
return Standard_False;
}
#include <Express_Item.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 name, const Handle(TColStd_HSequenceOfHAsciiString)& names);
//! Create HXX/CXX files from item
Standard_EXPORT virtual Standard_Boolean GenerateClass() const Standard_OVERRIDE;
-
-
-
DEFINE_STANDARD_RTTIEXT(Express_Enum,Express_Item)
protected:
-
-
-
private:
-
Handle(TColStd_HSequenceOfHAsciiString) myNames;
-
};
-
-
-
-
-
-
#endif // _Express_Enum_HeaderFile
//purpose :
//=======================================================================
-Express_Field::Express_Field (const Standard_CString name,
- const Handle(Express_Type) &type,
- const Standard_Boolean opt)
+Express_Field::Express_Field(
+ const Standard_CString name,
+ const Handle(Express_Type) &type,
+ const Standard_Boolean opt)
{
myName = new TCollection_HAsciiString ( name );
myType = type;
//purpose :
//=======================================================================
-Express_Field::Express_Field (const Handle(TCollection_HAsciiString) &name,
- const Handle(Express_Type) &type,
- const Standard_Boolean opt)
+Express_Field::Express_Field(
+ const Handle(TCollection_HAsciiString) &name,
+ const Handle(Express_Type) &type,
+ const Standard_Boolean opt)
{
myName = name;
myType = type;
class TCollection_HAsciiString;
class Express_Type;
-
//! 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 name, const Handle(Express_Type)& type, const Standard_Boolean opt);
+ Standard_EXPORT Express_Field(
+ const Standard_CString name,
+ const Handle(Express_Type)& type,
+ const Standard_Boolean opt);
//! Create object and initialize it
- Standard_EXPORT Express_Field(const Handle(TCollection_HAsciiString)& name, const Handle(Express_Type)& type, const Standard_Boolean opt);
+ Standard_EXPORT Express_Field(
+ const Handle(TCollection_HAsciiString)& name,
+ const Handle(Express_Type)& type,
+ const Standard_Boolean opt);
//! Returns field name
Standard_EXPORT const Handle(TCollection_HAsciiString)& Name() 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
DEFINE_HSEQUENCE(Express_HSequenceOfEntity, Express_SequenceOfEntity)
-
#endif
DEFINE_HSEQUENCE(Express_HSequenceOfField, Express_SequenceOfField)
-
#endif
DEFINE_HSEQUENCE(Express_HSequenceOfItem, Express_SequenceOfItem)
-
#endif
#include <Express_PredefinedType.hxx>
class TCollection_HAsciiString;
-
//! Implements EXPRESS type 'INTEGER'
class Express_Integer : public Express_PredefinedType
{
public:
-
//! Empty constructor
Standard_EXPORT Express_Integer();
//! Returns "Standard_Integer"
Standard_EXPORT virtual Handle(TCollection_HAsciiString) CPPName() const Standard_OVERRIDE;
-
-
-
DEFINE_STANDARD_RTTIEXT(Express_Integer,Express_PredefinedType)
protected:
-
-
-
private:
-
-
-
};
-
-
-
-
-
-
#endif // _Express_Integer_HeaderFile
Handle(TCollection_HAsciiString) Express_Item::CPPName () const
{
- Handle(TCollection_HAsciiString) name = GetPackageName ( Standard_True )->Cat ( "_" );
+ Handle(TCollection_HAsciiString) name = GetPackageName(Standard_True)->Cat("_");
name->AssignCat ( myName );
return name;
}
Handle(TCollection_HAsciiString) Express_Item::GetPackageName (const Standard_Boolean Auto) const
{
- if ( myPack.IsNull() && Auto ) return new TCollection_HAsciiString ( "StepStep" );
+ if (myPack.IsNull() && Auto)
+ {
+ return new TCollection_HAsciiString("StepStep");
+ }
return myPack;
}
Standard_Boolean Express_Item::Generate ()
{
- if ( ! GetMark() ) return Standard_False;
- if ( GetPackageName().IsNull() )
- SetPackageName ( GetPackageName ( Standard_True ) );
+ if (!GetMark())
+ {
+ return Standard_False;
+ }
+ if (GetPackageName().IsNull())
+ {
+ SetPackageName(GetPackageName(Standard_True));
+ }
SetMark ( Standard_False );
return GenerateClass();
}
//purpose :
//=======================================================================
-Standard_Boolean Express_Item::Use (const Handle(TCollection_HAsciiString) &pack,
- const Standard_Boolean defer)
+Standard_Boolean Express_Item::Use(
+ const Handle(TCollection_HAsciiString) &pack,
+ const Standard_Boolean defer)
{
- if ( ! GetPackageName().IsNull() ) {
+ if (!GetPackageName().IsNull())
+ {
// issue a warning message if item from known package uses item from unknown package (StepStep)
- if ( pack->String().IsDifferent ( "StepStep" ) &&
- GetPackageName()->String().IsEqual ( "StepStep" ) ) {
- std::cout << "Warning: item " << Name()->ToCString() << " has no package assigned, but used from package " << pack->ToCString() << std::endl;
+ if (pack->String().IsDifferent("StepStep") && GetPackageName()->String().IsEqual("StepStep"))
+ {
+ std::cout << "Warning: item " << Name()->ToCString() << " has no package assigned, but used from package "
+ << pack->ToCString() << std::endl;
}
-
return Standard_False;
}
// issue a warning message if type still does not have package assigned
- if ( pack->String().IsDifferent ( "StepStep" ) ) {
- std::cout << "Warning: item " << Name()->ToCString() << " has no package assigned, setting " << pack->ToCString() << std::endl;
+ if (pack->String().IsDifferent("StepStep"))
+ {
+ std::cout << "Warning: item " << Name()->ToCString() << " has no package assigned, setting "
+ << pack->ToCString() << std::endl;
}
SetPackageName ( pack );
SetMark ( Standard_True );
- if ( defer ) return Standard_False;
+ if (defer)
+ {
+ return Standard_False;
+ }
// manage indent for cout in order to mark structure of calls
static Standard_Integer shift=0;
shift++;
- for ( Standard_Integer i=0; i < shift; i++ ) std::cout << " ";
+ for (Standard_Integer i = 0; i < shift; i++)
+ {
+ std::cout << " ";
+ }
Standard_Boolean res = Generate();
shift--;
return res;
#include <Standard_CString.hxx>
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
//! Returns package name
//! If not defined, returns NULL if auto is False (default)
//! or "StepStep" if auto is True
- Standard_EXPORT Handle(TCollection_HAsciiString) GetPackageName (const Standard_Boolean Auto = Standard_False) const;
+ Standard_EXPORT Handle(TCollection_HAsciiString) GetPackageName(const Standard_Boolean Auto = Standard_False) const;
//! Sets package name
Standard_EXPORT void SetPackageName (const Handle(TCollection_HAsciiString)& pack) ;
//! by pack argument (supposing that it is package of item that uses
//! current one) and Mark flag is set. Then, if defer is False,
//! calls Generate().
- Standard_EXPORT Standard_Boolean Use (const Handle(TCollection_HAsciiString)& pack, const Standard_Boolean defer = Standard_False) ;
+ Standard_EXPORT Standard_Boolean Use(
+ const Handle(TCollection_HAsciiString)& pack,
+ const Standard_Boolean defer = Standard_False);
//! Set category for item
Standard_EXPORT void SetCategory (const Handle(TCollection_HAsciiString)& categ) ;
//! Get current entity index
Standard_EXPORT static Standard_Integer Index();
-
-
-
DEFINE_STANDARD_RTTIEXT(Express_Item,Standard_Transient)
protected:
-
//! Creates object and initialises fields PackageName and
//! CreateFlag by 0
//! CreateFlag by 0
Standard_EXPORT Express_Item(const Handle(TCollection_HAsciiString)& name);
-
-
private:
-
Handle(TCollection_HAsciiString) myName;
Handle(TCollection_HAsciiString) myPack;
Standard_Boolean myMark;
Standard_Boolean myhasCheck;
Standard_Boolean myhasFillShared;
-
};
-
-
-
-
-
#endif // _Express_Item_HeaderFile
Handle(TCollection_HAsciiString) Express_Logical::CPPName () const
{
- return new TCollection_HAsciiString ( "StepData_Logical" );
+ return new TCollection_HAsciiString("StepData_Logical");
}
//=======================================================================
#define _Express_Logical_HeaderFile
#include <Standard_Type.hxx>
-
#include <Express_PredefinedType.hxx>
class TCollection_HAsciiString;
-
//! Implements EXPRESS type 'LOGICAL'
class Express_Logical : public Express_PredefinedType
{
public:
-
//! Empty constructor
Standard_EXPORT Express_Logical();
//! Return False
Standard_EXPORT virtual Standard_Boolean IsHandle() const Standard_OVERRIDE;
-
-
-
DEFINE_STANDARD_RTTIEXT(Express_Logical,Express_PredefinedType)
protected:
-
-
-
private:
-
-
-
};
-
-
-
-
-
-
#endif // _Express_Logical_HeaderFile
Standard_Boolean Express_NamedType::IsStandard () const
{
- if ( myItem->IsKind(STANDARD_TYPE(Express_Alias)) ) {
- Handle(Express_Alias) alias = Handle(Express_Alias)::DownCast ( myItem );
+ if (myItem->IsKind(STANDARD_TYPE(Express_Alias)))
+ {
+ Handle(Express_Alias) alias = Handle(Express_Alias)::DownCast(myItem);
return alias->Type()->IsStandard();
}
return Standard_False;
Standard_Boolean Express_NamedType::IsSimple () const
{
- if ( myItem->IsKind(STANDARD_TYPE(Express_Alias)) ) {
- Handle(Express_Alias) alias = Handle(Express_Alias)::DownCast ( myItem );
+ if (myItem->IsKind(STANDARD_TYPE(Express_Alias)))
+ {
+ Handle(Express_Alias) alias = Handle(Express_Alias)::DownCast(myItem);
return alias->Type()->IsSimple();
}
- if ( myItem->IsKind(STANDARD_TYPE(Express_Enum)) ) return Standard_True;
+ if (myItem->IsKind(STANDARD_TYPE(Express_Enum)))
+ {
+ return Standard_True;
+ }
return Standard_False; // SELECT & ENTITY
}
Standard_Boolean Express_NamedType::IsHandle () const
{
- if ( myItem->IsKind(STANDARD_TYPE(Express_Alias)) ) {
+ 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;
+ if (myItem->IsKind(STANDARD_TYPE(Express_Entity)))
+ {
+ return Standard_True;
+ }
return Standard_False; // SELECT & ENUMERATION
}
//purpose :
//=======================================================================
-Standard_Boolean Express_NamedType::Use (const Handle(TCollection_HAsciiString) &pack,
- const Standard_Boolean defer) const
+Standard_Boolean Express_NamedType::Use(
+ const Handle(TCollection_HAsciiString) &pack,
+ const Standard_Boolean defer) const
{
return myItem->Use ( pack, defer );
}
#define _Express_NamedType_HeaderFile
#include <Standard_Type.hxx>
-
#include <Express_Type.hxx>
class TCollection_HAsciiString;
class Express_Item;
-
//! Base class for complex types (ARRAY, LIST, BAG, SET)
//! in EXPRESS schema
//! Stores type of elements and
{
public:
-
//! Creates an object and initializes by name
Standard_EXPORT Express_NamedType(const Standard_CString name);
//! Declares type as used by some item being generated.
//! Calls Use() for referred item (found by name).
- Standard_EXPORT virtual Standard_Boolean Use(const Handle(TCollection_HAsciiString)& pack, const Standard_Boolean defer = Standard_False) const Standard_OVERRIDE;
-
-
-
+ Standard_EXPORT virtual Standard_Boolean Use(
+ const Handle(TCollection_HAsciiString)& pack,
+ const Standard_Boolean defer = Standard_False) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(Express_NamedType,Express_Type)
protected:
-
-
-
private:
-
Handle(TCollection_HAsciiString) myName;
Handle(Express_Item) myItem;
-
};
-
-
-
-
-
-
#endif // _Express_NamedType_HeaderFile
#define _Express_PredefinedType_HeaderFile
#include <Standard_Type.hxx>
-
#include <Express_Type.hxx>
//! Base class for predefined types (like NUMBER or STRING)
{
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
Handle(TCollection_HAsciiString) Express_Real::CPPName () const
{
- return new TCollection_HAsciiString ( "Standard_Real" );
+ return new TCollection_HAsciiString("Standard_Real");
}
#define _Express_Real_HeaderFile
#include <Standard_Type.hxx>
-
#include <Express_PredefinedType.hxx>
class TCollection_HAsciiString;
-
//! Implements EXPRESS type 'REAL'
class Express_Real : public Express_PredefinedType
{
public:
-
//! Empty constructor
Standard_EXPORT Express_Real();
//! Returns "Standard_Real"
Standard_EXPORT virtual Handle(TCollection_HAsciiString) CPPName() const Standard_OVERRIDE;
-
-
-
DEFINE_STANDARD_RTTIEXT(Express_Real,Express_PredefinedType)
protected:
-
-
-
private:
-
-
-
};
-
-
-
-
-
-
#endif // _Express_Real_HeaderFile
//purpose :
//=======================================================================
-Express_Reference::Express_Reference (const Standard_CString name,
- const Handle(TColStd_HSequenceOfHAsciiString) &types)
- : Express_Item ( name )
+Express_Reference::Express_Reference(
+ const Standard_CString name,
+ const Handle(TColStd_HSequenceOfHAsciiString) &types)
+ : Express_Item(name)
{
myTypes = types;
}
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 name, const Handle(TColStd_HSequenceOfHAsciiString)& types);
//! Returns list of types referenced
- const Handle(TColStd_HSequenceOfHAsciiString)& Types() const { return myTypes; }
+ 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; }
+ const Handle(Express_HSequenceOfItem)& Items() const
+ {
+ return myItems;
+ }
//! Redefined to empty (in order to be able to instantiate)
//! Returna False
Standard_EXPORT virtual Standard_Boolean GenerateClass() const Standard_OVERRIDE;
-
-
-
DEFINE_STANDARD_RTTIEXT(Express_Reference,Express_Item)
protected:
-
-
-
private:
-
Handle(TColStd_HSequenceOfHAsciiString) myTypes;
Handle(Express_HSequenceOfItem) myItems;
-
};
-
#endif // _Express_Reference_HeaderFile
//purpose :
//=======================================================================
-Express_Schema::Express_Schema (const Standard_CString name,
- const Handle(Express_HSequenceOfItem) &items)
+Express_Schema::Express_Schema(
+ const Standard_CString name,
+ const Handle(Express_HSequenceOfItem) &items)
{
myName = new TCollection_HAsciiString ( name );
myItems = items;
//purpose :
//=======================================================================
-Express_Schema::Express_Schema (const Handle(TCollection_HAsciiString) &name,
- const Handle(Express_HSequenceOfItem) &items)
+Express_Schema::Express_Schema(
+ const Handle(TCollection_HAsciiString) &name,
+ const Handle(Express_HSequenceOfItem) &items)
{
myName = name;
myItems = items;
//purpose :
//=======================================================================
-Handle(Express_Item) Express_Schema::Item (const Standard_Integer num) const
+Handle(Express_Item) Express_Schema::Item(const Standard_Integer num) const
{
return myItems->Value(num);
}
//purpose :
//=======================================================================
-Handle(Express_Item) Express_Schema::Item (const Standard_CString name,
- const Standard_Boolean silent) const
+Handle(Express_Item) Express_Schema::Item(
+ const Standard_CString name,
+ const Standard_Boolean silent) const
{
- if ( ! myDict.IsBound ( name ) ) {
- if ( ! silent )
+ if (!myDict.IsBound(name))
+ {
+ if (!silent)
+ {
std::cout << "Error: attempt to access unknown item by name " << name << std::endl;
+ }
return 0;
}
return myDict.Find (name);
//purpose :
//=======================================================================
-Handle(Express_Item) Express_Schema::Item (const TCollection_AsciiString &name) const
+Handle(Express_Item) Express_Schema::Item(const TCollection_AsciiString &name) const
{
- return Item ( name.ToCString() );
+ return Item(name.ToCString());
}
//=======================================================================
//purpose :
//=======================================================================
-Handle(Express_Item) Express_Schema::Item (const Handle(TCollection_HAsciiString) &name) const
+Handle(Express_Item) Express_Schema::Item(const Handle(TCollection_HAsciiString) &name) const
{
- return Item ( name->ToCString() );
+ return Item(name->ToCString());
}
//=======================================================================
-//function : Prepare
-//purpose :
+//function : nameToCasCade
+//purpose : auxilary for Prepare()
+// Convert STEP-style name (lowercase, with underscores)
+// to CASCADE-style name (each word starts with uppercase, no intervals)
//=======================================================================
-
-// 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) &name)
+static void nameToCasCade (const Handle(TCollection_HAsciiString) &name)
{
- if ( name.IsNull() ) return;
- for ( Standard_Integer i=1; i <= name->Length(); i++ ) {
- if ( name->Value(i) == '_' ) {
+ if (name.IsNull())
+ {
+ return;
+ }
+ for (Standard_Integer i = 1; i <= name->Length(); i++)
+ {
+ if ( name->Value(i) == '_' )
+ {
name->Remove ( i );
}
- else if ( i >1 ) continue;
+ else if (i > 1)
+ {
+ continue;
+ }
name->SetValue ( i, UpperCase ( name->Value(i) ) );
}
}
-// Convert names for Type object
-static void NameToCasCade (const Handle(Express_Type) &type)
+//=======================================================================
+//function : nameToCasCade
+//purpose : auxilary for Prepare()
+// Convert names for Type object
+//=======================================================================
+static void nameToCasCade (const Handle(Express_Type) &type)
{
- if ( type->IsKind(STANDARD_TYPE(Express_NamedType)) ) {
- const Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast ( type );
- NameToCasCade ( named->Name() );
+ if (type->IsKind(STANDARD_TYPE(Express_NamedType)))
+ {
+ const Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast(type);
+ nameToCasCade(named->Name());
}
- else if ( type->IsKind(STANDARD_TYPE(Express_ComplexType)) ) {
- const Handle(Express_ComplexType) complex = Handle(Express_ComplexType)::DownCast ( type );
- NameToCasCade ( complex->Type() );
+ else if (type->IsKind(STANDARD_TYPE(Express_ComplexType)))
+ {
+ const Handle(Express_ComplexType) complex = Handle(Express_ComplexType)::DownCast(type);
+ nameToCasCade(complex->Type());
}
}
-// Prepare data: convert names to CasCade, fill dictionary of typenames
-// and set handles to items where they are referenced by names
+//=======================================================================
+//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;
+ if (myItems.IsNull())
+ {
+ return;
+ }
Standard_Integer nbItems = NbItems();
// convert names annd fill dictionary
- for ( Standard_Integer num=1; num <= nbItems; num++ ) {
+ for ( Standard_Integer num=1; num <= nbItems; num++ )
+ {
// get item
const Handle(Express_Item) item = Item(num);
// change item name
- NameToCasCade ( item->Name() );
+ nameToCasCade ( item->Name() );
// change names of referred types and other names
- if ( item->IsKind(STANDARD_TYPE(Express_Alias)) ) {
- const Handle(Express_Alias) alias = Handle(Express_Alias)::DownCast ( item );
- NameToCasCade ( alias->Type() );
+ if (item->IsKind(STANDARD_TYPE(Express_Alias)))
+ {
+ const Handle(Express_Alias) alias = Handle(Express_Alias)::DownCast(item);
+ nameToCasCade(alias->Type());
}
- else if ( item->IsKind(STANDARD_TYPE(Express_Select)) ) {
- const Handle(Express_Select) select = Handle(Express_Select)::DownCast ( item );
- for ( Standard_Integer i=1; i <= select->Names()->Length(); i++ )
- NameToCasCade ( select->Names()->Value(i) );
+ else if (item->IsKind(STANDARD_TYPE(Express_Select)))
+ {
+ const Handle(Express_Select) select = Handle(Express_Select)::DownCast(item);
+ for (Standard_Integer i = 1; i <= select->Names()->Length(); i++)
+ {
+ nameToCasCade(select->Names()->Value(i));
+ }
}
- else if ( item->IsKind(STANDARD_TYPE(Express_Enum)) ) {
- const Handle(Express_Enum) en = Handle(Express_Enum)::DownCast ( item );
- for ( Standard_Integer i=1; i <= en->Names()->Length(); i++ )
- NameToCasCade ( en->Names()->Value(i) );
+ else if (item->IsKind(STANDARD_TYPE(Express_Enum)))
+ {
+ const Handle(Express_Enum) en = Handle(Express_Enum)::DownCast(item);
+ for (Standard_Integer i = 1; i <= en->Names()->Length(); i++)
+ {
+ nameToCasCade(en->Names()->Value(i));
+ }
}
- else if ( item->IsKind(STANDARD_TYPE(Express_Entity)) ) {
- const Handle(Express_Entity) ent = Handle(Express_Entity)::DownCast ( item );
- for ( Standard_Integer i=1; i <= ent->SuperTypes()->Length(); i++ )
- NameToCasCade ( ent->SuperTypes()->Value(i) );
+ else if (item->IsKind(STANDARD_TYPE(Express_Entity)))
+ {
+ const Handle(Express_Entity) ent = Handle(Express_Entity)::DownCast(item);
+ for (Standard_Integer i = 1; i <= ent->SuperTypes()->Length(); i++)
+ {
+ nameToCasCade(ent->SuperTypes()->Value(i));
+ }
const Handle(Express_HSequenceOfField) fields = ent->Fields();
- for (Standard_Integer i=1; i <= fields->Length(); i++ ) {
- NameToCasCade ( fields->Value(i)->Name() );
- NameToCasCade ( fields->Value(i)->Type() );
+ for (Standard_Integer i = 1; i <= fields->Length(); i++)
+ {
+ nameToCasCade(fields->Value(i)->Name());
+ nameToCasCade(fields->Value(i)->Type());
}
}
// add to dictionary
- myDict.Bind (item->Name()->String(), item);
+ myDict.Bind(item->Name()->String(), item);
}
// set references to items from other items and types
- for (Standard_Integer num=1; num <= nbItems; num++ ) {
+ for (Standard_Integer num=1; num <= nbItems; num++ )
+ {
const Handle(Express_Item) item = Item(num);
- if ( item->IsKind(STANDARD_TYPE(Express_Alias)) ) {
+ if ( item->IsKind(STANDARD_TYPE(Express_Alias)) )
+ {
const Handle(Express_Alias) alias = Handle(Express_Alias)::DownCast ( item );
PrepareType ( alias->Type() );
// for aliases, define package to avoid warnings
alias->SetPackageName ( new TCollection_HAsciiString ( "Standard" ) );
continue;
}
- else if ( item->IsKind(STANDARD_TYPE(Express_Select)) ) {
- const Handle(Express_Select) select = Handle(Express_Select)::DownCast ( item );
+ else if (item->IsKind(STANDARD_TYPE(Express_Select)))
+ {
+ const Handle(Express_Select) select = Handle(Express_Select)::DownCast(item);
Handle(TColStd_HSequenceOfHAsciiString) names = select->Names();
Handle(Express_HSequenceOfItem) items = select->Items();
- for ( Standard_Integer i=1; i <= names->Length(); i++ ) {
- Handle(Express_Item) it = Item ( names->Value(i) );
- // if select refers to another select, expand it
- if ( it->IsKind(STANDARD_TYPE(Express_Select)) ) {
- std::cout << "Info: SELECT " << item->Name()->ToCString() << " refers to another SELECT " <<
- it->Name()->ToCString() << "; expanded" << std::endl;
- const Handle(Express_Select) sel = Handle(Express_Select)::DownCast ( it );
+ for (Standard_Integer i = 1; i <= names->Length(); i++)
+ {
+ Handle(Express_Item) it = Item(names->Value(i));
+ // if select refers to another select, expand it
+ if (it->IsKind(STANDARD_TYPE(Express_Select)))
+ {
+ std::cout << "Info: SELECT " << item->Name()->ToCString() << " refers to another SELECT " <<
+ it->Name()->ToCString() << "; expanded" << std::endl;
+ const Handle(Express_Select) sel = Handle(Express_Select)::DownCast(it);
Standard_Integer j = 1;
- for ( ; j <= sel->Names()->Length(); j++ )
- names->InsertBefore ( i+j-1, sel->Names()->Value(j) );
- names->Remove ( i+j-1 );
- i--;
- continue;
- }
- items->Append ( it );
+ for (; j <= sel->Names()->Length(); j++)
+ {
+ names->InsertBefore(i + j - 1, sel->Names()->Value(j));
+ }
+ names->Remove(i + j - 1);
+ i--;
+ continue;
+ }
+ items->Append(it);
}
}
- else if ( item->IsKind(STANDARD_TYPE(Express_Entity)) ) {
- const Handle(Express_Entity) ent = Handle(Express_Entity)::DownCast ( item );
+ else if ( item->IsKind(STANDARD_TYPE(Express_Entity)) )
+ {
+ const Handle(Express_Entity) ent = Handle(Express_Entity)::DownCast(item);
Handle(TColStd_HSequenceOfHAsciiString) names = ent->SuperTypes();
Handle(Express_HSequenceOfEntity) inh = ent->Inherit();
- for ( Standard_Integer i=1; i <= names->Length(); i++ ) {
- Handle(Express_Entity) subent = Handle(Express_Entity)::DownCast ( Item ( names->Value(i) ) );
- if ( ! subent.IsNull() ) inh->Append ( subent );
- else
+ for (Standard_Integer i = 1; i <= names->Length(); i++)
+ {
+ Handle(Express_Entity) subent = Handle(Express_Entity)::DownCast(Item(names->Value(i)));
+ if (!subent.IsNull())
{
- std::cout << "Error in " << item->Name()->ToCString() << ": supertype " <<
- names->Value(i)->ToCString() << " is not an ENTITY; ignored" << std::endl;
+ inh->Append(subent);
+ }
+ else
+ {
+ std::cout << "Error in " << item->Name()->ToCString() << ": supertype " <<
+ names->Value(i)->ToCString() << " is not an ENTITY; ignored" << std::endl;
}
}
const Handle(Express_HSequenceOfField) fields = ent->Fields();
- for (Standard_Integer i=1; i <= fields->Length(); i++ )
- PrepareType ( fields->Value(i)->Type() );
+ for (Standard_Integer i = 1; i <= fields->Length(); i++)
+ {
+ PrepareType(fields->Value(i)->Type());
+ }
}
}
//purpose :
//=======================================================================
-void Express_Schema::PrepareType (const Handle(Express_Type) &type) const
+void Express_Schema::PrepareType(const Handle(Express_Type) &type) const
{
- if ( type->IsKind(STANDARD_TYPE(Express_NamedType)) ) {
- Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast ( type );
- named->SetItem ( Item ( named->Name() ) );
+ if (type->IsKind(STANDARD_TYPE(Express_NamedType)))
+ {
+ Handle(Express_NamedType) named = Handle(Express_NamedType)::DownCast(type);
+ named->SetItem(Item(named->Name()));
}
- else if ( type->IsKind(STANDARD_TYPE(Express_ComplexType)) ) {
- Handle(Express_ComplexType) complex = Handle(Express_ComplexType)::DownCast ( type );
- PrepareType ( complex->Type() );
+ else if (type->IsKind(STANDARD_TYPE(Express_ComplexType)))
+ {
+ Handle(Express_ComplexType) complex = Handle(Express_ComplexType)::DownCast(type);
+ PrepareType(complex->Type());
}
}
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)
{
public:
-
//! Creates a schema with given name and given set of items
//! and calls Prepare()
//! Creates a schema with given name and given set of items
//! and calls Prepare()
- Standard_EXPORT Express_Schema(const Handle(TCollection_HAsciiString)& Name, const Handle(Express_HSequenceOfItem)& items);
+ Standard_EXPORT Express_Schema(
+ const Handle(TCollection_HAsciiString)& Name,
+ const Handle(Express_HSequenceOfItem)& items);
//! Returns schema name
Standard_EXPORT const Handle(TCollection_HAsciiString)& Name() const;
Standard_EXPORT Handle(Express_Item) Item (const Standard_Integer num) const;
//! Returns item by name
- Standard_EXPORT Handle(Express_Item) Item (const Standard_CString name, const Standard_Boolean silent = Standard_False) const;
+ Standard_EXPORT Handle(Express_Item) Item(
+ const Standard_CString name,
+ const Standard_Boolean silent = Standard_False) const;
//! Returns item by name
Standard_EXPORT Handle(Express_Item) Item (const TCollection_AsciiString& name) const;
//! Returns item by name
Standard_EXPORT Handle(Express_Item) Item (const Handle(TCollection_HAsciiString)& name) 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).
Handle(TCollection_HAsciiString) myName;
Handle(Express_HSequenceOfItem) myItems;
Express_DataMapOfAsciiStringItem myDict;
+
};
#endif // _Express_Schema_HeaderFile
//purpose :
//=======================================================================
-Express_Select::Express_Select (const Standard_CString name,
- const Handle(TColStd_HSequenceOfHAsciiString) &names)
- : Express_Item(name), myNames(names)
+Express_Select::Express_Select(
+ const Standard_CString name,
+ const Handle(TColStd_HSequenceOfHAsciiString) &names)
+ : Express_Item(name), myNames(names)
{
myItems = new Express_HSequenceOfItem;
}
Handle(TColStd_HSequenceOfInteger) seqMember = new TColStd_HSequenceOfInteger;
Handle(TColStd_HSequenceOfInteger) seqEntities = new TColStd_HSequenceOfInteger;
- for ( Standard_Integer i=1; i <= myItems->Length(); i++ ) {
+ for (Standard_Integer i = 1; i <= myItems->Length(); i++)
+ {
Handle(Express_Item) item = myItems->Value(i);
if (item->IsKind(STANDARD_TYPE(Express_Entity)) || item->IsKind(STANDARD_TYPE(Express_Select))
|| item->IsKind(STANDARD_TYPE(Express_Alias)) || item->IsKind(STANDARD_TYPE(Express_ComplexType)))
- seqEntities->Append(i);
- else seqMember->Append(i);
-
+ {
+ seqEntities->Append(i);
+ }
+ else
+ {
+ seqMember->Append(i);
+ }
}
std::cout << "Generating SELECT " << CPPname->ToCString() << std::endl;
- if(!seqMember->IsEmpty()) {
- std::cout << "Generating SELECTMember " << CPPname->ToCString() << "Member"<< std::endl;
+ if (!seqMember->IsEmpty())
+ {
+ std::cout << "Generating SELECTMember " << CPPname->ToCString() << "Member" << std::endl;
GenerateSelectMember(seqMember);
}
// create a package directory (if not yet exist)
- OSD_Protection prot ( OSD_RX, OSD_RWX, OSD_RX, OSD_RX );
+ OSD_Protection prot(OSD_RX, OSD_RWX, OSD_RX, OSD_RX);
TCollection_AsciiString pack = GetPackageName()->String();
- OSD_Path path ( pack );
- OSD_Directory dir ( path );
- dir.Build ( prot );
+ OSD_Path path(pack);
+ OSD_Directory dir(path);
+ dir.Build(prot);
pack += "/";
pack += CPPname->String();
-
+
//===============================
// Step 1: generating HXX
os << "class StepData_SelectMember;" << std::endl;
Standard_Integer jj = 1;
- for (Standard_Integer i = 1; i <= myItems->Length(); i++) {
+ for (Standard_Integer i = 1; i <= myItems->Length(); i++)
+ {
Handle(Express_Item) item = myItems->Value(i);
item->Use(GetPackageName());
- if (item->IsKind(STANDARD_TYPE(Express_Alias))) {
+ if (item->IsKind(STANDARD_TYPE(Express_Alias)))
+ {
Handle(Express_Type) type = Handle(Express_Alias)::DownCast(item)->Type();
TCollection_AsciiString ats = type->CPPName()->String();
if (type->IsStandard()) //(STANDARD_TYPE(Express_PredefinedType)))
+ {
continue;
+ }
}
os << "class " << item->CPPName()->ToCString() << ";" << std::endl;
jj++;
// write common methods section
os << " //! Recognizes a kind of " << Name()->ToCString() << " select type" << std::endl;
- for (Standard_Integer i = 1; i <= seqEntities->Length(); i++) {
+ for (Standard_Integer i = 1; i <= seqEntities->Length(); i++)
+ {
Standard_Integer ind = seqEntities->Value(i);
os << " //! -- " << i << " -> " << myNames->Value(ind)->ToCString() << std::endl;
}
os << " Standard_EXPORT Standard_Integer CaseNum (const Handle(Standard_Transient)& ent) const Standard_OVERRIDE;" << std::endl;
os << std::endl;
- if(!seqMember->IsEmpty()) {
+ if(!seqMember->IsEmpty())
+ {
os << " //! Recognizes items of select member " << Name()->ToCString() << "Member" << std::endl;
- for (Standard_Integer i = 1; i <= seqMember->Length(); i++) {
+ for (Standard_Integer i = 1; i <= seqMember->Length(); i++)
+ {
Standard_Integer ind = seqMember->Value(i);
os << " //! -- " << i << " -> " << myNames->Value(ind)->ToCString() << std::endl;
}
}
// write methods get for entities
- for (Standard_Integer i = 1; i <= seqEntities->Length(); i++) {
+ for (Standard_Integer i = 1; i <= seqEntities->Length(); i++)
+ {
Standard_Integer ind = seqEntities->Value(i);
Handle(Express_Item) item = myItems->Value(ind);
Handle(TCollection_HAsciiString) name = item->Name();
os << " //! Returns Value as " << name->ToCString() << " (or Null if another type)" << std::endl;
- os << " Standard_EXPORT Handle(" << item->CPPName()->ToCString() << ") " << name->ToCString() << "() const;" << std::endl;
+ os << " Standard_EXPORT Handle(" << item->CPPName()->ToCString() << ") " <<
+ name->ToCString() << "() const;" << std::endl;
os << std::endl;
}
// writes method set and get for enum , integer, real and string.
- for (Standard_Integer i = 1; i <= seqMember->Length(); i++) {
+ for (Standard_Integer i = 1; i <= seqMember->Length(); i++)
+ {
Standard_Integer ind = seqMember->Value(i);
Handle(Express_Item) item = myItems->Value(ind);
Handle(TCollection_HAsciiString) name = item->Name();
// write include section
os << "#include <" << CPPname->ToCString() << ".hxx>" << std::endl;
- if(!seqMember->IsEmpty()) {
+ if(!seqMember->IsEmpty())
+ {
os << "#include <" << CPPName()->ToCString() << "Member.hxx>"<< std::endl;
os << "#include <TCollection_HAsciiString.hxx>"<< std::endl;
}
- for (Standard_Integer i = 1; i <= seqEntities->Length(); i++) {
+ for (Standard_Integer i = 1; i <= seqEntities->Length(); i++)
+ {
Standard_Integer ind = seqEntities->Value(i);
- os << "#include <" <<
- myItems->Value(ind)->CPPName()->ToCString() << ".hxx>" << std::endl;
+ os << "#include <" << myItems->Value(ind)->CPPName()->ToCString() << ".hxx>" << std::endl;
}
// write constructor
os << "{" << std::endl << "}" << std::endl;
// write CaseNum method
- Express::WriteMethodStamp ( os, new TCollection_HAsciiString ( "CaseNum" ) );
- os << "Standard_Integer " << CPPname->ToCString() << "::CaseNum (const Handle(Standard_Transient)& ent) const" << std::endl;
+ Express::WriteMethodStamp(os, new TCollection_HAsciiString("CaseNum"));
+ os << "Standard_Integer " << CPPname->ToCString() <<
+ "::CaseNum (const Handle(Standard_Transient)& ent) const" << std::endl;
os << "{" << std::endl;
- if(!seqEntities->IsEmpty()) {
+ if(!seqEntities->IsEmpty())
+ {
os << " if (ent.IsNull()) return 0;" << std::endl;
- for (Standard_Integer i=1; i <= seqEntities->Length(); i++ ) {
+ for (Standard_Integer i = 1; i <= seqEntities->Length(); i++)
+ {
Standard_Integer ind = seqEntities->Value(i);
- os << " if (ent->IsKind(STANDARD_TYPE(" <<
+ os << " if (ent->IsKind(STANDARD_TYPE(" <<
myItems->Value(ind)->CPPName()->ToCString() << "))) return " << i << ";" << std::endl;
}
os << " return 0;\n}" << std::endl;
}
- else os << " return 0;\n}" << std::endl;
+ else
+ {
+ os << " return 0;\n}" << std::endl;
+ }
- if(!seqMember->IsEmpty()) { //gka for AP209
+ if (!seqMember->IsEmpty())
+ { //gka for AP209
//write CaseMem method
- Express::WriteMethodStamp ( os, new TCollection_HAsciiString ( "CaseMem" ) );
- os<<"Standard_Integer "<<CPPname->ToCString()<<"::CaseMem (const Handle(StepData_SelectMember)& ent) const"<< std::endl;
- os<<"{"<< std::endl;
- os<<" if(ent.IsNull()) return 0;"<< std::endl;
+ Express::WriteMethodStamp(os, new TCollection_HAsciiString("CaseMem"));
+ os << "Standard_Integer " << CPPname->ToCString() <<
+ "::CaseMem (const Handle(StepData_SelectMember)& ent) const" << std::endl;
+ os << "{" << std::endl;
+ os << " if(ent.IsNull()) return 0;" << std::endl;
//os<<" Handle("<< CPPName()->ToCString()<<"Member sm = Handle("<<CPPName()->ToCString()<<"Member)::DownCast(ent);"<< std::endl;
//os<<" if(sm.IsNull()) return 0;"<< std::endl;
//os<<" Handle(TCollection_HAsciiString) name;"<< std::endl;
- for( int j = 1; j<= seqMember->Length(); j++) {
+ for (int j = 1; j <= seqMember->Length(); j++)
+ {
Standard_Integer ind = seqMember->Value(j);
//os<<" name = new TCollection_HAsciiString(\""<<myNames->Value(ind)->ToCString()<<"\");"<< std::endl;
- if(j ==1)
- os<<" if(ent->Matches(\""<<myNames->Value(ind)->ToCString()<< "\")) return "<<j<<";"<< std::endl;
- else os<<" else if(ent->Matches(\""<<myNames->Value(ind)->ToCString()<< "\")) return "<<j<<";"<< std::endl;
+ if (j == 1)
+ {
+ os << " if(ent->Matches(\"" << myNames->Value(ind)->ToCString() << "\")) return " << j << ";" << std::endl;
+ }
+ else
+ {
+ os << " else if(ent->Matches(\"" << myNames->Value(ind)->ToCString() << "\")) return " << j << ";" << std::endl;
+ }
}
- os<<" else return 0;"<< std::endl;
- os<<"}"<< std::endl;
-
+ os << " else return 0;" << std::endl;
+ os << "}" << std::endl;
+
//write NewMember method
- Express::WriteMethodStamp ( os, new TCollection_HAsciiString ( "NewMember" ) );
- os<<"Handle(StepData_SelectMember) "<<CPPname->ToCString()<<"::NewMember() const"<< std::endl;
- os<<"{"<< std::endl;
- os<<" return new "<<CPPname->ToCString()<<"Member;"<< std::endl;
- os<<"}"<< std::endl;
-
+ Express::WriteMethodStamp(os, new TCollection_HAsciiString("NewMember"));
+ os << "Handle(StepData_SelectMember) " << CPPname->ToCString() << "::NewMember() const" << std::endl;
+ os << "{" << std::endl;
+ os << " return new " << CPPname->ToCString() << "Member;" << std::endl;
+ os << "}" << std::endl;
}
-
// write methods Get for entities.
- for (Standard_Integer i=1; i <= seqEntities->Length(); i++ ) {
+ for (Standard_Integer i = 1; i <= seqEntities->Length(); i++)
+ {
Standard_Integer ind = seqEntities->Value(i);
Handle(Express_Item) item = myItems->Value(ind);
- Express::WriteMethodStamp ( os, item->Name() );
+ Express::WriteMethodStamp(os, item->Name());
os << "Handle(" << item->CPPName()->ToCString() << ") " << CPPname->ToCString() <<
- "::" << item->Name()->ToCString() << " () const" << std::endl;
+ "::" << item->Name()->ToCString() << " () const" << std::endl;
os << "{\n return Handle(" << item->CPPName()->ToCString() << ")::DownCast(Value());\n}" << std::endl;
}
//write methods Set and Get for Integer, Real, String and Enum
- for (Standard_Integer i=1; i <= seqMember->Length(); i++ ) {
+ for (Standard_Integer i = 1; i <= seqMember->Length(); i++)
+ {
Standard_Integer ind = seqMember->Value(i);
Handle(Express_Item) item = myItems->Value(ind);
Handle(TCollection_HAsciiString) stamp = new TCollection_HAsciiString("Set");
stamp->AssignCat(item->Name());
- Express::WriteMethodStamp ( os, stamp );
-
- Standard_Boolean isString = (item->CPPName()->String().Location("HAsciiString",1,item->CPPName()->Length()) > 0);
+ Express::WriteMethodStamp(os, stamp);
+
+ Standard_Boolean isString = (item->CPPName()->String().Location("HAsciiString", 1, item->CPPName()->Length()) > 0);
Handle(TCollection_HAsciiString) nameFunc = new TCollection_HAsciiString;
Handle(TCollection_HAsciiString) Func = new TCollection_HAsciiString;
Standard_Boolean isEnum = item->IsKind(STANDARD_TYPE(Express_Enum));
- if(!isEnum) {
- if(isString)
+ if (!isEnum)
+ {
+ if (isString)
+ {
Func->AssignCat("String");
- else {
+ }
+ else
+ {
nameFunc->AssignCat(item->CPPName());
Func = nameFunc;
- Standard_Integer splitind = nameFunc->String().Location("_",1,item->CPPName()->Length());
- if(splitind)
+ Standard_Integer splitind = nameFunc->String().Location("_", 1, item->CPPName()->Length());
+ if (splitind)
+ {
Func = nameFunc->Split(splitind);
+ }
}
}
-
+
//write method set
- if(isString) {
- os << "void "<<CPPname->ToCString() <<
- "::" << "Set"<<item->Name()->ToCString() << " (const Handle("<<item->CPPName()->ToCString() << ") &val)" << std::endl;
+ if (isString)
+ {
+ os << "void " << CPPname->ToCString() << "::" << "Set" << item->Name()->ToCString() <<
+ " (const Handle(" << item->CPPName()->ToCString() << ") &val)" << std::endl;
+ }
+ else
+ {
+ os << "void " << CPPname->ToCString() << "::" << "Set" << item->Name()->ToCString() <<
+ " (const " << item->CPPName()->ToCString() << " val)" << std::endl;
}
- else
- os << "void "<<CPPname->ToCString() <<
- "::" << "Set"<<item->Name()->ToCString() << " (const "<<item->CPPName()->ToCString() << " val)" << std::endl;
- os<<"{"<< std::endl;
-
- os<< " Handle("<<CPPname->ToCString()<<"Member) SelMem = Handle(" << CPPname->ToCString()<<"Member)::DownCast(Value());"<< std::endl;
- os<<" if(SelMem.IsNull()) return;"<< std::endl;
- os<<" Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString(\""<<item->Name()->ToCString()<<"\");"<< std::endl;
- os<<" SelMem->SetName(name->ToCString());"<< std::endl;
- if(isEnum)
- os<<" SelMem->SetEnum((Standard_Integer)val);"<< std::endl;
- else if(isString)
- os<<" SelMem->Set"<<Func->ToCString()<<"(val->ToCString());"<< std::endl;
- else
- os<<" SelMem->Set"<<Func->ToCString()<<"(val);"<< std::endl;
-
- os<<"}"<< std::endl;
-
+ os << "{" << std::endl;
+ os << " Handle(" << CPPname->ToCString() << "Member) SelMem = Handle(" <<
+ CPPname->ToCString() << "Member)::DownCast(Value());" << std::endl;
+ os << " if(SelMem.IsNull()) return;" << std::endl;
+ os << " Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString(\"" <<
+ item->Name()->ToCString() << "\");" << std::endl;
+ os << " SelMem->SetName(name->ToCString());" << std::endl;
+ if (isEnum)
+ {
+ os << " SelMem->SetEnum((Standard_Integer)val);" << std::endl;
+ }
+ else if (isString)
+ {
+ os << " SelMem->Set" << Func->ToCString() << "(val->ToCString());" << std::endl;
+ }
+ else
+ {
+ os << " SelMem->Set" << Func->ToCString() << "(val);" << std::endl;
+ }
+ os << "}" << std::endl;
+
//write method get
- Express::WriteMethodStamp ( os, item->Name() );
- if(isString)
- os << "Handle("<<item->CPPName()->ToCString() << ") "<<CPPname->ToCString() <<
- "::" << item->Name()->ToCString() << " () const" << std::endl;
- else
- os << item->CPPName()->ToCString() << " "<<CPPname->ToCString() <<
- "::" << item->Name()->ToCString() << " () const" << std::endl;
-
- os<<"{"<< std::endl;
- os<< " Handle("<<CPPname->ToCString()<<"Member) SelMem = Handle(" << CPPname->ToCString()<<"Member)::DownCast(Value());"<< std::endl;
- os<<" if(SelMem.IsNull()) return 0;"<< std::endl;
- os<<" Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString;"<< std::endl;
- os<<" name->AssignCat(SelMem->Name());"<< std::endl;
- os<<" Handle(TCollection_HAsciiString) nameitem = new TCollection_HAsciiString(\""<<item->Name()->ToCString()<<"\");"<< std::endl;
- os<<" if(name->IsDifferent(nameitem)) return 0;"<< std::endl;
- if(isEnum) {
+ Express::WriteMethodStamp(os, item->Name());
+ if (isString)
+ {
+ os << "Handle(" << item->CPPName()->ToCString() << ") " << CPPname->ToCString() <<
+ "::" << item->Name()->ToCString() << " () const" << std::endl;
+ }
+ else
+ {
+ os << item->CPPName()->ToCString() << " " << CPPname->ToCString() <<
+ "::" << item->Name()->ToCString() << " () const" << std::endl;
+ }
+
+ os << "{" << std::endl;
+ os << " Handle(" << CPPname->ToCString() << "Member) SelMem = Handle(" << CPPname->ToCString() <<
+ "Member)::DownCast(Value());" << std::endl;
+ os << " if(SelMem.IsNull()) return 0;" << std::endl;
+ os << " Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString;" << std::endl;
+ os << " name->AssignCat(SelMem->Name());" << std::endl;
+ os << " Handle(TCollection_HAsciiString) nameitem = new TCollection_HAsciiString(\"" <<
+ item->Name()->ToCString() << "\");" << std::endl;
+ os << " if(name->IsDifferent(nameitem)) return 0;" << std::endl;
+ if (isEnum)
+ {
//nameFunc.AssignCat(item->Name()->ToCString());
- os<<" Standard_Integer numit = SelMem->Enum();"<< std::endl;
- os<<" "<<item->CPPName()->ToCString()<<" val;"<< std::endl;
- os<<" switch(numit) {"<< std::endl;
+ os << " Standard_Integer numit = SelMem->Enum();" << std::endl;
+ os << " " << item->CPPName()->ToCString() << " val;" << std::endl;
+ os << " switch(numit) {" << std::endl;
Handle(Express_Enum) Enum = Handle(Express_Enum)::DownCast(item);
- Handle(TColStd_HSequenceOfHAsciiString) enitems = Enum->Names();
+ Handle(TColStd_HSequenceOfHAsciiString) enitems = Enum->Names();
Handle(TCollection_HAsciiString) prefix = Express::EnumPrefix(item->Name());
- for(Standard_Integer k = 1; k <= enitems->Length(); k++)
- os<<" case "<<k<<" : val = "<<item->Name()->ToCString()<<"_"<<prefix->ToCString()<<enitems->Value(k)->ToCString()<<"; break;"<< std::endl;
- os<<" default : return 0;break;"<< std::endl;
- os<<" }"<< std::endl;
+ for (Standard_Integer k = 1; k <= enitems->Length(); k++)
+ {
+ os << " case " << k << " : val = " << item->Name()->ToCString() << "_" << prefix->ToCString() <<
+ enitems->Value(k)->ToCString() << "; break;" << std::endl;
+ }
+ os << " default : return 0;break;" << std::endl;
+ os << " }" << std::endl;
}
- else if(isString) {
- os<<" Handle(TCollection_HAsciiString) val = new TCollection_HAsciiString;"<< std::endl;
- os<<" val->AssignCat(SelMem->String());"<< std::endl;
+ else if (isString)
+ {
+ os << " Handle(TCollection_HAsciiString) val = new TCollection_HAsciiString;" << std::endl;
+ os << " val->AssignCat(SelMem->String());" << std::endl;
}
-
- else
- os<<" "<<item->CPPName()->ToCString()<<" val = SelMem->"<<Func->ToCString()<<"();"<< std::endl;
-
-
- os<<" return val;"<< std::endl;
- os<<"}"<< std::endl;
-
+ else
+ {
+ os << " " << item->CPPName()->ToCString() << " val = SelMem->" << Func->ToCString() << "();" << std::endl;
+ }
+
+ os << " return val;" << std::endl;
+ os << "}" << std::endl;
+
}
// close CXX
os.close();
-
+
return Standard_True;
}
//=======================================================================
os << "class " << CPPname->ToCString() << " : public StepData_SelectNamed" << std::endl;
os << "{" << std::endl;
os << "public:" << std::endl;
-
- // write methods
+
+ // write methods
os << " //! Empty constructor" << std::endl;
os << " Standard_EXPORT " << CPPname->ToCString() << "();" << std::endl;
os << std::endl;
-
+
os << " //! Returns True if has name" << std::endl;
os << " Standard_EXPORT virtual Standard_Boolean HasName() const Standard_OVERRIDE;" << std::endl;
os << std::endl;
os << " Standard_EXPORT virtual Standard_CString Name() const Standard_OVERRIDE;" << std::endl;
os << std::endl;
os << " //! Set name" << std::endl;
- os << " Standard_EXPORT virtual Standard_Boolean SetName(const Standard_CString name) Standard_OVERRIDE;" << std::endl;
+ os << " Standard_EXPORT virtual Standard_Boolean SetName(const Standard_CString name) Standard_OVERRIDE;"
+ << std::endl;
os << std::endl;
os << " //! Tells if the name of a SelectMember matches a given one;" << std::endl;
- os << " Standard_EXPORT virtual Standard_Boolean Matches(const Standard_CString name) const Standard_OVERRIDE;" << std::endl;
+ os << " Standard_EXPORT virtual Standard_Boolean Matches(const Standard_CString name) const Standard_OVERRIDE;"
+ << std::endl;
os << std::endl;
//write fields
- os <<"private:"<< std::endl;
- os << " Standard_Integer myCase;"<< std::endl<< std::endl;
+ os << "private:" << std::endl;
+ os << " Standard_Integer myCase;" << std::endl << std::endl;
// write end
os << "};" << std::endl;
os << "#endif // _" << CPPname->ToCString() << "_HeaderFile" << std::endl;
//===============================
// Step 2: generating CXX
// Open CXX file
- os.open ( pack.Cat ( ".cxx" ).ToCString() );
+ os.open(pack.Cat(".cxx").ToCString());
// write header
- Express::WriteFileStamp ( os );
+ Express::WriteFileStamp(os);
// write include section
os << "#include <" << CPPname->ToCString() << ".hxx>" << std::endl;
- os << "#include <TCollection_HAsciiString.hxx>"<< std::endl;
+ os << "#include <TCollection_HAsciiString.hxx>" << std::endl;
// write constructor
- Express::WriteMethodStamp ( os, CPPname );
+ Express::WriteMethodStamp(os, CPPname);
os << CPPname->ToCString() << "::" << CPPname->ToCString() << " () : myCase(0) " << std::endl;
os << "{" << std::endl << "}" << std::endl;
-
+
//write method HasName
- Express::WriteMethodStamp ( os, new TCollection_HAsciiString ("HasName") );
- os<<"Standard_Boolean "<<CPPname->ToCString()<<"::HasName() const"<< std::endl;
+ Express::WriteMethodStamp(os, new TCollection_HAsciiString("HasName"));
+ os << "Standard_Boolean " << CPPname->ToCString() << "::HasName() const" << std::endl;
os << "{" << std::endl;
- os<< " return myCase > 0;"<< std::endl;
- os<< "}" << std::endl;
-
+ os << " return myCase > 0;" << std::endl;
+ os << "}" << std::endl;
+
Standard_Boolean hasEnum = Standard_False;
//write method Name
- Express::WriteMethodStamp ( os, new TCollection_HAsciiString ("Name") );
- os<<"Standard_CString "<<CPPname->ToCString()<<"::Name() const"<< std::endl;
+ Express::WriteMethodStamp(os, new TCollection_HAsciiString("Name"));
+ os << "Standard_CString " << CPPname->ToCString() << "::Name() const" << std::endl;
os << "{" << std::endl;
- os << " Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString;"<< std::endl;
- os << " switch(myCase) {"<< std::endl;
+ os << " Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString;" << std::endl;
+ os << " switch(myCase) {" << std::endl;
Standard_Integer i = 1;
- for( i = 1; i <= seqMember->Length(); i++) {
+ for (i = 1; i <= seqMember->Length(); i++)
+ {
Standard_Integer ind = seqMember->Value(i);
Handle(Express_Item) item = myItems->Value(ind);
- if(item->IsKind(STANDARD_TYPE(Express_Enum)))
+ if (item->IsKind(STANDARD_TYPE(Express_Enum)))
+ {
hasEnum = Standard_True;
- os << " case "<<i<<" : aName->AssignCat(\""<<myNames->Value(ind)->ToCString()<<"\"); break;"<< std::endl;
+ }
+ os << " case " << i << " : aName->AssignCat(\"" << myNames->Value(ind)->ToCString() << "\"); break;" << std::endl;
}
- os << " default : break;"<< std::endl;
- os<<" }"<< std::endl;
- os<<" return aName->ToCString();"<< std::endl;
- os<< "}" << std::endl;
-
+ os << " default : break;" << std::endl;
+ os << " }" << std::endl;
+ os << " return aName->ToCString();" << std::endl;
+ os << "}" << std::endl;
+
//write static method for compare name
- Express::WriteMethodStamp ( os, new TCollection_HAsciiString ("CompareNames") );
- os<<"static Standard_Integer CompareNames(const Standard_CString name";
- if(hasEnum)
- os<<",Standard_Integer &numen) "<< std::endl;
+ Express::WriteMethodStamp(os, new TCollection_HAsciiString("CompareNames"));
+ os << "static Standard_Integer CompareNames(const Standard_CString name";
+ if (hasEnum)
+ {
+ os << ",Standard_Integer &numen) " << std::endl;
+ }
else
- os<<")"<< std::endl;
+ {
+ os << ")" << std::endl;
+ }
os << "{" << std::endl;
- os << " Standard_Integer thecase = 0;"<< std::endl;
- os << " if (!name || name[0] == \'/0\') thecase = 0;"<< std::endl;
- for( i = 1; i <= seqMember->Length(); i++) {
+ os << " Standard_Integer thecase = 0;" << std::endl;
+ os << " if (!name || name[0] == \'/0\') thecase = 0;" << std::endl;
+ for (i = 1; i <= seqMember->Length(); i++)
+ {
Standard_Integer ind = seqMember->Value(i);
Handle(Express_Item) item = myItems->Value(ind);
- if(item->IsKind(STANDARD_TYPE(Express_Enum))) {
+ if (item->IsKind(STANDARD_TYPE(Express_Enum)))
+ {
Handle(Express_Enum) en = Handle(Express_Enum)::DownCast(item);
- for(Standard_Integer k =1 ; k <= en->Names()->Length();k++) {
- os<<" else if(!strcmp (name,\""<<en->Names()->Value(k)->ToCString()<<"\")) { "<< std::endl;
- os<<" thecase = "<<i<<";"<< std::endl;
- os<<" numen = "<<k<<";"<< std::endl;
- os<<" }"<< std::endl;
-
+ for (Standard_Integer k = 1; k <= en->Names()->Length(); k++)
+ {
+ os << " else if(!strcmp (name,\"" << en->Names()->Value(k)->ToCString() << "\")) { " << std::endl;
+ os << " thecase = " << i << ";" << std::endl;
+ os << " numen = " << k << ";" << std::endl;
+ os << " }" << std::endl;
}
}
else
- os<<" else if(!strcmp (name,\""<<myNames->Value(ind)->ToCString()<<"\")) thecase = "<<i<<";"<< std::endl;
+ {
+ os << " else if(!strcmp (name,\"" << myNames->Value(ind)->ToCString() << "\")) thecase = " << i << ";" << std::endl;
+ }
}
- os << " return thecase;"<< std::endl;
+ os << " return thecase;" << std::endl;
os << "}" << std::endl;
-
+
//write method SetName
- Express::WriteMethodStamp ( os, new TCollection_HAsciiString ("SetName") );
- os<<"Standard_Boolean "<<CPPname->ToCString()<<"::SetName(const Standard_CString name) "<< std::endl;
+ Express::WriteMethodStamp(os, new TCollection_HAsciiString("SetName"));
+ os << "Standard_Boolean " << CPPname->ToCString() << "::SetName(const Standard_CString name) " << std::endl;
os << "{" << std::endl;
- if(hasEnum) {
- os << " Standard_Integer numit = 0;"<< std::endl;
- os << " myCase = CompareNames(name,numit);"<< std::endl;
-
- os << " if (numit) SetInteger(numit);"<< std::endl;
+ if (hasEnum)
+ {
+ os << " Standard_Integer numit = 0;" << std::endl;
+ os << " myCase = CompareNames(name,numit);" << std::endl;
+ os << " if (numit) SetInteger(numit);" << std::endl;
}
else
- os << " myCase = CompareNames(name);"<< std::endl;
- os << " return (myCase >0);"<< std::endl;
-
- os<< "}" << std::endl;
+ {
+ os << " myCase = CompareNames(name);" << std::endl;
+ }
+ os << " return (myCase >0);" << std::endl;
+ os << "}" << std::endl;
+
//write method Matches
- Express::WriteMethodStamp ( os, new TCollection_HAsciiString ("Matches") );
- os<<"Standard_Boolean "<<CPPname->ToCString()<<"::Matches(const Standard_CString name) const"<< std::endl;
+ Express::WriteMethodStamp(os, new TCollection_HAsciiString("Matches"));
+ os << "Standard_Boolean " << CPPname->ToCString() << "::Matches(const Standard_CString name) const" << std::endl;
os << "{" << std::endl;
- if(hasEnum) {
- os << " Standard_Integer numit = 0;"<< std::endl;
- os<< " Standard_Integer thecase = CompareNames(name,numit);"<< std::endl;
+ if (hasEnum)
+ {
+ os << " Standard_Integer numit = 0;" << std::endl;
+ os << " Standard_Integer thecase = CompareNames(name,numit);" << std::endl;
}
else
- os<< " Standard_Integer thecase = CompareNames(name);"<< std::endl;
- os << " return (thecase > 0);"<< std::endl;
+ {
+ os << " Standard_Integer thecase = CompareNames(name);" << std::endl;
+ }
+ os << " return (thecase > 0);" << std::endl;
os << "}" << std::endl;
return Standard_True;
-}
+ }
{
public:
-
//! Create SELECT item and initialize it
Standard_EXPORT Express_Select(const Standard_CString name, const Handle(TColStd_HSequenceOfHAsciiString)& names);
//! Create HXX/CXX files from item
Standard_EXPORT virtual Standard_Boolean GenerateClass() const Standard_OVERRIDE;
-
-
-
DEFINE_STANDARD_RTTIEXT(Express_Select,Express_Item)
protected:
-
-
-
private:
-
Standard_EXPORT Standard_Boolean GenerateSelectMember (const Handle(TColStd_HSequenceOfInteger)& seqMember) const;
Handle(TColStd_HSequenceOfHAsciiString) myNames;
Handle(Express_HSequenceOfItem) myItems;
-
};
-
-
-
-
-
-
#endif // _Express_Select_HeaderFile
typedef NCollection_Sequence<Handle(Express_Entity)> Express_SequenceOfEntity;
-
#endif
typedef NCollection_Sequence<Handle(Express_Field)> Express_SequenceOfField;
-
#endif
typedef NCollection_Sequence<Handle(Express_Item)> Express_SequenceOfItem;
-
#endif
#define _Express_String_HeaderFile
#include <Standard_Type.hxx>
-
#include <Express_PredefinedType.hxx>
-
class TCollection_HAsciiString;
-
//! Implements EXPRESS type 'STRING'
class Express_String : public Express_PredefinedType
{
public:
-
//! Empty constructor
Standard_EXPORT Express_String();
//! Returns False
Standard_EXPORT virtual Standard_Boolean IsStandard() const Standard_OVERRIDE;
-
-
-
DEFINE_STANDARD_RTTIEXT(Express_String,Express_PredefinedType)
protected:
-
-
-
private:
-
-
-
};
-
-
-
-
-
-
#endif // _Express_String_HeaderFile
//purpose :
//=======================================================================
-Standard_Boolean Express_Type::Use (const Handle(TCollection_HAsciiString) &,
- const Standard_Boolean ) const
+Standard_Boolean Express_Type::Use(
+ const Handle(TCollection_HAsciiString) &,
+ const Standard_Boolean ) const
{
return Standard_False;
}
{
public:
-
//! Returns CPP-style name of the type
Standard_EXPORT virtual Handle(TCollection_HAsciiString) CPPName() const = 0;
//! 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 Handle(TCollection_HAsciiString)& pack, const Standard_Boolean defer = Standard_False) const;
-
-
-
+ Standard_EXPORT virtual Standard_Boolean Use(
+ const Handle(TCollection_HAsciiString)& pack,
+ const Standard_Boolean defer = Standard_False) const;
DEFINE_STANDARD_RTTIEXT(Express_Type,Standard_Transient)
protected:
-
//! Empty constructor
Standard_EXPORT Express_Type();
-
-
private:
-
-
-
};
-
-
-
-
-
-
#endif // _Express_Type_HeaderFile