#include <CDM_Document.hxx>
-#include <CDM_MessageDriver.hxx>
#include <CDM_MetaData.hxx>
#include <CDM_ReferenceIterator.hxx>
#include <OSD_Path.hxx>
#include <PCDM_ReadWriter_1.hxx>
#include <PCDM_Reference.hxx>
#include <PCDM_TypeOfFileDriver.hxx>
+#include <Message_Messenger.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Type.hxx>
#include <Storage_Data.hxx>
#include <TColStd_SequenceOfExtendedString.hxx>
#include <UTL.hxx>
+IMPLEMENT_STANDARD_RTTIEXT(PCDM_ReadWriter_1,PCDM_ReadWriter)
+
#define START_REF "START_REF"
#define END_REF "END_REF"
#define START_EXT "START_EXT"
Standard_Integer i, j, len ;
len = aString.Length() ;
-#ifdef WNT
+#ifdef _WIN32
// Case of network path, such as \\MACHINE\dir
for (i = j = 2 ; j <= len ; i++,j++) {
#else
const TCollection_AsciiString& aRelFilePath)
{
TCollection_AsciiString EmptyString = "" ;
-#ifdef WNT
+#ifdef _WIN32
if (aRelFilePath.Search(":") == 2 ||
(aRelFilePath.Search("\\") == 1 && aRelFilePath.Value(2) == '\\'))
#else
TCollection_AsciiString DirPath = aDirPath, RelFilePath = aRelFilePath ;
Standard_Integer i,len ;
-#ifdef WNT
+#ifdef _WIN32
if(DirPath.Search(":") != 2 &&
(DirPath.Search("\\") != 1 || DirPath.Value(2) != '\\'))
#else
#endif
return EmptyString ;
-#ifdef WNT
+#ifdef _WIN32
DirPath.ChangeAll('\\','/') ;
RelFilePath.ChangeAll('\\','/') ;
#endif
TCollection_AsciiString theCFile(aFileName);
TCollection_AsciiString theDirectory;
Standard_Integer i=theCFile.SearchFromEnd("/");
-#ifdef WNT
+#ifdef _WIN32
// if(i==-1) i=theCFile.SearchFromEnd("\\");
if(theCFile.SearchFromEnd("\\") > i)
i=theCFile.SearchFromEnd("\\");
//purpose :
//=======================================================================
-Standard_Integer PCDM_ReadWriter_1::ReadReferenceCounter(const TCollection_ExtendedString& aFileName, const Handle(CDM_MessageDriver)& theMsgDriver) const {
+Standard_Integer PCDM_ReadWriter_1::ReadReferenceCounter(const TCollection_ExtendedString& aFileName, const Handle(Message_Messenger)& theMsgDriver) const {
static Standard_Integer theReferencesCounter ;
theReferencesCounter=0;
static Standard_Integer i ;
- PCDM_BaseDriverPointer theFileDriver;
+ Handle(Storage_BaseDriver) theFileDriver;
TCollection_AsciiString aFileNameU(aFileName);
if(PCDM::FileDriverType(aFileNameU, theFileDriver) == PCDM_TOFD_Unknown)
return theReferencesCounter;
try {
OCC_CATCH_SIGNALS
- PCDM_ReadWriter::Open(*theFileDriver,aFileName,Storage_VSRead);
+ PCDM_ReadWriter::Open(theFileDriver,aFileName,Storage_VSRead);
theFileIsOpen=Standard_True;
Handle(Storage_Schema) s = new Storage_Schema;
- Handle(Storage_HeaderData) hd = s->ReadHeaderSection(*theFileDriver);
- const TColStd_SequenceOfAsciiString &refUserInfo = hd->UserInfo();
+ Storage_HeaderData hd;
+ hd.Read (theFileDriver);
+ const TColStd_SequenceOfAsciiString &refUserInfo = hd.UserInfo();
for ( i =1; i<= refUserInfo.Length() ; i++) {
if(refUserInfo(i).Search(REFERENCE_COUNTER) != -1) {
try { OCC_CATCH_SIGNALS theReferencesCounter=refUserInfo(i).Token(" ",2).IntegerValue();}
- catch (Standard_Failure) {
-// cout << "warning: could not read the reference counter in " << aFileName << endl;
+ catch (Standard_Failure const&) {
+// std::cout << "warning: could not read the reference counter in " << aFileName << std::endl;
TCollection_ExtendedString aMsg("Warning: ");
aMsg = aMsg.Cat("could not read the reference counter in ").Cat(aFileName).Cat("\0");
if(!theMsgDriver.IsNull())
- theMsgDriver->Write(aMsg.ToExtString());
+ theMsgDriver->Send(aMsg.ToExtString());
}
}
}
}
- catch (Standard_Failure) {}
+ catch (Standard_Failure const&) {}
- if(theFileIsOpen) theFileDriver->Close();
+ if(theFileIsOpen)
+ {
+ theFileDriver->Close();
+ }
- delete theFileDriver;
return theReferencesCounter;
}
//purpose :
//=======================================================================
-void PCDM_ReadWriter_1::ReadReferences(const TCollection_ExtendedString& aFileName, PCDM_SequenceOfReference& theReferences, const Handle(CDM_MessageDriver)& theMsgDriver) const {
+void PCDM_ReadWriter_1::ReadReferences(const TCollection_ExtendedString& aFileName, PCDM_SequenceOfReference& theReferences, const Handle(Message_Messenger)& theMsgDriver) const {
TColStd_SequenceOfExtendedString ReadReferences;
if(!theAbsolutePath.IsEmpty()) thePath=theAbsolutePath;
}
if(!theMsgDriver.IsNull()) {
-// cout << "reference found; ReferenceIdentifier: " << theReferenceIdentifier << "; File:" << thePath << ", version:" << theDocumentVersion;
+// std::cout << "reference found; ReferenceIdentifier: " << theReferenceIdentifier << "; File:" << thePath << ", version:" << theDocumentVersion;
TCollection_ExtendedString aMsg("Warning: ");
aMsg = aMsg.Cat("reference found; ReferenceIdentifier: ").Cat(theReferenceIdentifier).Cat("; File:").Cat(thePath).Cat(", version:").Cat(theDocumentVersion).Cat("\0");
- theMsgDriver->Write(aMsg.ToExtString());
+ theMsgDriver->Send(aMsg.ToExtString());
}
TCollection_ExtendedString aPathW(thePath);
theReferences.Append(PCDM_Reference (theReferenceIdentifier,aPathW,theDocumentVersion));
//purpose :
//=======================================================================
-void PCDM_ReadWriter_1::ReadExtensions(const TCollection_ExtendedString& aFileName, TColStd_SequenceOfExtendedString& theExtensions, const Handle(CDM_MessageDriver)& theMsgDriver) const {
+void PCDM_ReadWriter_1::ReadExtensions(const TCollection_ExtendedString& aFileName, TColStd_SequenceOfExtendedString& theExtensions, const Handle(Message_Messenger)& theMsgDriver) const {
ReadUserInfo(aFileName,START_EXT,END_EXT,theExtensions, theMsgDriver);
}
const TCollection_AsciiString& Start,
const TCollection_AsciiString& End,
TColStd_SequenceOfExtendedString& theUserInfo,
- const Handle(CDM_MessageDriver)&) {
-
+ const Handle(Message_Messenger)&)
+{
static Standard_Integer i ;
- PCDM_BaseDriverPointer theFileDriver;
+ Handle(Storage_BaseDriver) theFileDriver;
TCollection_AsciiString aFileNameU(aFileName);
if(PCDM::FileDriverType(aFileNameU, theFileDriver) == PCDM_TOFD_Unknown)
return;
- PCDM_ReadWriter::Open(*theFileDriver,aFileName,Storage_VSRead);
+ PCDM_ReadWriter::Open(theFileDriver,aFileName,Storage_VSRead);
Handle(Storage_Schema) s = new Storage_Schema;
- Handle(Storage_HeaderData) hd = s->ReadHeaderSection(*theFileDriver);
- const TColStd_SequenceOfAsciiString &refUserInfo = hd->UserInfo();
+ Storage_HeaderData hd;
+ hd.Read (theFileDriver);
+ const TColStd_SequenceOfAsciiString &refUserInfo = hd.UserInfo();
Standard_Integer debut=0,fin=0;
}
}
theFileDriver->Close();
- delete theFileDriver;
}
//=======================================================================
//purpose :
//=======================================================================
-Standard_Integer PCDM_ReadWriter_1::ReadDocumentVersion(const TCollection_ExtendedString& aFileName, const Handle(CDM_MessageDriver)& theMsgDriver) const {
+Standard_Integer PCDM_ReadWriter_1::ReadDocumentVersion(const TCollection_ExtendedString& aFileName, const Handle(Message_Messenger)& theMsgDriver) const {
static Standard_Integer theVersion ;
theVersion=-1;
- PCDM_BaseDriverPointer theFileDriver;
+ Handle(Storage_BaseDriver) theFileDriver;
TCollection_AsciiString aFileNameU(aFileName);
if(PCDM::FileDriverType(aFileNameU, theFileDriver) == PCDM_TOFD_Unknown)
return theVersion;
try {
OCC_CATCH_SIGNALS
- PCDM_ReadWriter::Open(*theFileDriver,aFileName,Storage_VSRead);
+ PCDM_ReadWriter::Open(theFileDriver,aFileName,Storage_VSRead);
theFileIsOpen=Standard_True;
Handle(Storage_Schema) s = new Storage_Schema;
- Handle(Storage_HeaderData) hd = s->ReadHeaderSection(*theFileDriver);
- const TColStd_SequenceOfAsciiString &refUserInfo = hd->UserInfo();
+ Storage_HeaderData hd;
+ hd.Read (theFileDriver);
+ const TColStd_SequenceOfAsciiString &refUserInfo = hd.UserInfo();
static Standard_Integer i ;
for ( i =1; i<= refUserInfo.Length() ; i++) {
if(refUserInfo(i).Search(MODIFICATION_COUNTER) != -1) {
try { OCC_CATCH_SIGNALS theVersion=refUserInfo(i).Token(" ",2).IntegerValue();}
- catch (Standard_Failure) {
-// cout << "warning: could not read the version in " << aFileName << endl;
+ catch (Standard_Failure const&) {
+// std::cout << "warning: could not read the version in " << aFileName << std::endl;
TCollection_ExtendedString aMsg("Warning: ");
aMsg = aMsg.Cat("could not read the version in ").Cat(aFileName).Cat("\0");
if(!theMsgDriver.IsNull())
- theMsgDriver->Write(aMsg.ToExtString());
+ theMsgDriver->Send(aMsg.ToExtString());
}
}
}
}
- catch (Standard_Failure) {}
+ catch (Standard_Failure const&) {}
+
+ if(theFileIsOpen)
+ {
+ theFileDriver->Close();
+ }
- if(theFileIsOpen) theFileDriver->Close();
- delete theFileDriver;
return theVersion;
}