|
||||
File indexing completed on 2025-01-18 10:05:06
0001 // Created on: 1992-02-11 0002 // Created by: Christian CAILLET 0003 // Copyright (c) 1992-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _StepData_StepWriter_HeaderFile 0018 #define _StepData_StepWriter_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <Standard_Handle.hxx> 0023 0024 #include <TColStd_HSequenceOfHAsciiString.hxx> 0025 #include <Interface_LineBuffer.hxx> 0026 #include <Standard_Integer.hxx> 0027 #include <Interface_FloatWriter.hxx> 0028 #include <Interface_CheckIterator.hxx> 0029 #include <TColStd_HArray1OfInteger.hxx> 0030 #include <Standard_CString.hxx> 0031 #include <StepData_Logical.hxx> 0032 #include <TColStd_HArray1OfReal.hxx> 0033 #include <Standard_OStream.hxx> 0034 class StepData_StepModel; 0035 class StepData_Protocol; 0036 class StepData_WriterLib; 0037 class TCollection_AsciiString; 0038 class TCollection_HAsciiString; 0039 class StepData_Field; 0040 class StepData_PDescr; 0041 class StepData_SelectMember; 0042 class StepData_FieldList; 0043 class StepData_ESDescr; 0044 class Standard_Transient; 0045 0046 0047 //! manages atomic file writing, under control of StepModel (for 0048 //! general organisation of file) and each class of Transient 0049 //! (for its own parameters) : prepares text to be written then 0050 //! writes it 0051 //! A stream cannot be used because Step limits line length at 72 0052 //! In more, a specific object offers more appropriate functions 0053 class StepData_StepWriter 0054 { 0055 public: 0056 0057 DEFINE_STANDARD_ALLOC 0058 0059 0060 //! Creates an empty StepWriter from a StepModel. The StepModel 0061 //! provides the Number of Entities, as identifiers for File 0062 Standard_EXPORT StepData_StepWriter(const Handle(StepData_StepModel)& amodel); 0063 0064 //! ModeLabel controls how to display entity ids : 0065 //! 0 (D) gives entity number in the model 0066 //! 1 gives the already recorded label (else, its number) 0067 //! Warning : conflicts are not controlled 0068 Standard_EXPORT Standard_Integer& LabelMode(); 0069 0070 //! TypeMode controls the type form to use : 0071 //! 0 (D) for normal long form 0072 //! 1 for short form (if a type name has no short form, normal 0073 //! long form is then used) 0074 Standard_EXPORT Standard_Integer& TypeMode(); 0075 0076 //! Returns the embedded FloatWriter, which controls sending Reals 0077 //! Use this method to access FloatWriter in order to consult or 0078 //! change its options (MainFormat, FormatForRange,ZeroSuppress), 0079 //! because it is returned as the address of its field 0080 Standard_EXPORT Interface_FloatWriter& FloatWriter(); 0081 0082 //! Declares the Entity Number <numscope> to correspond to a Scope 0083 //! which contains the Entity Number <numin>. Several calls to the 0084 //! same <numscope> add Entities in this Scope, in this order. 0085 //! Error if <numin> is already declared in the Scope 0086 //! Warning : the declaration of the Scopes is assumed to be consistent, 0087 //! i.e. <numin> is not referenced from outside this Scope 0088 //! (not checked here) 0089 Standard_EXPORT void SetScope (const Standard_Integer numscope, const Standard_Integer numin); 0090 0091 //! Returns True if an Entity identified by its Number is in a Scope 0092 Standard_EXPORT Standard_Boolean IsInScope (const Standard_Integer num) const; 0093 0094 //! Sends the complete Model, included HEADER and DATA Sections 0095 //! Works with a WriterLib defined through a Protocol 0096 //! If <headeronly> is given True, only the HEADER Section is sent 0097 //! (used to Dump the Header of a StepModel) 0098 Standard_EXPORT void SendModel (const Handle(StepData_Protocol)& protocol, const Standard_Boolean headeronly = Standard_False); 0099 0100 //! Begins model header 0101 Standard_EXPORT void SendHeader(); 0102 0103 //! Begins data section; error if EndSec was not set 0104 Standard_EXPORT void SendData(); 0105 0106 //! Send an Entity of the Data Section. If it corresponds to a 0107 //! Scope, also Sends the Scope information and contained Items 0108 Standard_EXPORT void SendEntity (const Standard_Integer nument, const StepData_WriterLib& lib); 0109 0110 //! sets end of section; to be done before passing to next one 0111 Standard_EXPORT void EndSec(); 0112 0113 //! sets end of file; error is EndSec was not set 0114 Standard_EXPORT void EndFile(); 0115 0116 //! flushes current line; if empty, flushes it (defines a new 0117 //! empty line) if evenempty is True; else, skips it 0118 Standard_EXPORT void NewLine (const Standard_Boolean evenempty); 0119 0120 //! joins current line to last one, only if new length is 72 max 0121 //! if newline is True, a new current line begins; else, current 0122 //! line is set to the last line (once joined) itself an can be 0123 //! completed 0124 Standard_EXPORT void JoinLast (const Standard_Boolean newline); 0125 0126 //! asks that further indentations will begin at position of 0127 //! entity first opening bracket; else they begin at zero (def) 0128 //! for each sublist level, two more blancks are added at beginning 0129 //! (except for text continuation, which must begin at true zero) 0130 Standard_EXPORT void Indent (const Standard_Boolean onent); 0131 0132 //! begins an entity with an ident plus '=' (at beginning of line) 0133 //! entity ident is its Number given by the containing Model 0134 //! Warning : <ident> must be, either Number or Label, according LabelMode 0135 Standard_EXPORT void SendIdent (const Standard_Integer ident); 0136 0137 //! sets a begin of Scope (ends this line) 0138 Standard_EXPORT void SendScope(); 0139 0140 //! sets an end of Scope (on a separate line) 0141 Standard_EXPORT void SendEndscope(); 0142 0143 //! sets a comment mark : if mode is True, begins Comment zone, 0144 //! if mode is False, ends Comment zone (if one is begun) 0145 Standard_EXPORT void Comment (const Standard_Boolean mode); 0146 0147 //! sends a comment. Error if we are not inside a comment zone 0148 Standard_EXPORT void SendComment (const Handle(TCollection_HAsciiString)& text); 0149 0150 //! same as above but accepts a CString (ex.: "..." directly) 0151 Standard_EXPORT void SendComment (const Standard_CString text); 0152 0153 //! sets entity's StepType, opens brakets, starts param no to 0 0154 //! params are separated by comma 0155 //! Remark : for a Multiple Type Entity (see Express ANDOR clause) 0156 //! StartComplex must be called before sending components, then 0157 //! each "Component" must be sent separately (one call to 0158 //! StartEntity for each one) : the Type which precedes is then 0159 //! automatically closed. Once all the components have been sent, 0160 //! EndComplex must be called, then and only then EndEntity 0161 Standard_EXPORT void StartEntity (const TCollection_AsciiString& atype); 0162 0163 //! sends the start of a complex entity, which is a simple open 0164 //! bracket (without increasing braket level) 0165 //! It must be called JUST AFTER SendEntity and BEFORE sending 0166 //! components, each one begins by StartEntity 0167 Standard_EXPORT void StartComplex(); 0168 0169 //! sends the end of a complex entity : a simple closed bracket 0170 //! It must be called AFTER sending all the components and BEFORE 0171 //! the final call to EndEntity 0172 Standard_EXPORT void EndComplex(); 0173 0174 //! Sends the content of a field, controlled by its descriptor 0175 //! If the descriptor is not defined, follows the description 0176 //! detained by the field itself 0177 Standard_EXPORT void SendField (const StepData_Field& fild, const Handle(StepData_PDescr)& descr); 0178 0179 //! Sends a SelectMember, which cab be named or not 0180 Standard_EXPORT void SendSelect (const Handle(StepData_SelectMember)& sm, const Handle(StepData_PDescr)& descr); 0181 0182 //! Send the content of an entity as being a FieldList controlled 0183 //! by its descriptor. This includes start and end brackets but 0184 //! not the entity type 0185 Standard_EXPORT void SendList (const StepData_FieldList& list, const Handle(StepData_ESDescr)& descr); 0186 0187 //! open a sublist by a '(' 0188 Standard_EXPORT void OpenSub(); 0189 0190 //! open a sublist with its type then a '(' 0191 Standard_EXPORT void OpenTypedSub (const Standard_CString subtype); 0192 0193 //! closes a sublist by a ')' 0194 Standard_EXPORT void CloseSub(); 0195 0196 //! prepares adding a parameter (that is, adds ',' except for 0197 //! first one); normally for internal use; can be used to send 0198 //! a totally empty parameter (with no literal value) 0199 Standard_EXPORT void AddParam(); 0200 0201 //! sends an integer parameter 0202 Standard_EXPORT void Send (const Standard_Integer val); 0203 0204 //! sends a real parameter (works with FloatWriter) 0205 Standard_EXPORT void Send (const Standard_Real val); 0206 0207 //! sends a text given as string (it will be set between '...') 0208 Standard_EXPORT void Send (const TCollection_AsciiString& val); 0209 0210 //! sends a reference to an entity (its identifier with '#') 0211 //! REMARK 1 : a Null <val> is interpreted as "Undefined" 0212 //! REMARK 2 : for an HAsciiString which is not recorded in the 0213 //! Model, it is send as its String Content, between quotes 0214 Standard_EXPORT void Send (const Handle(Standard_Transient)& val); 0215 0216 //! sends a Boolean as .T. for True or .F. for False 0217 //! (it is an useful case of Enum, which is built-in) 0218 Standard_EXPORT void SendBoolean (const Standard_Boolean val); 0219 0220 //! sends a Logical as .T. or .F. or .U. according its Value 0221 //! (it is a standard case of Enum for Step, and is built-in) 0222 Standard_EXPORT void SendLogical (const StepData_Logical val); 0223 0224 //! sends a string exactly as it is given 0225 Standard_EXPORT void SendString (const TCollection_AsciiString& val); 0226 0227 //! sends a string exactly as it is given 0228 Standard_EXPORT void SendString (const Standard_CString val); 0229 0230 //! sends an enum given by String (literal expression) 0231 //! adds '.' around it if not done 0232 //! Remark : val can be computed by class EnumTool from StepData: 0233 //! StepWriter.SendEnum (myenum.Text(enumval)); 0234 Standard_EXPORT void SendEnum (const TCollection_AsciiString& val); 0235 0236 //! sends an enum given by String (literal expression) 0237 //! adds '.' around it if not done 0238 Standard_EXPORT void SendEnum (const Standard_CString val); 0239 0240 //! sends an array of real 0241 Standard_EXPORT void SendArrReal (const Handle(TColStd_HArray1OfReal)& anArr); 0242 0243 //! sends an undefined (optional absent) parameter (by '$') 0244 Standard_EXPORT void SendUndef(); 0245 0246 //! sends a "Derived" parameter (by '*'). A Derived Parameter has 0247 //! been inherited from a Super-Type then redefined as being 0248 //! computed by a function. Hence its value in file is senseless. 0249 Standard_EXPORT void SendDerived(); 0250 0251 //! sends end of entity (closing bracket plus ';') 0252 //! Error if count of opened-closed brackets is not null 0253 Standard_EXPORT void EndEntity(); 0254 0255 //! Returns the check-list, which has received possible checks : 0256 //! for unknown entities, badly loaded ones, null or unknown 0257 //! references 0258 Standard_EXPORT Interface_CheckIterator CheckList() const; 0259 0260 //! Returns count of Lines 0261 Standard_EXPORT Standard_Integer NbLines() const; 0262 0263 //! Returns a Line given its rank in the File 0264 Standard_EXPORT Handle(TCollection_HAsciiString) Line (const Standard_Integer num) const; 0265 0266 //! writes result on an output defined as an OStream 0267 //! then clears it 0268 Standard_EXPORT Standard_Boolean Print (Standard_OStream& S); 0269 0270 0271 0272 0273 protected: 0274 0275 0276 0277 0278 0279 private: 0280 0281 0282 //! adds a string to current line; first flushes it if full 0283 //! (72 char); more allows to ask a reserve at end of line : flush 0284 //! is done if remaining length (to 72) is less than <more> 0285 Standard_EXPORT void AddString (const TCollection_AsciiString& str, const Standard_Integer more = 0); 0286 0287 //! Same as above, but the string is given by CString + Length 0288 Standard_EXPORT void AddString (const Standard_CString str, const Standard_Integer lnstr, const Standard_Integer more = 0); 0289 0290 0291 Handle(StepData_StepModel) themodel; 0292 Handle(TColStd_HSequenceOfHAsciiString) thefile; 0293 Interface_LineBuffer thecurr; 0294 Standard_Boolean thesect; 0295 Standard_Boolean thecomm; 0296 Standard_Boolean thefirst; 0297 Standard_Boolean themult; 0298 Standard_Integer thelevel; 0299 Standard_Boolean theindent; 0300 Standard_Integer theindval; 0301 Standard_Integer thetypmode; 0302 Interface_FloatWriter thefloatw; 0303 Interface_CheckIterator thechecks; 0304 Standard_Integer thenum; 0305 Standard_Integer thelabmode; 0306 Handle(TColStd_HArray1OfInteger) thescopebeg; 0307 Handle(TColStd_HArray1OfInteger) thescopeend; 0308 Handle(TColStd_HArray1OfInteger) thescopenext; 0309 0310 0311 }; 0312 0313 0314 0315 0316 0317 0318 0319 #endif // _StepData_StepWriter_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |