Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:31

0001 // Created on: 1996-11-29
0002 // Created by: Christophe LEYNADIER
0003 // Copyright (c) 1996-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 _FSD_File_HeaderFile
0018 #define _FSD_File_HeaderFile
0019 
0020 #include <FSD_FStream.hxx>
0021 #include <Storage_BaseDriver.hxx>
0022 
0023 class TCollection_AsciiString;
0024 class TCollection_ExtendedString;
0025 
0026 DEFINE_STANDARD_HANDLE(FSD_File,Storage_BaseDriver)
0027 
0028 //! A general driver which defines as a file, the
0029 //! physical container for data to be stored or retrieved.
0030 class FSD_File  : public Storage_BaseDriver
0031 {
0032 public:
0033   DEFINE_STANDARD_RTTIEXT(FSD_File,Storage_BaseDriver)
0034 
0035 public:
0036 
0037   //! Constructs a driver defining as a file, the physical
0038   //! container for data to be stored or retrieved.
0039   //! Use the function Open to give the name of the driven file.
0040   Standard_EXPORT FSD_File();
0041   
0042 
0043   //! Assigns as aName the name of the file to be
0044   //! driven by this driver. aMode precises if the file is
0045   //! opened in read or write mode.
0046   //! The function returns Storage_VSOk if the file
0047   //! is opened correctly, or any other value of the
0048   //! Storage_Error enumeration which specifies the problem encountered.
0049   Standard_EXPORT virtual Storage_Error Open (const TCollection_AsciiString& aName, const Storage_OpenMode aMode) Standard_OVERRIDE;
0050   
0051   Standard_EXPORT virtual Standard_Boolean IsEnd() Standard_OVERRIDE;
0052   
0053   //! return position in the file. Return -1 upon error.
0054   Standard_EXPORT virtual Storage_Position Tell() Standard_OVERRIDE;
0055   
0056   Standard_EXPORT static Storage_Error IsGoodFileType (const TCollection_AsciiString& aName);
0057   
0058   Standard_EXPORT virtual Storage_Error BeginWriteInfoSection() Standard_OVERRIDE;
0059   
0060   Standard_EXPORT virtual void WriteInfo (const Standard_Integer nbObj, 
0061                                           const TCollection_AsciiString& dbVersion, 
0062                                           const TCollection_AsciiString& date, 
0063                                           const TCollection_AsciiString& schemaName, 
0064                                           const TCollection_AsciiString& schemaVersion, 
0065                                           const TCollection_ExtendedString& appName, 
0066                                           const TCollection_AsciiString& appVersion, 
0067                                           const TCollection_ExtendedString& objectType, 
0068                                           const TColStd_SequenceOfAsciiString& userInfo) Standard_OVERRIDE;
0069   
0070   Standard_EXPORT virtual Storage_Error EndWriteInfoSection() Standard_OVERRIDE;
0071   
0072   Standard_EXPORT virtual Storage_Error BeginReadInfoSection() Standard_OVERRIDE;
0073   
0074   Standard_EXPORT virtual void ReadInfo (Standard_Integer& nbObj, 
0075                                          TCollection_AsciiString& dbVersion, 
0076                                          TCollection_AsciiString& date, 
0077                                          TCollection_AsciiString& schemaName, 
0078                                          TCollection_AsciiString& schemaVersion, 
0079                                          TCollection_ExtendedString& appName, 
0080                                          TCollection_AsciiString& appVersion, 
0081                                          TCollection_ExtendedString& objectType, 
0082                                          TColStd_SequenceOfAsciiString& userInfo) Standard_OVERRIDE;
0083 
0084   Standard_EXPORT virtual void ReadCompleteInfo (Standard_IStream& theIStream, Handle(Storage_Data)& theData) Standard_OVERRIDE;
0085   
0086   Standard_EXPORT virtual Storage_Error EndReadInfoSection() Standard_OVERRIDE;
0087   
0088   Standard_EXPORT virtual Storage_Error BeginWriteCommentSection() Standard_OVERRIDE;
0089   
0090   Standard_EXPORT virtual void WriteComment (const TColStd_SequenceOfExtendedString& userComments) Standard_OVERRIDE;
0091   
0092   Standard_EXPORT virtual Storage_Error EndWriteCommentSection() Standard_OVERRIDE;
0093   
0094   Standard_EXPORT virtual Storage_Error BeginReadCommentSection() Standard_OVERRIDE;
0095   
0096   Standard_EXPORT virtual void ReadComment (TColStd_SequenceOfExtendedString& userComments) Standard_OVERRIDE;
0097   
0098   Standard_EXPORT virtual Storage_Error EndReadCommentSection() Standard_OVERRIDE;
0099   
0100   Standard_EXPORT virtual Storage_Error BeginWriteTypeSection() Standard_OVERRIDE;
0101   
0102   Standard_EXPORT virtual void SetTypeSectionSize (const Standard_Integer aSize) Standard_OVERRIDE;
0103   
0104   Standard_EXPORT virtual void WriteTypeInformations (const Standard_Integer typeNum, 
0105                                                       const TCollection_AsciiString& typeName) Standard_OVERRIDE;
0106   
0107   Standard_EXPORT virtual Storage_Error EndWriteTypeSection() Standard_OVERRIDE;
0108   
0109   Standard_EXPORT virtual Storage_Error BeginReadTypeSection() Standard_OVERRIDE;
0110   
0111   Standard_EXPORT virtual Standard_Integer TypeSectionSize() Standard_OVERRIDE;
0112   
0113   Standard_EXPORT virtual void ReadTypeInformations (Standard_Integer& typeNum, TCollection_AsciiString& typeName) Standard_OVERRIDE;
0114   
0115   Standard_EXPORT virtual Storage_Error EndReadTypeSection() Standard_OVERRIDE;
0116   
0117   Standard_EXPORT virtual Storage_Error BeginWriteRootSection() Standard_OVERRIDE;
0118   
0119   Standard_EXPORT virtual void SetRootSectionSize (const Standard_Integer aSize) Standard_OVERRIDE;
0120   
0121   Standard_EXPORT virtual void WriteRoot (const TCollection_AsciiString& rootName, 
0122                                           const Standard_Integer aRef, 
0123                                           const TCollection_AsciiString& aType) Standard_OVERRIDE;
0124   
0125   Standard_EXPORT virtual Storage_Error EndWriteRootSection() Standard_OVERRIDE;
0126   
0127   Standard_EXPORT virtual Storage_Error BeginReadRootSection() Standard_OVERRIDE;
0128   
0129   Standard_EXPORT virtual Standard_Integer RootSectionSize() Standard_OVERRIDE;
0130   
0131   Standard_EXPORT virtual void ReadRoot (TCollection_AsciiString& rootName, 
0132                                          Standard_Integer& aRef, 
0133                                          TCollection_AsciiString& aType) Standard_OVERRIDE;
0134   
0135   Standard_EXPORT virtual Storage_Error EndReadRootSection() Standard_OVERRIDE;
0136   
0137   Standard_EXPORT virtual Storage_Error BeginWriteRefSection() Standard_OVERRIDE;
0138   
0139   Standard_EXPORT virtual void SetRefSectionSize (const Standard_Integer aSize) Standard_OVERRIDE;
0140   
0141   Standard_EXPORT virtual void WriteReferenceType (const Standard_Integer reference, const Standard_Integer typeNum) Standard_OVERRIDE;
0142   
0143   Standard_EXPORT virtual Storage_Error EndWriteRefSection() Standard_OVERRIDE;
0144   
0145   Standard_EXPORT virtual Storage_Error BeginReadRefSection() Standard_OVERRIDE;
0146   
0147   Standard_EXPORT virtual Standard_Integer RefSectionSize() Standard_OVERRIDE;
0148   
0149   Standard_EXPORT virtual void ReadReferenceType (Standard_Integer& reference, Standard_Integer& typeNum) Standard_OVERRIDE;
0150   
0151   Standard_EXPORT virtual Storage_Error EndReadRefSection() Standard_OVERRIDE;
0152   
0153   Standard_EXPORT virtual Storage_Error BeginWriteDataSection() Standard_OVERRIDE;
0154   
0155   Standard_EXPORT virtual void WritePersistentObjectHeader (const Standard_Integer aRef, const Standard_Integer aType) Standard_OVERRIDE;
0156   
0157   Standard_EXPORT virtual void BeginWritePersistentObjectData() Standard_OVERRIDE;
0158   
0159   Standard_EXPORT virtual void BeginWriteObjectData() Standard_OVERRIDE;
0160   
0161   Standard_EXPORT virtual void EndWriteObjectData() Standard_OVERRIDE;
0162   
0163   Standard_EXPORT virtual void EndWritePersistentObjectData() Standard_OVERRIDE;
0164   
0165   Standard_EXPORT virtual Storage_Error EndWriteDataSection() Standard_OVERRIDE;
0166   
0167   Standard_EXPORT virtual Storage_Error BeginReadDataSection() Standard_OVERRIDE;
0168   
0169   Standard_EXPORT virtual void ReadPersistentObjectHeader (Standard_Integer& aRef, Standard_Integer& aType) Standard_OVERRIDE;
0170   
0171   Standard_EXPORT virtual void BeginReadPersistentObjectData() Standard_OVERRIDE;
0172   
0173   Standard_EXPORT virtual void BeginReadObjectData() Standard_OVERRIDE;
0174   
0175   Standard_EXPORT virtual void EndReadObjectData() Standard_OVERRIDE;
0176   
0177   Standard_EXPORT virtual void EndReadPersistentObjectData() Standard_OVERRIDE;
0178   
0179   Standard_EXPORT virtual Storage_Error EndReadDataSection() Standard_OVERRIDE;
0180   
0181   Standard_EXPORT virtual void SkipObject() Standard_OVERRIDE;
0182   
0183   Standard_EXPORT virtual Storage_BaseDriver& PutReference (const Standard_Integer aValue) Standard_OVERRIDE;
0184   
0185   Standard_EXPORT virtual Storage_BaseDriver& PutCharacter (const Standard_Character aValue) Standard_OVERRIDE;
0186 
0187   Standard_EXPORT virtual Storage_BaseDriver& PutExtCharacter(const Standard_ExtCharacter aValue) Standard_OVERRIDE;
0188   
0189   Standard_EXPORT virtual Storage_BaseDriver& PutInteger (const Standard_Integer aValue) Standard_OVERRIDE;
0190   
0191   Standard_EXPORT virtual Storage_BaseDriver& PutBoolean (const Standard_Boolean aValue) Standard_OVERRIDE;
0192   
0193   Standard_EXPORT virtual Storage_BaseDriver& PutReal (const Standard_Real aValue) Standard_OVERRIDE;
0194   
0195   Standard_EXPORT virtual Storage_BaseDriver& PutShortReal (const Standard_ShortReal aValue) Standard_OVERRIDE;
0196   
0197   Standard_EXPORT virtual Storage_BaseDriver& GetReference (Standard_Integer& aValue) Standard_OVERRIDE;
0198   
0199   Standard_EXPORT virtual Storage_BaseDriver& GetCharacter (Standard_Character& aValue) Standard_OVERRIDE;
0200   
0201   Standard_EXPORT virtual Storage_BaseDriver& GetExtCharacter (Standard_ExtCharacter& aValue) Standard_OVERRIDE;
0202   
0203   Standard_EXPORT virtual Storage_BaseDriver& GetInteger (Standard_Integer& aValue) Standard_OVERRIDE;
0204   
0205   Standard_EXPORT virtual Storage_BaseDriver& GetBoolean (Standard_Boolean& aValue) Standard_OVERRIDE;
0206   
0207   Standard_EXPORT virtual Storage_BaseDriver& GetReal (Standard_Real& aValue) Standard_OVERRIDE;
0208   
0209   Standard_EXPORT virtual Storage_BaseDriver& GetShortReal (Standard_ShortReal& aValue) Standard_OVERRIDE;  
0210 
0211   //! Closes the file driven by this driver. This file was
0212   //! opened by the last call to the function Open.
0213   //! The function returns Storage_VSOk if the
0214   //! closure is correctly done, or any other value of
0215   //! the Storage_Error enumeration which specifies the problem encountered.
0216   Standard_EXPORT virtual Storage_Error Close() Standard_OVERRIDE;
0217   
0218   Standard_EXPORT void Destroy();
0219 ~FSD_File()
0220 {
0221   Destroy();
0222 }
0223 
0224   Standard_EXPORT static Standard_CString MagicNumber();
0225 
0226 protected:
0227   
0228   //! read from the current position to the end of line.
0229   Standard_EXPORT virtual void ReadLine (TCollection_AsciiString& buffer);
0230   
0231   //! read from the current position to the next white space or end of line.
0232   Standard_EXPORT virtual void ReadWord (TCollection_AsciiString& buffer);
0233   
0234   //! read extended chars (unicode) from the current position to the end of line.
0235   Standard_EXPORT virtual void ReadExtendedLine (TCollection_ExtendedString& buffer);
0236   
0237   //! write from the current position to the end of line.
0238   Standard_EXPORT virtual void WriteExtendedLine (const TCollection_ExtendedString& buffer);
0239   
0240   //! read <rsize> character from the current position.
0241   Standard_EXPORT virtual void ReadChar (TCollection_AsciiString& buffer, const Standard_Size rsize);
0242   
0243   //! read from the first none space character position to the end of line.
0244   Standard_EXPORT virtual void ReadString (TCollection_AsciiString& buffer);
0245   
0246   Standard_EXPORT virtual void FlushEndOfLine();
0247   
0248   Standard_EXPORT virtual Storage_Error FindTag (const Standard_CString aTag);
0249 
0250 protected:
0251   FSD_FStream myStream;
0252 };
0253 
0254 #endif // _FSD_File_HeaderFile