Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Member Functions
StepData_StepWriter Class Reference

manages atomic file writing, under control of StepModel (for general organisation of file) and each class of Transient (for its own parameters) : prepares text to be written then writes it A stream cannot be used because Step limits line length at 72 In more, a specific object offers more appropriate functions More...

#include <StepData_StepWriter.hxx>

Public Member Functions

 StepData_StepWriter (const occ::handle< StepData_StepModel > &amodel)
 Creates an empty StepWriter from a StepModel. The StepModel provides the Number of Entities, as identifiers for File.
 
intLabelMode ()
 ModeLabel controls how to display entity ids : 0 (D) gives entity number in the model 1 gives the already recorded label (else, its number) Warning : conflicts are not controlled.
 
intTypeMode ()
 TypeMode controls the type form to use : 0 (D) for normal long form 1 for short form (if a type name has no short form, normal long form is then used)
 
Interface_FloatWriterFloatWriter ()
 Returns the embedded FloatWriter, which controls sending Reals Use this method to access FloatWriter in order to consult or change its options (MainFormat, FormatForRange,ZeroSuppress), because it is returned as the address of its field.
 
void SetScope (const int numscope, const int numin)
 Declares the Entity Number <numscope> to correspond to a Scope which contains the Entity Number <numin>. Several calls to the same <numscope> add Entities in this Scope, in this order. Error if <numin> is already declared in the Scope Warning : the declaration of the Scopes is assumed to be consistent, i.e. <numin> is not referenced from outside this Scope (not checked here)
 
bool IsInScope (const int num) const
 Returns True if an Entity identified by its Number is in a Scope.
 
void SendModel (const occ::handle< StepData_Protocol > &protocol, const bool headeronly=false)
 Sends the complete Model, included HEADER and DATA Sections Works with a WriterLib defined through a Protocol If <headeronly> is given True, only the HEADER Section is sent (used to Dump the Header of a StepModel)
 
void SendHeader ()
 Begins model header.
 
void SendData ()
 Begins data section; error if EndSec was not set.
 
void SendEntity (const int nument, const StepData_WriterLib &lib)
 Send an Entity of the Data Section. If it corresponds to a Scope, also Sends the Scope information and contained Items.
 
void EndSec ()
 sets end of section; to be done before passing to next one
 
void EndFile ()
 sets end of file; error is EndSec was not set
 
void NewLine (const bool evenempty)
 flushes current line; if empty, flushes it (defines a new empty line) if evenempty is True; else, skips it
 
void JoinLast (const bool newline)
 joins current line to last one, only if new length is 72 max if newline is True, a new current line begins; else, current line is set to the last line (once joined) itself an can be completed
 
void Indent (const bool onent)
 asks that further indentations will begin at position of entity first opening bracket; else they begin at zero (def) for each sublist level, two more blancks are added at beginning (except for text continuation, which must begin at true zero)
 
void SendIdent (const int ident)
 begins an entity with an ident plus '=' (at beginning of line) entity ident is its Number given by the containing Model Warning : <ident> must be, either Number or Label, according LabelMode
 
void SendScope ()
 sets a begin of Scope (ends this line)
 
void SendEndscope ()
 sets an end of Scope (on a separate line)
 
void Comment (const bool mode)
 sets a comment mark : if mode is True, begins Comment zone, if mode is False, ends Comment zone (if one is begun)
 
void SendComment (const occ::handle< TCollection_HAsciiString > &text)
 sends a comment. Error if we are not inside a comment zone
 
void SendComment (const char *const text)
 same as above but accepts a CString (ex.: "..." directly)
 
void StartEntity (const TCollection_AsciiString &atype)
 sets entity's StepType, opens brackets, starts param no to 0 params are separated by comma Remark : for a Multiple Type Entity (see Express ANDOR clause) StartComplex must be called before sending components, then each "Component" must be sent separately (one call to StartEntity for each one) : the Type which precedes is then automatically closed. Once all the components have been sent, EndComplex must be called, then and only then EndEntity
 
void StartComplex ()
 sends the start of a complex entity, which is a simple open bracket (without increasing bracket level) It must be called JUST AFTER SendEntity and BEFORE sending components, each one begins by StartEntity
 
void EndComplex ()
 sends the end of a complex entity : a simple closed bracket It must be called AFTER sending all the components and BEFORE the final call to EndEntity
 
void SendField (const StepData_Field &fild, const occ::handle< StepData_PDescr > &descr)
 Sends the content of a field, controlled by its descriptor If the descriptor is not defined, follows the description detained by the field itself.
 
void SendSelect (const occ::handle< StepData_SelectMember > &sm, const occ::handle< StepData_PDescr > &descr)
 Sends a SelectMember, which cab be named or not.
 
void SendList (const StepData_FieldList &list, const occ::handle< StepData_ESDescr > &descr)
 Send the content of an entity as being a FieldList controlled by its descriptor. This includes start and end brackets but not the entity type.
 
void OpenSub ()
 open a sublist by a '('
 
void OpenTypedSub (const char *const subtype)
 open a sublist with its type then a '('
 
void CloseSub ()
 closes a sublist by a ')'
 
void AddParam ()
 prepares adding a parameter (that is, adds ',' except for first one); normally for internal use; can be used to send a totally empty parameter (with no literal value)
 
void Send (const int val)
 sends an integer parameter
 
void Send (const double val)
 sends a real parameter (works with FloatWriter)
 
void Send (const TCollection_AsciiString &val)
 sends a text given as string (it will be set between '...')
 
void Send (const occ::handle< Standard_Transient > &val)
 sends a reference to an entity (its identifier with '#') REMARK 1 : a Null <val> is interpreted as "Undefined" REMARK 2 : for an HAsciiString which is not recorded in the Model, it is send as its String Content, between quotes
 
void SendBoolean (const bool val)
 sends a Boolean as .T. for True or .F. for False (it is an useful case of Enum, which is built-in)
 
void SendLogical (const StepData_Logical val)
 sends a Logical as .T. or .F. or .U. according its Value (it is a standard case of Enum for Step, and is built-in)
 
void SendString (const TCollection_AsciiString &val)
 sends a string exactly as it is given
 
void SendString (const char *const val)
 sends a string exactly as it is given
 
void SendEnum (const TCollection_AsciiString &val)
 sends an enum given by String (literal expression) adds '.' around it if not done Remark : val can be computed by class EnumTool from StepData: StepWriter.SendEnum (myenum.Text(enumval));
 
void SendEnum (const char *const val)
 sends an enum given by String (literal expression) adds '.' around it if not done
 
void SendArrReal (const occ::handle< NCollection_HArray1< double > > &anArr)
 sends an array of real
 
void SendUndef ()
 sends an undefined (optional absent) parameter (by '$')
 
void SendDerived ()
 sends a "Derived" parameter (by '*'). A Derived Parameter has been inherited from a Super-Type then redefined as being computed by a function. Hence its value in file is senseless.
 
void EndEntity ()
 sends end of entity (closing bracket plus ';') Error if count of opened-closed brackets is not null
 
Interface_CheckIterator CheckList () const
 Returns the check-list, which has received possible checks : for unknown entities, badly loaded ones, null or unknown references.
 
int NbLines () const
 Returns count of Lines.
 
occ::handle< TCollection_HAsciiStringLine (const int num) const
 Returns a Line given its rank in the File.
 
bool Print (Standard_OStream &S)
 writes result on an output defined as an OStream then clears it
 
static TCollection_AsciiString CleanTextForSend (const TCollection_AsciiString &theText)
 Static helper function to prepare text for STEP file output while preserving existing ISO 10303-21 control directives.
 

Detailed Description

manages atomic file writing, under control of StepModel (for general organisation of file) and each class of Transient (for its own parameters) : prepares text to be written then writes it A stream cannot be used because Step limits line length at 72 In more, a specific object offers more appropriate functions

Constructor & Destructor Documentation

◆ StepData_StepWriter()

StepData_StepWriter::StepData_StepWriter ( const occ::handle< StepData_StepModel > & amodel)

Creates an empty StepWriter from a StepModel. The StepModel provides the Number of Entities, as identifiers for File.

Member Function Documentation

◆ AddParam()

void StepData_StepWriter::AddParam ( )

prepares adding a parameter (that is, adds ',' except for first one); normally for internal use; can be used to send a totally empty parameter (with no literal value)

◆ CheckList()

Interface_CheckIterator StepData_StepWriter::CheckList ( ) const

Returns the check-list, which has received possible checks : for unknown entities, badly loaded ones, null or unknown references.

◆ CleanTextForSend()

static TCollection_AsciiString StepData_StepWriter::CleanTextForSend ( const TCollection_AsciiString & theText)
static

Static helper function to prepare text for STEP file output while preserving existing ISO 10303-21 control directives.

This function processes input text and escapes special characters (quotes, backslashes, newlines, tabs) for STEP file format compliance, while carefully preserving any existing control directives that may already be present in the input string.

Supported control directive patterns that are preserved:

  • \X{HH}\ : Single byte character encoding (U+0000 to U+00FF)
  • \X2HHHH}...\X0\ : UTF-16 character encoding
  • \X4HHHHHHHH}...\X0\ : UTF-32 character encoding
  • \S\ : Latin codepoint character with current code page
  • \P{A-I}\ : Code page control directive
  • \N\ : Newline directive (preserved as-is)
  • \T\ : Tab directive (preserved as-is)

Character escaping performed (only on non-directive content):

  • Single quote (') -> double quote ('')
  • Backslash () -> double backslash (\)
  • Newline character -> \N\ directive
  • Tab character -> \T\ directive

Example: Input: "text with \XA7\ and 'quotes'" Output: "text with \XA7\ and ''quotes''"

Parameters
theTextThe input text string to be processed
Returns
Processed text with preserved control directives and escaped special characters

◆ CloseSub()

void StepData_StepWriter::CloseSub ( )

closes a sublist by a ')'

◆ Comment()

void StepData_StepWriter::Comment ( const bool mode)

sets a comment mark : if mode is True, begins Comment zone, if mode is False, ends Comment zone (if one is begun)

◆ EndComplex()

void StepData_StepWriter::EndComplex ( )

sends the end of a complex entity : a simple closed bracket It must be called AFTER sending all the components and BEFORE the final call to EndEntity

◆ EndEntity()

void StepData_StepWriter::EndEntity ( )

sends end of entity (closing bracket plus ';') Error if count of opened-closed brackets is not null

◆ EndFile()

void StepData_StepWriter::EndFile ( )

sets end of file; error is EndSec was not set

◆ EndSec()

void StepData_StepWriter::EndSec ( )

sets end of section; to be done before passing to next one

◆ FloatWriter()

Interface_FloatWriter & StepData_StepWriter::FloatWriter ( )

Returns the embedded FloatWriter, which controls sending Reals Use this method to access FloatWriter in order to consult or change its options (MainFormat, FormatForRange,ZeroSuppress), because it is returned as the address of its field.

◆ Indent()

void StepData_StepWriter::Indent ( const bool onent)

asks that further indentations will begin at position of entity first opening bracket; else they begin at zero (def) for each sublist level, two more blancks are added at beginning (except for text continuation, which must begin at true zero)

◆ IsInScope()

bool StepData_StepWriter::IsInScope ( const int num) const

Returns True if an Entity identified by its Number is in a Scope.

◆ JoinLast()

void StepData_StepWriter::JoinLast ( const bool newline)

joins current line to last one, only if new length is 72 max if newline is True, a new current line begins; else, current line is set to the last line (once joined) itself an can be completed

◆ LabelMode()

int & StepData_StepWriter::LabelMode ( )

ModeLabel controls how to display entity ids : 0 (D) gives entity number in the model 1 gives the already recorded label (else, its number) Warning : conflicts are not controlled.

◆ Line()

occ::handle< TCollection_HAsciiString > StepData_StepWriter::Line ( const int num) const

Returns a Line given its rank in the File.

◆ NbLines()

int StepData_StepWriter::NbLines ( ) const

Returns count of Lines.

◆ NewLine()

void StepData_StepWriter::NewLine ( const bool evenempty)

flushes current line; if empty, flushes it (defines a new empty line) if evenempty is True; else, skips it

◆ OpenSub()

void StepData_StepWriter::OpenSub ( )

open a sublist by a '('

◆ OpenTypedSub()

void StepData_StepWriter::OpenTypedSub ( const char *const subtype)

open a sublist with its type then a '('

◆ Print()

bool StepData_StepWriter::Print ( Standard_OStream & S)

writes result on an output defined as an OStream then clears it

◆ Send() [1/4]

void StepData_StepWriter::Send ( const double val)

sends a real parameter (works with FloatWriter)

◆ Send() [2/4]

void StepData_StepWriter::Send ( const int val)

sends an integer parameter

◆ Send() [3/4]

void StepData_StepWriter::Send ( const occ::handle< Standard_Transient > & val)

sends a reference to an entity (its identifier with '#') REMARK 1 : a Null <val> is interpreted as "Undefined" REMARK 2 : for an HAsciiString which is not recorded in the Model, it is send as its String Content, between quotes

◆ Send() [4/4]

void StepData_StepWriter::Send ( const TCollection_AsciiString & val)

sends a text given as string (it will be set between '...')

◆ SendArrReal()

void StepData_StepWriter::SendArrReal ( const occ::handle< NCollection_HArray1< double > > & anArr)

sends an array of real

◆ SendBoolean()

void StepData_StepWriter::SendBoolean ( const bool val)

sends a Boolean as .T. for True or .F. for False (it is an useful case of Enum, which is built-in)

◆ SendComment() [1/2]

void StepData_StepWriter::SendComment ( const char *const text)

same as above but accepts a CString (ex.: "..." directly)

◆ SendComment() [2/2]

void StepData_StepWriter::SendComment ( const occ::handle< TCollection_HAsciiString > & text)

sends a comment. Error if we are not inside a comment zone

◆ SendData()

void StepData_StepWriter::SendData ( )

Begins data section; error if EndSec was not set.

◆ SendDerived()

void StepData_StepWriter::SendDerived ( )

sends a "Derived" parameter (by '*'). A Derived Parameter has been inherited from a Super-Type then redefined as being computed by a function. Hence its value in file is senseless.

◆ SendEndscope()

void StepData_StepWriter::SendEndscope ( )

sets an end of Scope (on a separate line)

◆ SendEntity()

void StepData_StepWriter::SendEntity ( const int nument,
const StepData_WriterLib & lib )

Send an Entity of the Data Section. If it corresponds to a Scope, also Sends the Scope information and contained Items.

◆ SendEnum() [1/2]

void StepData_StepWriter::SendEnum ( const char *const val)

sends an enum given by String (literal expression) adds '.' around it if not done

◆ SendEnum() [2/2]

void StepData_StepWriter::SendEnum ( const TCollection_AsciiString & val)

sends an enum given by String (literal expression) adds '.' around it if not done Remark : val can be computed by class EnumTool from StepData: StepWriter.SendEnum (myenum.Text(enumval));

◆ SendField()

void StepData_StepWriter::SendField ( const StepData_Field & fild,
const occ::handle< StepData_PDescr > & descr )

Sends the content of a field, controlled by its descriptor If the descriptor is not defined, follows the description detained by the field itself.

◆ SendHeader()

void StepData_StepWriter::SendHeader ( )

Begins model header.

◆ SendIdent()

void StepData_StepWriter::SendIdent ( const int ident)

begins an entity with an ident plus '=' (at beginning of line) entity ident is its Number given by the containing Model Warning : <ident> must be, either Number or Label, according LabelMode

◆ SendList()

void StepData_StepWriter::SendList ( const StepData_FieldList & list,
const occ::handle< StepData_ESDescr > & descr )

Send the content of an entity as being a FieldList controlled by its descriptor. This includes start and end brackets but not the entity type.

◆ SendLogical()

void StepData_StepWriter::SendLogical ( const StepData_Logical val)

sends a Logical as .T. or .F. or .U. according its Value (it is a standard case of Enum for Step, and is built-in)

◆ SendModel()

void StepData_StepWriter::SendModel ( const occ::handle< StepData_Protocol > & protocol,
const bool headeronly = false )

Sends the complete Model, included HEADER and DATA Sections Works with a WriterLib defined through a Protocol If <headeronly> is given True, only the HEADER Section is sent (used to Dump the Header of a StepModel)

◆ SendScope()

void StepData_StepWriter::SendScope ( )

sets a begin of Scope (ends this line)

◆ SendSelect()

void StepData_StepWriter::SendSelect ( const occ::handle< StepData_SelectMember > & sm,
const occ::handle< StepData_PDescr > & descr )

Sends a SelectMember, which cab be named or not.

◆ SendString() [1/2]

void StepData_StepWriter::SendString ( const char *const val)

sends a string exactly as it is given

◆ SendString() [2/2]

void StepData_StepWriter::SendString ( const TCollection_AsciiString & val)

sends a string exactly as it is given

◆ SendUndef()

void StepData_StepWriter::SendUndef ( )

sends an undefined (optional absent) parameter (by '$')

◆ SetScope()

void StepData_StepWriter::SetScope ( const int numscope,
const int numin )

Declares the Entity Number <numscope> to correspond to a Scope which contains the Entity Number <numin>. Several calls to the same <numscope> add Entities in this Scope, in this order. Error if <numin> is already declared in the Scope Warning : the declaration of the Scopes is assumed to be consistent, i.e. <numin> is not referenced from outside this Scope (not checked here)

◆ StartComplex()

void StepData_StepWriter::StartComplex ( )

sends the start of a complex entity, which is a simple open bracket (without increasing bracket level) It must be called JUST AFTER SendEntity and BEFORE sending components, each one begins by StartEntity

◆ StartEntity()

void StepData_StepWriter::StartEntity ( const TCollection_AsciiString & atype)

sets entity's StepType, opens brackets, starts param no to 0 params are separated by comma Remark : for a Multiple Type Entity (see Express ANDOR clause) StartComplex must be called before sending components, then each "Component" must be sent separately (one call to StartEntity for each one) : the Type which precedes is then automatically closed. Once all the components have been sent, EndComplex must be called, then and only then EndEntity

◆ TypeMode()

int & StepData_StepWriter::TypeMode ( )

TypeMode controls the type form to use : 0 (D) for normal long form 1 for short form (if a type name has no short form, normal long form is then used)


The documentation for this class was generated from the following file: