TextFile.h

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 
00022 #pragma once
00023 
00024 #include <afx.h>
00025 
00026 class CTextFile : protected CStdioFile
00027 {
00028 public:
00029         typedef enum {ASCII, UTF8, LE16, BE16} enc;
00030 
00031 private:
00032         enc m_encoding;
00033         int m_offset;
00034 
00035 public:
00036         CTextFile();
00037 
00038         virtual bool Open(LPCTSTR lpszFileName);
00039         virtual bool Save(LPCTSTR lpszFileName, enc e /*= ASCII*/);
00040 
00041         enc GetEncoding();
00042         bool IsUnicode();
00043 
00044         // CFile
00045 
00046         CString GetFilePath() const;
00047 
00048         // CStdioFile
00049 
00050     ULONGLONG GetPosition() const;
00051         ULONGLONG GetLength() const;
00052         ULONGLONG Seek(LONGLONG lOff, UINT nFrom);
00053 
00054         void WriteString(LPCSTR lpsz/*CStringA str*/);
00055         void WriteString(LPCWSTR lpsz/*CStringW str*/);
00056         BOOL ReadString(CStringA& str);
00057         BOOL ReadString(CStringW& str);
00058 };
00059 
00060 class CWebTextFile : public CTextFile
00061 {
00062         LONGLONG m_llMaxSize;
00063         CString m_tempfn;
00064 
00065 public:
00066         CWebTextFile(LONGLONG llMaxSize = 1024*1024);
00067 
00068         bool Open(LPCTSTR lpszFileName);
00069         bool Save(LPCTSTR lpszFileName, enc e /*= ASCII*/);
00070         void Close();
00071 };
00072 
00073 extern CStringW AToW(CStringA str);
00074 extern CStringA WToA(CStringW str);
00075 extern CString AToT(CStringA str);
00076 extern CString WToT(CStringW str);
00077 extern CStringA TToA(CString str);
00078 extern CStringW TToW(CString str);

Generated on Tue Dec 13 14:47:55 2005 for guliverkli by  doxygen 1.4.5