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

📄 resourcesymbol.cpp

📁 ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - Manage and Renumber Resource Symbol IDs Introduction The
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/************************************************************************
 *
 *                 Resource ID Organiser Core Library
 *
 * (c) Copyright 2000-2004 by Anna-Jayne Metcalfe (resorg@annasplace.me.uk)
 *                         All rights reserved.
 *
 ************************************************************************
 *                                                                       
 *  Filename    : ResourceSymbol.cpp
 *
 *  Description : CResourceSymbol - class to represent a single resource symbol
 *                
 *  Compiler    : Microsoft Visual C++ 6.0, Service Pack 3 or later
 *                Microsoft Visual C++ .NET 2003
 *                                                                       
 *  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/ResourceSymbol.cpp $
 *   $Revision: 19 $
 *       $Date: 23/08/04 21:39 $
 *     $Author: Anna $
 *
 *    $History: ResourceSymbol.cpp $
 * 
 * *****************  Version 19  *****************
 * User: Anna         Date: 23/08/04   Time: 21:39
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Added support for SYM_TOOLBAR (IDT_xxx) and SYM_ACCELERATOR (IDK_xxx)
 * symbols
 * 
 * *****************  Version 18  *****************
 * User: Anna         Date: 11/07/04   Time: 16:06
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Improved code documentation
 * 
 * *****************  Version 17  *****************
 * User: Anna         Date: 15/04/03   Time: 20:36
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Corrected code documentation comments
 * 
 * *****************  Version 16  *****************
 * User: Anna         Date: 19/03/03   Time: 18:43
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Undid some blondeness in CResourceSymbol::SetModifiedFlag()
 * 
 * *****************  Version 15  *****************
 * User: Anna         Date: 3/03/03    Time: 20:10
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Moved XML code to its own class (CResOrgXmlWriter)
 * 
 * *****************  Version 14  *****************
 * User: Anna         Date: 27/02/03   Time: 13:38
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Write "uid" attriutes for symbols and files so the XSL stylesheet can
 * identify objects uniquely
 * 
 * *****************  Version 13  *****************
 * User: Anna         Date: 25/02/03   Time: 21:26
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * CResourceSymbol::AddConflict() now checks to ensure the symbol isn't
 * already listed before adding it
 * 
 * *****************  Version 12  *****************
 * User: Anna         Date: 19/02/03   Time: 19:20
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Started adding XML export and HTML reports
 * 
 * *****************  Version 11  *****************
 * User: Anna         Date: 15/02/03   Time: 20:52
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Changed big BOOLs into little bools
 * 
 * *****************  Version 10  *****************
 * User: Anna         Date: 3/12/02    Time: 20:18
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Added CResourceSymbol::m_nUserData
 * 
 * *****************  Version 9  *****************
 * User: Anna         Date: 25/11/02   Time: 15:20
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Changed website address in banner
 * 
 * *****************  Version 8  *****************
 * User: Anna         Date: 22/10/02   Time: 13:24
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Changed name/mail address (at last!)
 * 
 * *****************  Version 7  *****************
 * 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 6  *****************
 * User: Andy         Date: 27/05/02   Time: 17:10
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Revised the way conflicts are stored to remove a two-way code
 * dependency which caused big problems in Visual C++ 7.0
 * 
 * *****************  Version 5  *****************
 * User: Andy         Date: 12/27/01   Time: 10:48p
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Added "Original Value" attribute
 * 
 * *****************  Version 4  *****************
 * User: Andy         Date: 2/04/01    Time: 17:03
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * The default constructor now has optional parameters for the Name, Value
 * and Read-Only status of the symbol
 * 
 *****************  Version 3  *****************
 * User: Andy            Date: 27/03/01  Time:  15:37
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Added CResourceSymbol::IsValidName()
 *
 *****************  Version 2  *****************
 * User: Andy            Date: 17/02/01  Time:   6:49
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * 1.  Moved resource type identification to a separate class
 * 2.  Added SetReadOnly(), IsReadOnly() and GetConflicts()
 *
 ******************  Version 1  *****************
 * User: Andy            Date: 12/11/00  Time:  21:36
 * Created in $/Projects/AddIns/ResOrg/ResOrgUtils
 *
 * $Nokeywords: $
 *
 ************************************************************************/


#include "StdAfx.h"
#include "ResOrgCore_Priv.h"

#include "ResourceSymbol.h"


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



/////////////////////////////////////////////////////////////////////////////
// CResourceSymbol


IMPLEMENT_DYNCREATE(CResourceSymbol, CResourceSymbol_BASE)


/// CResourceSymbol constructor.
///
/// \param	sName		The name of the symbol.
/// \param	uValue		The value of the symbol.
/// \param	bReadOnly	true if the symbol should be read-only; false otherwise.
///						Read-only symbols are saved in hexadecimal, and the resource editor <b>hates</b> them, so be careful!
///
CResourceSymbol::CResourceSymbol(const CString& sName /*= _T("")*/,
								 UINT uValue /*= 0*/,
								 bool bReadOnly /*= false*/)
{
	m_sName				= sName;
	m_uValue			= uValue;
	m_uOriginalValue	= 0;
	m_sFileName			= _T("");
	m_nLineNo			= 0;

	m_bModified			= false;
	m_bReadOnly			= bReadOnly;

	m_nUserData			= 0;
}


CResourceSymbol::~CResourceSymbol(void)
{
}


/////////////////////////////////////////////////////////////////////////////
// Virtual Overrides
// (none)


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

/// Return the type of the symbol, in enumerated form
///
/// The following symbol types are available:
///
///		- SYM_RESOURCE (IDx_xxx)
///		- SYM_BITMAP (IDB_xxx)
///		- SYM_CONTROL (IDC_xxx)
///		- SYM_DIALOG (IDD_xxx)
///		- SYM_MENU (IDM_xxx)
///		- SYM_ICON (IDI_xxx)
///		- SYM_PROMPT (IDP_xxx)
///		- SYM_STRING (IDS_xxx)
///		- SYM_COMMAND (ID_xxx)
///		- SYM_TOOLBAR (IDT_xxx)
///		- SYM_ACCELERATOR (IDK_xxx)
///
/// \return				The enumerated type of the symbol
///
int CResourceSymbol::GetType(void) const
{
	return SymbolTypes.GetType(m_sName);
}


/// Return the type of the symbol, in string form.
///
/// This method is intended for display purposes and hence the names should
/// ideally be loaded from a string table entry.
///
/// \return				The type of the symbol, in string form.
///
CString CResourceSymbol::GetTypeName(void) const
{
	return SymbolTypes.GetTypeName( GetType() );
}


/// Determine whether the given symbol name is valid.
///
///	The following rules are applied in validating the name:
///
///		- The name must not be blank (obviously...)
///		- The first character must be alphabetic
///		- The remainder of the name must contain only alphanumeric characters
///		  or underscores.
///		- Leading and trailing spaces are \b not permitted.
///
/// \param				The name to be validated
/// \return				true if the symbol name is valid; false otherwise.
///
bool CResourceSymbol::IsValidName(const CString& sName)
{
	bool  bValid = false;

	if (!sName.IsEmpty())
	{
		if (::isalpha(sName[0]) )
		{
			for (int n = 0; n < sName.GetLength(); n++)
			{
				TCHAR ch = sName[n];
				if ( _T('_') == ch)
				{
					bValid = true;
					continue;		// Underscores are OK
				}
				if (::isalnum(ch) )
				{
					bValid = true;
					continue;
				}
				// If we get here, the symbol name isn't valid

⌨️ 快捷键说明

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