⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 queue.cpp

📁 VC—网络与通信
💻 CPP
字号:
// Queue.cpp: implementation of the Queue class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MirrorGuide.h"
#include "Queue.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Queue::Queue()
{
	pQueue = NULL;
	putIndex = getIndex = 0;

}

Queue::~Queue()
{
	if ( pQueue != NULL )
		_rmtmp ();
}


BOOL Queue::IsEmpty()
{
	if ( pQueue == NULL || getIndex == putIndex )
		return TRUE;
	return FALSE;
}

BOOL Queue::InQueue ( CString string )
{
	if ( pQueue == NULL )
		if ( (pQueue = tmpfile()) == NULL )
		{
			AfxMessageBox ( "Please Email to default@etang.com, error occurs!", NULL, MB_OK );
			exit ( 0 );
		}

	fseek ( pQueue, 0, 2 );
	fputs ( string, pQueue );
	fputs ( "\r\n", pQueue );
	fflush ( pQueue );
	putIndex ++;
	return TRUE;
}

BOOL Queue::GetHead ( CString &string )
{
	if ( pQueue != NULL && !IsEmpty() )
	{
		rewind ( pQueue );
		char buf[1024];
		for ( int i = 0; i <= getIndex; i ++ )
			fgets ( buf, 1024, pQueue );
		getIndex ++;
		string.Format ( "%s", buf );
		string.Delete ( string.GetLength() - 2, 2 );
		return TRUE;
	}
	return FALSE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -