X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2dfa1d9e11128c9708bbf55feeb442471828ac63..9a62fa17b1c342b5b1e1bb9b96373e170a9d8b6f:/include/wx/textbuf.h diff --git a/include/wx/textbuf.h b/include/wx/textbuf.h index 3dec00b608..f768a56324 100644 --- a/include/wx/textbuf.h +++ b/include/wx/textbuf.h @@ -14,6 +14,7 @@ #include "wx/defs.h" #include "wx/arrstr.h" +#include "wx/convauto.h" // ---------------------------------------------------------------------------- // constants @@ -80,10 +81,10 @@ public: bool Create(const wxString& strBufferName); // Open() also loads buffer in memory on success - bool Open(wxMBConv& conv = wxConvUTF8); + bool Open(const wxMBConv& conv = wxConvAuto()); // same as Open() but with (another) buffer name - bool Open(const wxString& strBufferName, wxMBConv& conv = wxConvUTF8); + bool Open(const wxString& strBufferName, const wxMBConv& conv = wxConvAuto()); // closes the buffer and frees memory, losing all changes bool Close(); @@ -114,12 +115,15 @@ public: // NB: const is commented out because not all compilers understand // 'mutable' keyword yet (m_nCurLine should be mutable) - wxString& GetFirstLine() /* const */ { return m_aLines[m_nCurLine = 0]; } - wxString& GetNextLine() /* const */ { return m_aLines[++m_nCurLine]; } + wxString& GetFirstLine() /* const */ + { return m_aLines.empty() ? ms_eof : m_aLines[m_nCurLine = 0]; } + wxString& GetNextLine() /* const */ + { return ++m_nCurLine == m_aLines.size() ? ms_eof + : m_aLines[m_nCurLine]; } wxString& GetPrevLine() /* const */ - { wxASSERT(m_nCurLine > 0); return m_aLines[--m_nCurLine]; } + { wxASSERT(m_nCurLine > 0); return m_aLines[--m_nCurLine]; } wxString& GetLastLine() /* const */ - { return m_aLines[m_nCurLine = m_aLines.size() - 1]; } + { m_nCurLine = m_aLines.size() - 1; return m_aLines.Last(); } // get the type of the line (see also GetEOL) wxTextFileType GetLineType(size_t n) const { return m_aTypes[n]; } @@ -158,7 +162,7 @@ public: // change the buffer (default argument means "don't change type") // possibly in another format bool Write(wxTextFileType typeNew = wxTextFileType_None, - wxMBConv& conv = wxConvUTF8); + const wxMBConv& conv = wxConvAuto()); // dtor virtual ~wxTextBuffer(); @@ -180,10 +184,11 @@ protected: virtual bool OnOpen(const wxString &strBufferName, wxTextBufferOpenMode openmode) = 0; virtual bool OnClose() = 0; - virtual bool OnRead(wxMBConv& conv) = 0; - virtual bool OnWrite(wxTextFileType typeNew, wxMBConv& conv) = 0; + virtual bool OnRead(const wxMBConv& conv) = 0; + virtual bool OnWrite(wxTextFileType typeNew, const wxMBConv& conv) = 0; - wxString m_strBufferName; // name of the buffer + static wxString ms_eof; // dummy string returned at EOF + wxString m_strBufferName; // name of the buffer private: wxArrayLinesType m_aTypes; // type of each line