亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? textfile.cpp

?? A Model-View-Controller Framework that integrates with the MFC Doc/View architecture.
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/*	NOTE: If you running this in a none-Windows platform, 
	then you should remove the include file below.
  */
	//#include <afx.h>
	#include "stdafx.h"

#include "textfile.h"

#if PEK_TX_TECHLEVEL == 0
 //Include iostream if running in ANSI mode.
 #include <iostream>
#endif

//Base constructor
CTextFileBase::CTextFileBase()
{
	#if PEK_TX_TECHLEVEL > 0
	m_codepage = CP_ACP;
	m_unknownChar = 0;
	#else
	m_unknownChar = '?';
	#endif

	#if PEK_TX_TECHLEVEL == 1
	m_hFile = INVALID_HANDLE_VALUE;
	#elif PEK_TX_TECHLEVEL == 2
	m_file = NULL;
	m_closeAndDeleteFile = false;
	#endif

	m_datalost = false;

	m_buffpos = -1;
}

//Base destructor
CTextFileBase::~CTextFileBase()
{
	Close();
}

//Set which character to use when conversion can't be done
void CTextFileBase::SetUnknownChar(const char unknown)
{
	m_unknownChar = unknown;
}

//True if data was lost during conversion
bool CTextFileBase::IsDataLost() const
{
	return m_datalost;
}

//Reset the data lost flag
void CTextFileBase::ResetDataLostFlag()
{
	m_datalost = false;
}

#if PEK_TX_TECHLEVEL > 0

//Make sure we have a legal value for code page to use when
//converting string. Used for debugging only.
#define IsLegalCodePage(cp) (cp == CP_ACP || cp == CP_MACCP || cp == CP_OEMCP || cp == CP_SYMBOL || cp == CP_THREAD_ACP || cp == CP_UTF7 || cp == CP_UTF8 || IsValidCodePage(cp))

#ifndef ASSERT 
 #define ASSERT 0
#endif


//(Windows-specific) Set codepage to use when working with non-unicode strings.
void CTextFileBase::SetCodePage(const UINT codepage)
{
	ASSERT(IsLegalCodePage(codepage));
	m_codepage = codepage;
}

//(Windows-specific) Get codepage to use when working with non-unicode strings.
UINT CTextFileBase::GetCodePage() const
{
	return m_codepage;
}

//(Windows-specific) Convert string to wstring with current codepage
inline void CTextFileBase::CharToWstring(const char* from, wstring &to) const
{
	ConvertCharToWstring(from, to, m_codepage);
}

//(Windows-specific) Convert wstring to string with current codepage
inline void CTextFileBase::WcharToString(const wchar_t* from, string &to) 
{
	ConvertWcharToString(from, to, m_codepage, &m_datalost, m_unknownChar);
}


//(Windows-specific) Convert char* to wstring
void CTextFileBase::ConvertCharToWstring(const char* from, wstring &to, UINT codepage)
{
	to = L"";

	ASSERT(IsLegalCodePage(codepage));
	//Use api convert routine
	int wlen = MultiByteToWideChar( codepage,
									0,
									from,
									-1,
									NULL,
									0);

	//if wlen == 0, some unknown codepage was probably used.
	ASSERT(wlen);
	if(wlen == 0) 
		return;

	wchar_t* wbuffer = new wchar_t[wlen+2];

    MultiByteToWideChar(    codepage,
                            0,
                            from,
                            -1,
                            wbuffer,
                            wlen);

	to = wbuffer;
	delete [] wbuffer;

}

//(Windows-specific) Convert wchar_* to string
void CTextFileBase::ConvertWcharToString(const wchar_t* from, string &to, 
										 UINT codepage, bool* datalost, char unknownchar)
{
	to = "";

	ASSERT(IsLegalCodePage(codepage));
	
	int alen = 	WideCharToMultiByte(	codepage,
							0,
							from,
							-1, 
							NULL,
							0,
							NULL,
							NULL);

	//if alen == 0, some unknown codepage was probably used.
	ASSERT(alen);
	if(alen == 0) 
		return;


	//Use mfc convert routine
	char* abuffer = new char[alen+2]; 
	BOOL UsedDefault=FALSE;

	WideCharToMultiByte(	codepage,
							0,
							from,
							-1,
							abuffer,
							alen, 
							(unknownchar != 0 ? &unknownchar : NULL),
							(datalost != NULL ? &UsedDefault : NULL)
						);


	if( datalost != NULL && UsedDefault != FALSE)
		*datalost = true;
	
	to = abuffer;
	delete [] abuffer;
}


#else

//(None-windows-specific) Convert string to wstring 
inline void CTextFileBase::CharToWstring(const char* from, wstring &to) const
{
	ConvertCharToWstring(from, to);
}

//(None-windows-specific) Convert wstring to string
inline void CTextFileBase::WcharToString(const wchar_t* from, string &to) 
{
	ConvertWcharToString(from, to, &m_datalost, m_unknownChar);
}


//(None-windows-specific) Convert char* to wstring
void CTextFileBase::ConvertCharToWstring(const char* from, wstring &to)
{
	to = L"";

	size_t pos=0;
	wchar_t temp[1];

	while(true)
	{
		size_t len = mbtowc(temp, from+pos, MB_CUR_MAX);

		//Found end
		if(len == 0)
			return;
		else if(len == (size_t)-1)
		{
			//Unknown character, should never happen
			pos++;
		}
		else
		{
			to += temp[0];
			pos += len;
		}
	}

}

//(None-windows-specific) Convert wchar_* to string
void CTextFileBase::ConvertWcharToString(const wchar_t* from, string &to, bool* datalost, char unknownchar)
{
	to = "";

	char* temp = new char[MB_CUR_MAX];
	
	while(*from != L'\0')
	{
		size_t len = wctomb(temp, *from);

		//Found end
		if(len == 0)
			break;
		else if(len == (size_t)-1)
		{
			//Replace with unknown character
			to += unknownchar;

			if(datalost != NULL)
				*datalost=true;
		}
		else
		{
			//Copy all characters
			for(size_t i=0; i<len; i++)
				to += temp[i];
		}

		from++;
	}

	delete [] temp;
}


#endif






//Return file encoding
CTextFileBase::TEXTENCODING CTextFileBase::GetEncoding() const 
{
	return m_encoding;
};

//Is file open?
int CTextFileBase::IsOpen() 
{
#if PEK_TX_TECHLEVEL == 0
	return m_file.is_open();
#elif PEK_TX_TECHLEVEL == 1
	return m_hFile != INVALID_HANDLE_VALUE;
#else
	return (m_file != NULL && m_file->m_hFile != CFile::hFileNull);
#endif

}

//Close file
void CTextFileBase::Close()
{
	if(IsOpen())
	{
#if PEK_TX_TECHLEVEL == 0
		m_file.close();
#elif PEK_TX_TECHLEVEL == 1
		::CloseHandle(m_hFile);
		m_hFile = INVALID_HANDLE_VALUE;
#else
		if(m_closeAndDeleteFile)
		{
			m_file->Close();
		}		
#endif
	}

#if PEK_TX_TECHLEVEL == 2
	if(m_closeAndDeleteFile)
	{
		delete m_file;
		m_file = NULL;
	}
#endif
}


//Create textfile
CTextFileWrite::CTextFileWrite(const FILENAMECHAR* filename, TEXTENCODING encoding)
{
#if PEK_TX_TECHLEVEL == 0
	m_file.open(filename, ios::binary | ios::out );
#elif PEK_TX_TECHLEVEL == 1

	m_hFile = ::CreateFile(	filename, 
							GENERIC_WRITE,
							0,
							NULL,
							CREATE_ALWAYS, 
							FILE_ATTRIBUTE_NORMAL,
							NULL);

#else
	m_file = new CFile;
	m_file->Open(filename, CFile::modeCreate | CFile::modeWrite);

	m_closeAndDeleteFile = true;
#endif

	m_buffpos = -1;
	m_buffsize = 0;

	m_encoding = encoding;
	
	WriteBOM();
}

#if PEK_TX_TECHLEVEL==2
//Create textfile from CFile object
CTextFileWrite::CTextFileWrite(CFile* file, TEXTENCODING encoding)
{
	ASSERT(file);

	m_file = file;
	m_closeAndDeleteFile = false;

	m_encoding = encoding;

	m_buffpos = -1;
	m_buffsize = 0;

	WriteBOM();
}
#endif

CTextFileWrite::~CTextFileWrite()
{
	Close();
}

void CTextFileWrite::WriteBOM()
{
	//Write BOM
	if(IsOpen())
	{
		if(m_encoding == UNI16_BE || m_encoding == UNI16_LE)
		{
			//Write BOM
			WriteWchar( 0xFEFF );
		}
		else if(m_encoding == UTF_8)
		{
			//Write UTF-8 BOM.  0xEF 0xBB 0xBF
			WriteByte(0xEF);
			WriteByte(0xBB);
			WriteByte(0xBF);
		}
	}
}

//Write one byte
void CTextFileWrite::WriteByte(const unsigned char byte)
{
	//Instead of writing, save data in buffer and write when buffer is full
	if(m_buffpos+1 >= BUFFSIZE)
		Flush();

	m_buffpos++;
	m_buf[m_buffpos] = byte;
}

//Write and empty buffer
void CTextFileWrite::Flush()
{
#if PEK_TX_TECHLEVEL==0
	m_file.write(m_buf, m_buffpos+1);
#elif PEK_TX_TECHLEVEL==1

	DWORD nWritten;
	if (!::WriteFile(m_hFile, m_buf, m_buffpos+1, &nWritten, NULL))
	{
		//Something bad has happend! Close file
		CTextFileBase::Close();

		//Throw exception
		throw CTextFileException(GetLastError());
	}

#else
	m_file->Write(m_buf, m_buffpos+1);	
#endif
	
	m_buffpos = -1;
}

void CTextFileWrite::WriteWchar(const wchar_t ch)
{
	//Write HO byte first?
	if(m_encoding == UNI16_BE)
	{
		//Write HO byte
		WriteByte((unsigned char) (ch >> 8) );
		//Write LO byte
		WriteByte((unsigned char) ch);
	}
	else if(m_encoding == UNI16_LE)
	{
		//Write LO byte
		WriteByte((unsigned char) ch);
		//Write HO byte
		WriteByte((unsigned char) (ch >> 8) );
	}
	else
	{
		//http://www.cl.cam.ac.uk/~mgk25/unicode.html#examples
		//http://www.ietf.org/rfc/rfc3629.txt

		//Just a single byte?
		if(ch <= 0x7F)
		{
			//U-00000000 - U-0000007F:  0xxxxxxx  
			WriteByte( (unsigned char) ch );
		}

		//Two bytes?
		else if(ch <= 0x7FF)
		{
			//U-00000080 - U-000007FF:  110xxxxx 10xxxxxx  
			WriteByte( (unsigned char) (0xC0 | (ch>>6)) );
			WriteByte( (unsigned char) (0x80 | (ch&0x3F)) );
		}

		//Three bytes?
		else if(ch <= 0xFFFF)
		{
			//U-00000800 - U-0000FFFF:  1110xxxx 10xxxxxx 10xxxxxx  
			WriteByte( (unsigned char) (0xE0 | (  ch>>12)		));
			WriteByte( (unsigned char) (0x80 | ( (ch>>6)&0x3F ) ));
			WriteByte( (unsigned char) (0x80 | ( ch&0x3F )		));
		}

		/* //UPS! I did some coding for UTF-32, may be useful in the future :-)
		//Four bytes?
		else if(ch <= 0x1FFFFF)
		{
			//U-00010000 - U-001FFFFF:  11110xxx 10xxxxxx 10xxxxxx 10xxxxxx  
			WriteByte( (unsigned char) (0xF0 | (  ch>>18)		 ));
			WriteByte( (unsigned char) (0xA0 | ( (ch>>12)&0xA0 ) ));
			WriteByte( (unsigned char) (0xA0 | ( (ch>>6)&0xA0 ) ));
			WriteByte( (unsigned char) (0xA0 | ( ch&0xA0 )		));
		}
		
		//Five bytes bytes?
		else if(ch <= 0x3FFFFFF)
		{
			//U-00200000 - U-03FFFFFF:  111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx  
			WriteByte( (unsigned char) (0xF8 | (  ch>>24)	 	 ));
			WriteByte( (unsigned char) (0xA0 | ( (ch>>18)&0xA0 ) ));
			WriteByte( (unsigned char) (0xA0 | ( (ch>>12)&0xA0 ) ));
			WriteByte( (unsigned char) (0xA0 | ( (ch>>6)&0xA0 ) ));
			WriteByte( (unsigned char) (0xA0 | ( ch&0xA0 )		));
		}
		
		//Five bytes bytes?
		else if(ch <= 0x7FFFFFFF)
		{
			//U-04000000 - U-7FFFFFFF:  1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 
			WriteByte( (unsigned char) (0xFC | (  ch>>30)		 ));
			WriteByte( (unsigned char) (0xA0 | ( (ch>>24)&0xA0 ) ));
			WriteByte( (unsigned char) (0xA0 | ( (ch>>18)&0xA0 ) ));
			WriteByte( (unsigned char) (0xA0 | ( (ch>>12)&0xA0 ) ));
			WriteByte( (unsigned char) (0xA0 | ( (ch>>6)&0xA0 ) ));
			WriteByte( (unsigned char) (0xA0 | ( ch&0xA0 )		));
		}*/

	}
}

//Write new line
void CTextFileWrite::WriteEndl()
{
	if(m_encoding == ASCII)
	{
		WriteByte(0x0D);
		WriteByte(0x0A);
	}
	else 
	{
		WriteWchar(0x0D);
		WriteWchar(0x0A);
	}
}


//Write a c-string in ASCII. 
//In versions before 1.02 this function wrote directly to file,
//no buffer was used. But sense WriteEndl() used buffer the file was
//written incorretly. Now buffer is used here too, this is the
//fastest solution.
void CTextFileWrite::WriteAsciiString(const char* s)
{	
	while(*s != '\0')
	{
		WriteByte(*s);
		s++;
	}
}


CTextFileWrite& CTextFileWrite::operator<< (const char* text)
{
	Write(text); 
	return *this;
};

CTextFileWrite& CTextFileWrite::operator << (const string& text)
{
	Write(text.c_str());
	return *this;
}

CTextFileWrite& CTextFileWrite::operator<< (const wchar_t* text)
{
	Write(text); 
	return *this;
};

CTextFileWrite& CTextFileWrite::operator << (const wstring& text)
{
	Write(text.c_str());
	return *this;
}


CTextFileWrite& CTextFileWrite::operator<< (const wchar_t wc)
{
	//Not the perfect code, but it's easy!
	wstring text;
	text=wc;
	Write(text.c_str());
	return *this;
};

CTextFileWrite& CTextFileWrite::operator<< (const char c)
{
	//Not the perfect code, but it's easy!
	string text;
	text=c;
	Write(text.c_str());
	return *this;
};

void CTextFileWrite::Write(const string& text)
{
	Write(text.c_str());
}

void CTextFileWrite::Write(const wstring& text)
{
	Write(text.c_str());
}

//Write char*
void CTextFileWrite::Write(const char* text)
{
	//ASCIItext file format?
	if(m_encoding == ASCII)
		WriteAsciiString(text);
	else
	{
		//Convert text to unicode
		wstring utext;
		CharToWstring(text, utext);

		//OK, lets write unicode
		for(wstring::const_iterator i=utext.begin();
			i < utext.end();
			i++)
		{
			WriteWchar(*i);
		}

	}
}

//Write wcar_t*
void CTextFileWrite::Write(const wchar_t* utext)
{
	//ASCII text file format?
	if(m_encoding == ASCII)
	{
		//Convert to string and write
		string text;
		WcharToString(utext, text);
		WriteAsciiString(text.c_str());
	}
	else
	{
		while(*utext != 0)
		{
			WriteWchar(*utext);
			utext++;
		}
	}
}

//Close the file
void CTextFileWrite::Close()
{
	if(IsOpen())
		Flush();

	CTextFileBase::Close();
}

CTextFileRead::CTextFileRead(const FILENAMECHAR* filename)
{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩高清影院| 欧美一区二区三区小说| 亚洲欧美激情一区二区| 日韩精品一区二区在线| 国产精品乱码人人做人人爱| 日韩不卡免费视频| 成人黄色电影在线| 日韩一区二区三区精品视频| 国产精品久久久久精k8| 美女精品自拍一二三四| 欧美探花视频资源| 国产精品传媒入口麻豆| 精品一区精品二区高清| 欧美精品一级二级三级| 亚洲美女淫视频| 成人午夜视频福利| 精品福利视频一区二区三区| 首页国产欧美久久| 色悠悠亚洲一区二区| 中日韩免费视频中文字幕| 国产一区二区在线电影| 日韩一区二区三区在线视频| 婷婷久久综合九色综合绿巨人| 91日韩精品一区| 亚洲视频在线一区二区| 波多野结衣精品在线| 国产精品美女久久久久久久| 成人免费看片app下载| 久久精品亚洲精品国产欧美kt∨| 久久av中文字幕片| 日韩一区二区在线看| 免费看日韩a级影片| 欧美精品九九99久久| 日本中文字幕一区二区有限公司| 欧美亚洲综合网| 亚洲1区2区3区视频| 欧美午夜精品一区| 日本在线不卡视频| 欧美岛国在线观看| 国产麻豆一精品一av一免费| 国产欧美一区二区三区在线看蜜臀| 国产一区中文字幕| 国产精品三级av| 色综合天天综合狠狠| 亚洲午夜久久久久久久久电影院| 欧美日韩国产一区二区三区地区| 亚洲国产欧美一区二区三区丁香婷| 欧美图片一区二区三区| 日产国产高清一区二区三区| 精品91自产拍在线观看一区| 懂色一区二区三区免费观看| 日韩美女精品在线| 欧美区视频在线观看| 免费一级片91| 中文字幕中文字幕中文字幕亚洲无线| 91麻豆文化传媒在线观看| 亚洲影院久久精品| 26uuu精品一区二区在线观看| 成人激情免费电影网址| 亚洲综合视频在线观看| 日韩美女一区二区三区四区| 成人理论电影网| 三级欧美在线一区| 国产精品视频你懂的| 欧美视频在线一区| 国产精品一区二区三区网站| 一区二区三区在线观看国产 | 91黄色免费网站| 日本美女一区二区三区视频| 亚洲国产精品精华液ab| 欧美日韩一卡二卡三卡| 国产成人亚洲综合a∨婷婷| 夜夜夜精品看看| 国产欧美精品一区二区色综合| 在线观看中文字幕不卡| 国产乱子伦一区二区三区国色天香| 亚洲欧美色图小说| 久久综合久久99| 欧美日韩亚洲丝袜制服| thepron国产精品| 麻豆一区二区在线| 亚洲小说欧美激情另类| 国产女同互慰高潮91漫画| 5566中文字幕一区二区电影| 91在线观看成人| 丰满放荡岳乱妇91ww| 日本亚洲最大的色成网站www| 国产精品久久久久永久免费观看 | 色先锋资源久久综合| 国产一区二区不卡在线| 日日夜夜免费精品| 一区二区三区中文字幕在线观看| 国产三级精品视频| 精品少妇一区二区三区在线播放| 欧美日韩视频在线第一区| 91丝袜美女网| youjizz国产精品| 国产精选一区二区三区| 久久精品国产99| 爽好多水快深点欧美视频| 一区二区三区四区激情| 亚洲裸体在线观看| 自拍av一区二区三区| 中文字幕+乱码+中文字幕一区| 欧美变态tickling挠脚心| 欧美一区二区三区在线电影| 欧美日韩国产免费| 欧美另类久久久品| 欧美视频在线观看一区| 欧美日韩一区二区三区四区五区| 一本大道综合伊人精品热热| 91碰在线视频| 欧美亚洲日本国产| 欧美日韩精品系列| 欧美精品v国产精品v日韩精品 | 91成人看片片| 日本伦理一区二区| 欧美性三三影院| 91精品国模一区二区三区| 欧美精品久久久久久久多人混战| 91精品欧美久久久久久动漫| 555www色欧美视频| 欧美精品一区二区高清在线观看| 精品毛片乱码1区2区3区| 久久婷婷一区二区三区| 中文字幕欧美激情一区| 国产精品的网站| 亚洲一区二区黄色| 日韩不卡免费视频| 国产精品自在欧美一区| 成人久久视频在线观看| 欧美性大战久久| 精品日韩一区二区三区免费视频| 久久精品日产第一区二区三区高清版| 亚洲国产精品精华液2区45| 国产精品国产成人国产三级| 伊人开心综合网| 免费的成人av| 成人国产视频在线观看| 欧美专区亚洲专区| 精品国精品自拍自在线| 国产精品国产三级国产普通话三级 | 色婷婷激情久久| 欧美精品丝袜久久久中文字幕| 精品国产亚洲在线| 亚洲日本va午夜在线影院| 日韩精品国产精品| 国产成人免费av在线| 欧美日韩激情一区二区三区| 精品国产1区二区| 亚洲另类色综合网站| 免费精品视频在线| jizz一区二区| 日韩欧美中文字幕精品| 国产精品国产三级国产有无不卡 | 捆绑调教美女网站视频一区| www.66久久| wwwwxxxxx欧美| 亚洲国产欧美日韩另类综合| 国产91色综合久久免费分享| 欧美日韩综合一区| 国产精品美女www爽爽爽| 日韩av一二三| 欧美性色综合网| 国产精品天干天干在线综合| 日本aⅴ免费视频一区二区三区 | 国产91在线观看丝袜| 91精品视频网| 亚洲午夜三级在线| 99视频精品免费视频| 久久综合久色欧美综合狠狠| 亚洲动漫第一页| 99精品偷自拍| 日本一区二区三区在线观看| 日本aⅴ免费视频一区二区三区| 91看片淫黄大片一级在线观看| 久久这里只精品最新地址| 亚洲gay无套男同| 色婷婷av一区| 亚洲另类在线视频| www.亚洲精品| 欧美国产禁国产网站cc| 国产一区二区主播在线| 欧美成人精品福利| 麻豆成人av在线| 欧美群妇大交群的观看方式| 亚洲永久精品国产| 欧美在线观看一区二区| 亚洲视频一区二区免费在线观看| 丰满少妇在线播放bd日韩电影| 久久久精品影视| 国产精品一区二区在线看| 精品国产3级a| 国产精品99久久久久久久女警| 欧美va在线播放| 久久国产精品区| 精品成人一区二区三区| 国模娜娜一区二区三区| 国产日韩精品一区二区三区在线| 精品一区二区在线免费观看|