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

📄 resourcesymbollist.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    : ResourceSymbolList.cpp
 *
 *  Description : CResourceSymbolList - implementation class used
 *                by CResourceSymbolManager
 *
 *  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/ResourceSymbolList.cpp $
 *   $Revision: 9 $
 *       $Date: 15/04/03 20:34 $
 *     $Author: Anna $
 *
 *    $History: ResourceSymbolList.cpp $
 * 
 * *****************  Version 9  *****************
 * User: Anna         Date: 15/04/03   Time: 20:34
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * 1.  Removed unnecessary file guards (#pragma once works well enough)
 * 2.  Updated file banners
 * 
 * *****************  Version 8  *****************
 * User: Anna         Date: 25/11/02   Time: 15:19
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Changed website address in banner
 * 
 * *****************  Version 7  *****************
 * User: Anna         Date: 22/10/02   Time: 13:24
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Changed name/mail address (at last!)
 * 
 * *****************  Version 6  *****************
 * 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 5  *****************
 * User: Andy         Date: 27/05/02   Time: 13:41
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Updated file banners
 * 
 * *****************  Version 4  *****************
 * User: Andy         Date: 8/07/01    Time: 8:36
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * ResourceSymbolList::CompareNames() now handles symbols with trailing
 * numbers intelligently
 * 
 * *****************  Version 3  *****************
 * User: Andy         Date: 19/02/01   Time: 8:28
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Added Remove()  and operator=()
 * 
 * *****************  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 "ResourceSymbol.h"

#include "ResourceSymbolList.h"


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


static int FindTrailingNumber(const CString& s)
{
	int nPos = -1;

	int nLen = s.GetLength();

	for (int n = nLen - 1; n >= 0; n--)
	{
		if (!::_istdigit(s[n]) )
		{
			nPos = n + 1;
			break;
		}
	}
	if (nPos >= nLen)
	{
		nPos = -1;		// Not found
	}
	return nPos;
}


static int StrCmpEx(const CString& sFirst, const CString& sSecond)
{
	int nFirst	= ::FindTrailingNumber(sFirst);
	int nSecond	= ::FindTrailingNumber(sSecond);

	if ( (nFirst >= 0) || (nSecond >= 0) )
	{
		CString sFirstPrefix	= (nFirst >= 0) ? sFirst.Left(nFirst) : sFirst;
		CString sSecondPrefix	= (nSecond >= 0) ? sSecond.Left(nSecond) : sSecond;

		if (sFirstPrefix.CompareNoCase(sSecondPrefix) == 0)
		{
			int nFirstSuffix	= (nFirst >= 0) ? _ttoi(sFirst.Mid(nFirst)) : 0;
			int nSecondSuffix	= (nSecond >= 0) ? _ttoi(sSecond.Mid(nSecond)) : 0;

			if (nFirstSuffix > nSecondSuffix)
			{
				return 1;
			}
			else if (nFirstSuffix < nSecondSuffix)
			{
				return -1;
			}
		}
	}
	return sFirst.CompareNoCase(sSecond);
}


/////////////////////////////////////////////////////////////////////////////
// CResourceSymbolList

CResourceSymbolList::CResourceSymbolList(void)
{
}

CResourceSymbolList::~CResourceSymbolList(void)
{
}


/////////////////////////////////////////////////////////////////////////////
// CResourceSymbolList operations

void CResourceSymbolList::SortByName(void)
{
	Sort(CResourceSymbolList::CompareNames);
}


void CResourceSymbolList::SortByValue(void)
{
	Sort(CResourceSymbolList::CompareValues);
}


BOOL CResourceSymbolList::Remove(CResourceSymbol* pSymbol)
{
	if (pSymbol != NULL)
	{
		POSITION pos = Find(pSymbol);
		if (NULL != pos)
		{
			RemoveAt(pos);

			return TRUE;
		}
	}
	return FALSE;
}


void CResourceSymbolList::operator=(const CResourceSymbolList& src)
{
	RemoveAll();

	AddTail( (CResourceSymbolList*)&src);
}


/////////////////////////////////////////////////////////////////////////////
// CResourceSymbolList implementation

int CResourceSymbolList::CompareNames(CResourceSymbol* pFirst, CResourceSymbol* pSecond)
{
	return ::StrCmpEx(pFirst->GetName(), pSecond->GetName());
}


int CResourceSymbolList::CompareValues(CResourceSymbol* pFirst, CResourceSymbol* pSecond)
{
	if (pFirst->GetValue() > pSecond->GetValue() )
	{
		return 1;
	}
	else if (pFirst->GetValue() < pSecond->GetValue() )
	{
		return -1;
	}
	return 0;
}

⌨️ 快捷键说明

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