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

📄 resourcefilebuffer.cpp

📁 一个vc中管理资源文件ID的插件
💻 CPP
字号:
/************************************************************************
 *
 *                 Resource ID Organiser Utility Library
 *
 *       (c) Copyright 2000 by Andy Metcalfe (andy.metcalfe@lineone.net)
 *                         All rights reserved.
 *
 ************************************************************************
 *                                                                       
 *  Filename    : ResourceFileBuffer.cpp
 *
 *  Description : CResourceFileBuffer - string buffer class for parsing
 *                manipulating and writing a resource file
 *                
 *  Compiler    : Microsoft Visual C++ 6.0, Service Pack 3 or 4
 *                                                                       
 *  Target                                                               
 *  Environment : Windows 98/NT
 *
 *  NOTE:
 *
 *    This software is provided "as is" free for personal use. All
 *    title and copyrights in and to the software, including but not
 *    limited to any images, text, etc. incorporated into it, are
 *    owned by Andy Metcalfe, except where acknowledged otherwise.
 *
 *    Your may freely to use this code in your own products, PROVIDED
 *    this notice is not removed or modified.
 *
 *
 *    Visit http://www.resorg.co.uk for latest updates
 *
 ************************************************************************
 *
 *   MODIFICATION HISTORY:
 *
 *           This is a controlled document. See project configuration
 *           control tool for latest version and full version history.
 *
 *    $Archive: /Projects/AddIns/ResOrg/ResOrgUtils/ResourceFileBuffer.cpp $
 *   $Revision: 2 $
 *       $Date: 29/11/00 18:38 $
 *     $Author: Andy $
 *
 *    $History: ResourceFileBuffer.cpp $
 * 
 * *****************  Version 2  *****************
 * User: Andy         Date: 29/11/00   Time: 18:38
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 *  Added file banners
 *
 * $Nokeywords: $
 *
 ************************************************************************/

// ResourceFileBuffer.cpp : implementation file
//

#include "StdAfx.h"
#include "ResOrgUtils_Priv.h"

#include "ResourceFileBuffer.h"


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



/////////////////////////////////////////////////////////////////////////////
// CResourceFileBuffer

#define BUFFER_GROWBY 100			// Grow file buffer by 100 lines at a time

#define	BUF_SIZE	1024

#define WHITE_SPACE	_T(" \t")


IMPLEMENT_DYNCREATE(CResourceFileBuffer, CResourceFileBuffer_BASE)

CResourceFileBuffer::CResourceFileBuffer(void)
{
	m_sSymbolFileName		= _T("");
	m_bModified				= FALSE;
}


CResourceFileBuffer::~CResourceFileBuffer(void)
{
}


/////////////////////////////////////////////////////////////////////////////
// CResourceFileBuffer message handlers

void CResourceFileBuffer::Serialize(CArchive& ar) 
{
	ASSERT_VALID(this);
	
	CResourceFileBuffer_BASE::Serialize(ar);
}


/////////////////////////////////////////////////////////////////////////////
// Virtual Overrides


/////////////////////////////////////////////////////////////////////////////
// Operations


/////////////////////////////////////////////////////////////////////////////
// File Read Implementation


/******************************************************************************
 *	Read from an archive
 *
 ******************************************************************************/

BOOL CResourceFileBuffer::Read(CArchive& ar)
{
	m_sSymbolFileName = _T("");

	return CResourceFileBuffer_BASE::Read(ar);
}


/******************************************************************************
 *	Parse the given line
 *
 ******************************************************************************/

BOOL CResourceFileBuffer::Parse(const CString& rsLine)
{
	if (!rsLine.IsEmpty())
	{
		CString sLine = rsLine;
		CString sToken = GetToken(sLine);
		if (m_sSymbolFileName.IsEmpty() && IsInclude(sToken))
		{
			CString sSymbolFileName = ::Between(sLine, _T("\""), _T("\"") );
//			sSymbolFileName.TrimLeft();
//			sSymbolFileName.TrimRight();

			if (!sSymbolFileName.IsEmpty())
			{
				m_sSymbolFileName = sSymbolFileName;
			}
		}
	}
	return TRUE;
}


BOOL CResourceFileBuffer::IsComment(const CString& rsToken) const
{
	if (rsToken.Left(2) == _T("//"))
	{
		return TRUE;
	}
	return FALSE;
}


BOOL CResourceFileBuffer::IsInclude(const CString& rsToken) const
{
	if (rsToken.Find( _T("#include") ) == 0)
	{
		return TRUE;
	}
	return FALSE;
}


BOOL CResourceFileBuffer::IsInteger(const CString& rsToken) const
{
	CString s = rsToken.SpanExcluding( _T("0123456789") );

	return s.IsEmpty();
}


CString CResourceFileBuffer::GetToken(CString& rsLine)
{
	rsLine.TrimLeft(WHITE_SPACE);

	CString sToken;
	int nPos = rsLine.FindOneOf(WHITE_SPACE);
	if (nPos > 0)
	{
		sToken = rsLine.Left(nPos);
		rsLine = rsLine.Mid(nPos);
	}
	else
	{
		sToken = rsLine;
		rsLine = _T("");
	}
	sToken.TrimLeft(WHITE_SPACE);
	sToken.TrimRight(WHITE_SPACE);

	return sToken;
}


/////////////////////////////////////////////////////////////////////////////
// File Write Implementation

/******************************************************************************
 *	Write the buffer to an archive
 *
 ******************************************************************************/

BOOL CResourceFileBuffer::Write(CArchive& ar)
{
	return CResourceFileBuffer_BASE::Write(ar);
}

⌨️ 快捷键说明

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