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

📄 resourcefilebuffer.cpp

📁 ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - Manage and Renumber Resource Symbol IDs Introduction The
💻 CPP
字号:
/************************************************************************
 *
 *                 Resource ID Organiser Core Library
 *
 * (c) Copyright 2000-2003 by Anna-Jayne Metcalfe (resorg@annasplace.me.uk)
 *                         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 later
 *                Microsoft Visual C++ .NET 2002
 *                                                                       
 *  Target                                                               
 *  Environment : Windows 98/NT/2000/XP
 *
 *  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 Anna-Jayne 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.annasplace.me.uk/resorg 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/ResOrgCore/ResourceFileBuffer.cpp $
 *   $Revision: 7 $
 *       $Date: 15/04/03 20:36 $
 *     $Author: Anna $
 *
 *    $History: ResourceFileBuffer.cpp $
 * 
 * *****************  Version 7  *****************
 * User: Anna         Date: 15/04/03   Time: 20:36
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * 1.  Removed unnecessary file guards (#pragma once works well enough)
 * 2.  Updated file banners
 * 
 * *****************  Version 6  *****************
 * User: Anna         Date: 25/11/02   Time: 15:20
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Changed website address in banner
 * 
 * *****************  Version 5  *****************
 * User: Anna         Date: 22/10/02   Time: 13:24
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Changed name/mail address (at last!)
 * 
 * *****************  Version 4  *****************
 * User: Andy         Date: 7/06/02    Time: 17:04
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Renamed the ResOrgUtils module to ResOrgCore. Updated file banners
 * accordingly
 * 
 * *****************  Version 3  *****************
 * User: Andy         Date: 27/05/02   Time: 14:48
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Updated file banner
 * 
 * *****************  Version 2  *****************
 * User: Andy         Date: 29/11/00   Time: 18:38
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 *  Added file banners
 *
 * $Nokeywords: $
 *
 ************************************************************************/


#include "StdAfx.h"
#include "ResOrgCore_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 + -