textfile.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/textfile.h
  3. // Purpose: class wxTextFile to work with text files of _small_ size
  4. // (file is fully loaded in memory) and which understands CR/LF
  5. // differences between platforms.
  6. // Author: Vadim Zeitlin
  7. // Modified by:
  8. // Created: 03.04.98
  9. // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
  10. // Licence: wxWindows licence
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #ifndef _WX_TEXTFILE_H
  13. #define _WX_TEXTFILE_H
  14. #include "wx/defs.h"
  15. #include "wx/textbuf.h"
  16. #if wxUSE_TEXTFILE
  17. #include "wx/file.h"
  18. // ----------------------------------------------------------------------------
  19. // wxTextFile
  20. // ----------------------------------------------------------------------------
  21. class WXDLLIMPEXP_BASE wxTextFile : public wxTextBuffer
  22. {
  23. public:
  24. // constructors
  25. wxTextFile() { }
  26. wxTextFile(const wxString& strFileName);
  27. protected:
  28. // implement the base class pure virtuals
  29. virtual bool OnExists() const;
  30. virtual bool OnOpen(const wxString &strBufferName,
  31. wxTextBufferOpenMode OpenMode);
  32. virtual bool OnClose();
  33. virtual bool OnRead(const wxMBConv& conv);
  34. virtual bool OnWrite(wxTextFileType typeNew, const wxMBConv& conv);
  35. private:
  36. wxFile m_file;
  37. wxDECLARE_NO_COPY_CLASS(wxTextFile);
  38. };
  39. #else // !wxUSE_TEXTFILE
  40. // old code relies on the static methods of wxTextFile being always available
  41. // and they still are available in wxTextBuffer (even if !wxUSE_TEXTBUFFER), so
  42. // make it possible to use them in a backwards compatible way
  43. typedef wxTextBuffer wxTextFile;
  44. #endif // wxUSE_TEXTFILE/!wxUSE_TEXTFILE
  45. #endif // _WX_TEXTFILE_H