|
From: Emilien K. <cur...@us...> - 2005-08-17 16:33:26
|
Update of /cvsroot/wxdevcenter/wxDevCenter/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28502/src Modified Files: Document.cpp FileSystemStandard.cpp MiniView.cpp Application.cpp FileSystem.cpp Project.cpp Log Message: Use of wxInput/OutputStream instead of Archive to serialize documents and projects. Index: FileSystemStandard.cpp =================================================================== RCS file: /cvsroot/wxdevcenter/wxDevCenter/src/FileSystemStandard.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** FileSystemStandard.cpp 13 Aug 2005 14:07:37 -0000 1.16 --- FileSystemStandard.cpp 17 Aug 2005 16:33:17 -0000 1.17 *************** *** 27,30 **** --- 27,31 ---- #include <wx/utils.h> + #include <wx/wfstream.h> #include <wx/artprov.h> *************** *** 94,144 **** } ! ! ////////////////////////////////////////////////////////////////////// ! // Archive de fichiers ! ////////////////////////////////////////////////////////////////////// ! ! ArchiveFile::ArchiveFile(wxString strFilePath, ARCHIVE_OPEN_MODE nMode): ! Archive(nMode) ! { ! m_File.Open(strFilePath ,(wxFile::OpenMode)nMode); ! } ! ! ArchiveFile::~ArchiveFile() ! { ! //Flush(); ! m_File.Close(); ! } ! ! bool ArchiveFile::Eof() ! { ! return (Archive::Eof()&&m_File.Eof()); ! } ! ! bool ArchiveFile::Flush() ! { ! if(!Archive::Flush()) ! return false; ! return m_File.Flush(); ! } ! ! size_t ArchiveFile::OnSysRead(void* buffer, size_t bufsize) ! { ! return m_File.Read(buffer, bufsize); ! } ! ! wxFileOffset ArchiveFile::OnSysSeek(wxFileOffset pos, wxSeekMode mode) ! { ! return m_File.Seek(pos, mode); ! } ! ! wxFileOffset ArchiveFile::OnSysTell() const { ! return m_File.Tell();; } ! size_t ArchiveFile::OnSysWrite(const void *buffer, size_t bufsize) { ! return m_File.Write(buffer, bufsize); } --- 95,106 ---- } ! wxInputStream* FileSystemStandardBase::GetInputStream(FilePath strPath) { ! return new wxFileInputStream(GetPhysicalFilePath(strPath)); } ! wxOutputStream* FileSystemStandardBase::GetOutputStream(FilePath strPath) { ! return new wxFileOutputStream(GetPhysicalFilePath(strPath)); } Index: FileSystem.cpp =================================================================== RCS file: /cvsroot/wxdevcenter/wxDevCenter/src/FileSystem.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** FileSystem.cpp 17 Aug 2005 15:01:06 -0000 1.7 --- FileSystem.cpp 17 Aug 2005 16:33:17 -0000 1.8 *************** *** 136,254 **** ! ////////////////////////////////////////////////////////////////////// ! // Archive de base ! ////////////////////////////////////////////////////////////////////// ! ! Archive::Archive(ARCHIVE_OPEN_MODE nMode): ! m_nOpenMode(nMode) ! { ! } ! ! Archive::~Archive(void) ! { ! } ! ! bool Archive::Eof() ! { ! return (m_nOpenMode==read)||(m_nOpenMode==readwrite); ! } ! ! bool Archive::Flush() ! { ! return (m_nOpenMode==write)||(m_nOpenMode==readwrite); ! } ! ! Archive& Archive::operator>>(int &i) ! { ! Read(&i, sizeof(int)); ! return *this; ! } ! ! Archive& Archive::operator>>(unsigned int &n) ! { ! Read(&n, sizeof(unsigned int)); ! return *this; ! } ! ! Archive& Archive::operator>>(short &s) ! { ! Read(&s, sizeof(short)); ! return *this; ! } ! ! Archive& Archive::operator>>(double &d) ! { ! Read(&d, sizeof(double)); ! return *this; ! } ! ! Archive& Archive::operator>>(char &c) ! { ! Read(&c, sizeof(char)); ! return *this; ! } ! ! Archive& Archive::operator>>(wxString &str) ! { ! unsigned short s; ! Read(&s, sizeof(unsigned short)); ! Read(str.GetWriteBuf(s+1), s); ! str.SetChar(s, 0); ! str.UngetWriteBuf(); ! return *this; ! } ! ! Archive& Archive::operator>>(wxImage &img) ! { ! img.LoadFile( (wxInputStream&)*this); ! return *this; ! } ! ! Archive& Archive::operator<<(int i) ! { ! Write(&i, sizeof(int)); ! return *this; ! } ! ! Archive& Archive::operator<<(unsigned int n) ! { ! Write(&n, sizeof(unsigned int)); ! return *this; ! } ! ! Archive& Archive::operator<<(short s) ! { ! Write(&s, sizeof(short)); ! return *this; ! } ! ! Archive& Archive::operator<<(double d) ! { ! Write(&d, sizeof(double)); ! return *this; ! } ! ! Archive& Archive::operator<<(char c) ! { ! Write(&c, sizeof(char)); ! return *this; ! } ! ! Archive& Archive::operator<<(wxString str) { ! unsigned short n = str.Length(); ! Write(&n, sizeof(unsigned short)); ! Write(str.GetData(), n); ! return *this; } ! Archive& Archive::operator<<(wxImage &img) { ! img.SaveFile( (wxOutputStream&)*this, wxBITMAP_TYPE_PNG); ! return *this; } - ////////////////////////////////////////////////////////////////////// // Gestionnaire de systèmes de fichiers --- 136,152 ---- ! // Retourne le flux de lecture sur un fichier. ! wxInputStream* FileSystem::GetInputStream(FilePath WXUNUSED(strPath)) { ! return NULL; } ! // Retourne le flux d'écriture sur un fichier. ! wxOutputStream* FileSystem::GetOutputStream(FilePath WXUNUSED(strPath)) { ! return NULL; } ////////////////////////////////////////////////////////////////////// // Gestionnaire de systèmes de fichiers *************** *** 276,289 **** } ! // Crée une archive sur un fichier. ! Archive* FileSystemManager::GetFileArchive(FilePath strPath, unsigned int nMode) { FileSystem* pFS = GetFileSystem(strPath); if(pFS!=NULL) ! return pFS->GetFileArchive(strPath, nMode); else return NULL; } // Enregistre un système de fichier. bool FileSystemManager::Register(FileSystem* pFileSystem, bool bMountWorkBar) --- 174,199 ---- } ! // Retourne le flux de lecture sur un fichier. ! wxInputStream* FileSystemManager::GetInputStream(FilePath strPath) { FileSystem* pFS = GetFileSystem(strPath); if(pFS!=NULL) ! return pFS->GetInputStream(strPath); ! else ! return NULL; ! } ! ! // Retourne le flux d'écriture sur un fichier. ! wxOutputStream* FileSystemManager::GetOutputStream(FilePath strPath) ! { ! FileSystem* pFS = GetFileSystem(strPath); ! if(pFS!=NULL) ! return pFS->GetOutputStream(strPath); else return NULL; } + + // Enregistre un système de fichier. bool FileSystemManager::Register(FileSystem* pFileSystem, bool bMountWorkBar) Index: Application.cpp =================================================================== RCS file: /cvsroot/wxdevcenter/wxDevCenter/src/Application.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Application.cpp 13 Aug 2005 14:07:37 -0000 1.30 --- Application.cpp 17 Aug 2005 16:33:17 -0000 1.31 *************** *** 381,393 **** - - // Crée une archive (pointeur vers Archive) pour la sérialisation des documents. - Archive* Application::CreateDocumentArchive(FilePath &strDocPath, unsigned int nMode) - { - return m_FileSystemManager.GetFileArchive(strDocPath, nMode); - } - - - ////////////////////////////////////////////////////////////////////// // Gestion de l'application --- 381,384 ---- Index: Project.cpp =================================================================== RCS file: /cvsroot/wxdevcenter/wxDevCenter/src/Project.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Project.cpp 3 Aug 2005 19:21:23 -0000 1.7 --- Project.cpp 17 Aug 2005 16:33:17 -0000 1.8 *************** *** 27,30 **** --- 27,32 ---- #include <wx/tokenzr.h> + #include <wx/stream.h> + using namespace wxDevCenter; *************** *** 61,65 **** // Méthode d'ouverture de projet. ! bool Project::OnOpenProject(Archive& WXUNUSED(ar)) { return true; --- 63,67 ---- // Méthode d'ouverture de projet. ! bool Project::OnOpenProject(wxInputStream* WXUNUSED(in)) { return true; *************** *** 67,71 **** // Méthode de sauvegarde de projet. ! bool Project::OnSaveProject(Archive& WXUNUSED(ar)) { return true; --- 69,73 ---- // Méthode de sauvegarde de projet. ! bool Project::OnSaveProject(wxOutputStream* WXUNUSED(out)) { return true; *************** *** 201,210 **** { // Appelle de le chargement du projet. ! Archive* pAr = Application::GetApp().CreateDocumentArchive(strFile, Archive::read); ! if(pAr!=NULL) { ! if(GetProject().OnOpenProject(*pAr)) { ! delete pAr; return true; } --- 203,212 ---- { // Appelle de le chargement du projet. ! wxInputStream* pIn = Application::GetApp().GetInputStream(strFile); ! if(pIn!=NULL) { ! if(GetProject().OnOpenProject(pIn)) { ! delete pIn; return true; } *************** *** 222,231 **** // Appelle de le chargement du projet. FilePath path = GetProject().GetPath(); ! Archive* pAr = Application::GetApp().CreateDocumentArchive(path, Archive::write); ! if(pAr!=NULL) { ! if(GetProject().OnSaveProject(*pAr)) { ! delete pAr; return true; } --- 224,233 ---- // Appelle de le chargement du projet. FilePath path = GetProject().GetPath(); ! wxOutputStream* pOut = Application::GetApp().GetOutputStream(path); ! if(pOut!=NULL) { ! if(GetProject().OnSaveProject(pOut)) { ! delete pOut; return true; } Index: Document.cpp =================================================================== RCS file: /cvsroot/wxdevcenter/wxDevCenter/src/Document.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Document.cpp 12 Aug 2005 15:50:00 -0000 1.13 --- Document.cpp 17 Aug 2005 16:33:17 -0000 1.14 *************** *** 162,183 **** // Sauvegarde les données du document ! bool Document::SaveDocument(Archive* ar) { ! return SerializeDocument(ar); } // Lit les données du document ! bool Document::LoadDocument(Archive* ar) { ! return SerializeDocument(ar); } - // Processus de lecture/ecriture des données du document - bool Document::SerializeDocument(Archive* WXUNUSED(ar)) - { - return true; - } - ////////////////////////////////////////////////////////////////////// --- 162,177 ---- // Sauvegarde les données du document ! bool Document::SaveDocument(wxOutputStream* WXUNUSED(out)) { ! return true; } // Lit les données du document ! bool Document::LoadDocument(wxInputStream* WXUNUSED(in)) { ! return true; } ////////////////////////////////////////////////////////////////////// *************** *** 194,200 **** { SetDocumentPath(strDocumentPath); ! ! Archive *pArchive = Application::GetApp().CreateDocumentArchive(strDocumentPath, wxStreamBuffer::read); ! if(pArchive==NULL) { wxMessageBox(WXDC_ERROR_LOADDOCUMENT); --- 188,194 ---- { SetDocumentPath(strDocumentPath); ! ! wxInputStream* pIn = Application::GetApp().GetInputStream(strDocumentPath); ! if(pIn==NULL) { wxMessageBox(WXDC_ERROR_LOADDOCUMENT); *************** *** 202,207 **** } ! bool state = LoadDocument(pArchive); ! delete pArchive; SetModifiedFlag(false); return state; --- 196,201 ---- } ! bool state = LoadDocument(pIn); ! delete pIn; SetModifiedFlag(false); return state; *************** *** 214,225 **** SetDocumentPath(strDocumentPath); ! Archive *pArchive = Application::GetApp().CreateDocumentArchive(strDocumentPath, wxStreamBuffer::write); ! if(pArchive==NULL) { wxMessageBox(WXDC_ERROR_SAVEDOCUMENT); return false; } ! bool state = SaveDocument(pArchive); ! delete pArchive; SetModifiedFlag(false); return state; --- 208,219 ---- SetDocumentPath(strDocumentPath); ! wxOutputStream* pOut = Application::GetApp().GetOutputStream(strDocumentPath); ! if(pOut==NULL) { wxMessageBox(WXDC_ERROR_SAVEDOCUMENT); return false; } ! bool state = SaveDocument(pOut); ! delete pOut; SetModifiedFlag(false); return state; Index: MiniView.cpp =================================================================== RCS file: /cvsroot/wxdevcenter/wxDevCenter/src/MiniView.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MiniView.cpp 3 Dec 2004 16:47:46 -0000 1.1 --- MiniView.cpp 17 Aug 2005 16:33:17 -0000 1.2 *************** *** 25,28 **** --- 25,31 ---- #include <wxDevCenter.h> #include <wxDevCenter/DocView.h> + + #include <wx/stream.h> + using namespace wxDevCenter; *************** *** 54,58 **** /** Initialisation du document.*/ ! bool MiniDoc::OnInitialize(Archive* WXUNUSED(pArchive)) { return true; --- 57,61 ---- /** Initialisation du document.*/ ! bool MiniDoc::OnInitialize(wxInputStream* WXUNUSED(in)) { return true; *************** *** 60,64 **** /** Modification du document.*/ ! bool MiniDoc::OnFileModified(Archive* WXUNUSED(pArchive)) { return true; --- 63,67 ---- /** Modification du document.*/ ! bool MiniDoc::OnFileModified(wxInputStream* WXUNUSED(in)) { return true; |