From: pdn Date: Tue, 22 Sep 2015 06:47:35 +0000 (+0300) Subject: Fix for draw tests, restoring API and linux compilation X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=7b79dbbed786426faa50fa2fdda88024011bce9c;p=occt-copy.git Fix for draw tests, restoring API and linux compilation --- diff --git a/src/FSD/FSD_CmpFile.cxx b/src/FSD/FSD_CmpFile.cxx index c7c7e4f67a..2f8651d74b 100644 --- a/src/FSD/FSD_CmpFile.cxx +++ b/src/FSD/FSD_CmpFile.cxx @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -72,6 +73,18 @@ Storage_Error FSD_CmpFile::IsGoodFileType(const Handle(Storage_IODevice)& aDevic //purpose : //======================================================================= +Storage_Error FSD_CmpFile::Open(const TCollection_AsciiString& aName, const Storage_OpenMode aMode) +{ + + Handle(Storage_File) aFile = new Storage_File(TCollection_ExtendedString(aName)); + return Open(aFile, aMode); +} + +//======================================================================= +//function : Open +//purpose : +//======================================================================= + Storage_Error FSD_CmpFile::Open(const Handle(Storage_IODevice)& aDevice,const Storage_OpenMode aMode) { SetDevice(aDevice); @@ -80,61 +93,6 @@ Storage_Error FSD_CmpFile::Open(const Handle(Storage_IODevice)& aDevice,const St return Storage_VSOpenError; return Device()->Open(aMode); - - /* - Storage_Error result = Storage_VSOk; - - SetName(aName); - - if (OpenMode() == Storage_VSNone) { - -#if defined(_WNT32) - TCollection_ExtendedString aWName(aName); - if (aMode == Storage_VSRead) { - myStream.open((const wchar_t*)aWName.ToExtString(),ios::in|ios::binary); // ios::nocreate is not portable - } - else if (aMode == Storage_VSWrite) { - myStream.open((const wchar_t*)aWName.ToExtString(),ios::out|ios::binary); - } - else if (aMode == Storage_VSReadWrite) { - myStream.open((const wchar_t*)aWName.ToExtString(),ios::in|ios::out|ios::binary); - } -#elif !defined(IRIX) && !defined(DECOSF1) - if (aMode == Storage_VSRead) { - myStream.open(aName.ToCString(),ios::in|ios::binary); // ios::nocreate is not portable - } - else if (aMode == Storage_VSWrite) { - myStream.open(aName.ToCString(),ios::out|ios::binary); - } - else if (aMode == Storage_VSReadWrite) { - myStream.open(aName.ToCString(),ios::in|ios::out|ios::binary); - } -#else - if (aMode == Storage_VSRead) { - myStream.open(aName.ToCString(),ios::in); // ios::nocreate is not portable - } - else if (aMode == Storage_VSWrite) { - myStream.open(aName.ToCString(),ios::out); - } - else if (aMode == Storage_VSReadWrite) { - myStream.open(aName.ToCString(),ios::in|ios::out); - } -#endif - - if (myStream.fail()) { - result = Storage_VSOpenError; - } - else { - myStream.precision(17); - myStream.imbue (std::locale::classic()); // use always C locale - SetOpenMode(aMode); - } - } - else { - result = Storage_VSAlreadyOpen; - } - return result; - */ } //======================================================================= @@ -183,24 +141,6 @@ const Standard_CString FSD_CmpFile::MagicNumber() void FSD_CmpFile::FlushEndOfLine() { -// TCollection_AsciiString aDummy; -// ReadLine (aDummy); // flush is nothing more than to read till the line-break - /* - static char Buffer[8192]; - char c; - Standard_Boolean IsEnd = Standard_False; - - while (!IsEnd && !FSD_CmpFile::IsEnd()) { - Buffer[0] = '\0'; - myStream.get(Buffer,8192,'\n'); - - if (myStream.get(c) && c != '\r' && c != '\n') { - } - else { - IsEnd = Standard_True; - } - } - */ } //======================================================================= @@ -218,7 +158,6 @@ void FSD_CmpFile::WriteLine(const TCollection_AsciiString& aStr, const Standard_ Storage_StreamWriteError::Raise(); } - //======================================================================= //function : ReadLine //purpose : read from the current position to the end of line. @@ -230,14 +169,14 @@ void FSD_CmpFile::ReadLine(TCollection_AsciiString& buffer) buffer.Clear(); - while (!IsEnd && !FSD_CmpFile::IsEnd()) + while ( !IsEnd && !FSD_CmpFile::IsEnd() ) { Standard_Character c; Device()->Read( (Standard_Address)&c, 1 ); if ( c != '\n' && c != '\r') { buffer += c; - } + } else { buffer += '\0'; diff --git a/src/FSD/FSD_CmpFile.hxx b/src/FSD/FSD_CmpFile.hxx index 29f8366fff..5e8a5de89a 100644 --- a/src/FSD/FSD_CmpFile.hxx +++ b/src/FSD/FSD_CmpFile.hxx @@ -56,6 +56,8 @@ public: Standard_EXPORT FSD_CmpFile(); + + Standard_EXPORT Storage_Error Open (const TCollection_AsciiString& aName, const Storage_OpenMode aMode); Standard_EXPORT Storage_Error Open (const Handle(Storage_IODevice)& aDevice, const Storage_OpenMode aMode); diff --git a/src/FSD/FSD_File.cxx b/src/FSD/FSD_File.cxx index 0ffbef9620..22464c51a2 100644 --- a/src/FSD/FSD_File.cxx +++ b/src/FSD/FSD_File.cxx @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -27,7 +28,6 @@ const Standard_CString MAGICNUMBER = "FSDFILE"; const Standard_CString ENDOFNORMALEXTENDEDSECTION = "BEGIN_REF_SECTION"; const Standard_Integer SIZEOFNORMALEXTENDEDSECTION = 16; -//#define USEOSDREAL 1 //======================================================================= //function : FSD_File @@ -68,6 +68,20 @@ Storage_Error FSD_File::IsGoodFileType(const Handle(Storage_IODevice)& aDevice) return s; } +//======================================================================= +//function : Open +//purpose : +//======================================================================= + +Storage_Error FSD_File::Open(const TCollection_AsciiString& aName, const Storage_OpenMode aMode) +{ + + Handle(Storage_File) aFile = new Storage_File(TCollection_ExtendedString(aName)); + return Open(aFile, aMode); +} + + + //======================================================================= //function : Open //purpose : @@ -129,22 +143,6 @@ const Standard_CString FSD_File::MagicNumber() void FSD_File::FlushEndOfLine() { - TCollection_AsciiString aDummy; - ReadLine (aDummy); // flush is nothing more than to read till the line-break -/* static char Buffer[8192]; - char c; - Standard_Boolean IsEnd = Standard_False; - - while (!IsEnd && !FSD_File::IsEnd()) { - Buffer[0] = '\0'; - myStream.get(Buffer,8192,'\n'); - - if (myStream.get(c) && c != '\n') { - } - else { - IsEnd = Standard_True; - } - }*/ } //======================================================================= @@ -169,19 +167,18 @@ void FSD_File::WriteLine(const TCollection_AsciiString& aStr, const Standard_Boo void FSD_File::ReadLine(TCollection_AsciiString& buffer) { - // char Buffer[8193]; Standard_Boolean IsEnd = Standard_False; buffer.Clear(); while ( !IsEnd && !FSD_File::IsEnd() ) { - // Buffer[0] = '\0'; - // myStream.getline(Buffer,8192,'\n'); Standard_Character c; Device()->Read( (Standard_Address)&c, 1 ); if ( c != '\n') + { buffer += c; + } else { buffer += '\0'; diff --git a/src/FSD/FSD_File.hxx b/src/FSD/FSD_File.hxx index 7954d64a3c..315d5f4e05 100644 --- a/src/FSD/FSD_File.hxx +++ b/src/FSD/FSD_File.hxx @@ -69,6 +69,13 @@ public: //! The function returns Storage_VSOk if the file //! is opened correctly, or any other value of the //! Storage_Error enumeration which specifies the problem encountered. + Standard_EXPORT Storage_Error Open (const TCollection_AsciiString& aName, const Storage_OpenMode aMode); + + //! Opens source specified by device. aMode precises if the device is + //! opened in read or write mode. + //! The function returns Storage_VSOk if the file + //! is opened correctly, or any other value of the + //! Storage_Error enumeration which specifies the problem encountered. Standard_EXPORT Storage_Error Open (const Handle(Storage_IODevice)& aDevice, const Storage_OpenMode aMode); Standard_EXPORT Standard_Boolean IsEnd(); diff --git a/src/PCDM/PCDM_Reference.hxx b/src/PCDM/PCDM_Reference.hxx index 16c4c0b8e7..487ba8e785 100644 --- a/src/PCDM/PCDM_Reference.hxx +++ b/src/PCDM/PCDM_Reference.hxx @@ -39,7 +39,7 @@ public: Standard_EXPORT Standard_Integer ReferenceIdentifier() const; - Standard_EXPORT Handle(Storage_IODevice) PCDM_Reference::Device() const; + Standard_EXPORT Handle(Storage_IODevice) Device() const; Standard_EXPORT Standard_Integer DocumentVersion() const; diff --git a/src/QABugs/QABugs_11.cxx b/src/QABugs/QABugs_11.cxx index ca5c858ad1..1ada39b5e6 100644 --- a/src/QABugs/QABugs_11.cxx +++ b/src/QABugs/QABugs_11.cxx @@ -825,7 +825,7 @@ static Standard_Integer OCC381_SaveAs (Draw_Interpretor& di, Standard_Integer nb if (!DDocStd::Find(A)) return 1; TCollection_ExtendedString theStatusMessage; - PCDM_StoreStatus theStatus = PCDM_SS_Failure; //A->SaveAs(D,path, theStatusMessage); + PCDM_StoreStatus theStatus = A->SaveAs(D,path, theStatusMessage); if (theStatus != PCDM_SS_OK ) { switch ( theStatus ) { case PCDM_SS_DriverFailure: { diff --git a/src/QABugs/QABugs_3.cxx b/src/QABugs/QABugs_3.cxx index b4438aff67..7ebd7b6ac9 100644 --- a/src/QABugs/QABugs_3.cxx +++ b/src/QABugs/QABugs_3.cxx @@ -1594,9 +1594,8 @@ static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** a TDF_Label L; DDF::AddLabel(aDF, "0:2", L); - Handle(TPrsStd_AISPresentation) AISP = new TPrsStd_AISPresentation; - - AISP->Set(L,TDataXtd_Constraint::GetID()); + Handle(TPrsStd_AISPresentation) AISP = + TPrsStd_AISPresentation::Set(L,TDataXtd_Constraint::GetID()); if (AISP->HasOwnMode()) {di<<3;return 0;} AISP->SetMode(3);