Overview
The RoseP21Parser class is an internal utility class used for reading object data from STEP ISO 10303-21 (Part 21) formatted files. It is not created or used directly, but it does have a few class variables that can be adjusted to customize how files are read.
See STEP Part 21 Exchange Files for more information on writing and customizing STEP files.
add_schema_fn
typedef RoseErrorCode (*RoseP21AddSchemaFn) ( RoseDesign * design, const char * name ); static RoseP21AddSchemaFn add_schema_fn;
This hook function is deprecated, use set_schemas_fn instead, which is more flexible since it gets all of the schema names at once rather than one by one. This lets the set_schemas hook test for an empty schema list, which the add_schema hook can not do.
The add_schema_fn static class variable can specify a hook function that will be called for each schema name found in the FILE_SCHEMA() entry within the header section of a Part 21 file.
This function takes a design pointer and a schema name, and should find the appropriate compiled schema and add it to the design. A return value of ROSE_OK indicates successful completion while a non-zero value indicates an error.
By default, this value is null and the rose_p21_dflt_add_schema() function is called to add schemas.
RoseErrorCode a_simple_add_schema_function ( RoseDesign * design, const char * sname ) { /* like findDesign(), but ignores case and ASN/1 idents */ RoseDesign * schema = rose_p21_find_schema (sname); if (schema) { design-> addSchema (schema); return ROSE_OK; } return ROSE_IO_BAD_SCHEMA; } // Somewhere in your main RoseP21Parser::set_schema_fn = custom_set_schemas;
See Also
allow_bad_schemas
static RoseBoolean allow_bad_schemas;
The allow_bad_schemas static class variable can controls whether or not to continue reading if the Part 21 reader can not find the compiled schema definitions for a file. If no compiled schema definitions are found, the parser will probably not be able to process many of the instances in the file.
By default, this variable is set to false, and if schema cannot by found, the filer generates a single error for the schema itself, and the RoseDesign that is returned from ROSE.findDesign() is NULL.
If this variable is set to true, the filer attempts to read as much as it can. If schemas are missing, it unlikely to find the compiled EXPRESS definition for many entities. When it can not fine a definition, it will issue a warning and skip the instance. This may result in many messages and a RoseDesign containing no instances.
/* try to keep reading, even with missing schema */ RoseP21Parser::allow_bad_schemas = ROSE_TRUE; /* (default) generate an error, do not continue reading */ RoseP21Parser::allow_bad_schemas = ROSE_FALSE;
See Also
set_schemas_fn
typedef RoseErrorCode (*RoseP21SetSchemasFn) ( RoseDesign * design, ListOfString * all_schemas ); static RoseP21SetSchemasFn set_schemas_fn;
The set_schemas_fn static class variable can specify a hook function that will be called to process the schema names found in the FILE_SCHEMA() entry in the header section of a Part 21 file.
This function takes a pointer to the design being read and a list of strings containing the schema names. It should scan the schema names, find the appropriate compiled schemas, and add them to the design. The function should return ROSE_OK on success or a non-zero value to indicate an error.
An application can use this hook is used to substitute schemas, ignore certain schemas, or look for certain combinations of names. The Merged AP library uses this feature to substitute its own merged schema for the AP242, AP203, AP214 or other schema listed in the Part 21 file.
By default, this value is null and the rose_p21_dflt_add_schema() function is called on each schema.
RoseErrorCode custom_set_schemas ( RoseDesign * design, ListOfString * all_schemas ) { if (!all_schemas || !all_schemas-> size()) { printf ("NO SCHEMAS\n"); return ROSE_IO_BAD_SCHEMA; } unsigned i, sz; for (i=0, sz=all_schemas->size(); i<sz; i++) { const char * sname = all_schemas-> get(i); /* like findDesign(), but ignores case and ASN/1 idents */ RoseDesign * schema = rose_p21_find_schema (sname); if (schema) { design-> addSchema (schema); } return ROSE_IO_BAD_SCHEMA; } return ROSE_OK; }
See Also
status_fn / status_freq
typedef RoseErrorCode (*RoseP21ReadStatusFn) ( RoseP21Parser *, unsigned long ); static RoseP21ReadStatusFn status_fn; static unsigned status_freq;
The status_fn static class variable specifies a hook function that will be called periodically when reading a Part 21 file. The status_freq variable gives the calling frequency as a number of objects. A value of 100 means the status function will be called after every 100 objects are read. A value of 1 means the function will be called after every object. If the calling frequency is zero or the function pointer is null, the status function will not be called.
The status function returns a RoseErrorCode. Successful completion is indicated by the value ROSE_OK. If a non-zero value is returned, file writing will be halted, so applications can use this to implement a cancel button for a status bar.