Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 09:15:30

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