📄 resourcesymbolbuffer.h
字号:
#if !defined(__ResourceSymbolBuffer_H__)
#define __ResourceSymbolBuffer_H__
/************************************************************************
*
* Resource ID Organiser Utility Library
*
* (c) Copyright 2000 by Andy Metcalfe (andy.metcalfe@lineone.net)
* All rights reserved.
*
************************************************************************
*
* Filename : ResourceSymbolBuffer.h
*
* Description : CResourceSymbolBuffer - string buffer class for parsing
* manipulating and writing a resource symbol 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/ResourceSymbolBuffer.h $
* $Revision: 11 $
* $Date: 22/06/01 9:42 $
* $Author: Andy $
*
* $History: ResourceSymbolBuffer.h $
*
* ***************** Version 11 *****************
* User: Andy Date: 22/06/01 Time: 9:42
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Made class declaration "Rose friendly"
*
* ***************** Version 10 *****************
* User: Andy Date: 4/05/01 Time: 22:34
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Renumber() no longer takes the "editable symbol" base value as a
* parameter (it was never used anyway)
*
* ***************** Version 9 *****************
* User: Andy Date: 23/04/01 Time: 21:17
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Consolidated Renumber() methods
* 2. Speeded up symbol loading
*
* ***************** Version 8 *****************
* User: Andy Date: 21/04/01 Time: 7:29
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added new exported methods
*
* ***************** Version 7 *****************
* User: Andy Date: 2/04/01 Time: 17:32
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Check for name conflicts as well as value conflicts
* 2. Added IsUnique(Name/Value) methods
* 3. Added GetUnusedName() metho
*
* ***************** Version 6 *****************
* User: Andy Date: 27/03/01 Time: 15:39
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Added the capability to check resource symbol names for conflicts
* 2. Removed unused (and stubbed) Lookup() methods
*
* ***************** Version 5 *****************
* User: Andy Date: 2/03/01 Time: 16:43
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Added a CResourceSymbolValuesMap object to keep track of symbol
* values
* 2. Removed CResourceSymbolBuffer::EditReservedSymbols() [this is now
* the responsibility of CResOrgSymbolsDoc]
*
* ***************** Version 4 *****************
* User: Andy Date: 19/02/01 Time: 8:30
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added better tracking of values (alongside the existing method for
* now..)
*
* ***************** Version 3 *****************
* User: Andy Date: 17/02/01 Time: 6:54
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Added CResourceSymbolBuffer::GetDisplayedStatus() and GetSymbols()
* 2. Added support for read only symbols (the values of which saved in
* hexadecimal)
*
* ***************** Version 2 *****************
* User: Andy Date: 29/11/00 Time: 18:38
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added file banners
*
* $Nokeywords: $
*
************************************************************************/
// ResourceSymbolBuffer.h : interface of the CResourceSymbolBuffer class
//
/////////////////////////////////////////////////////////////////////////////
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// ResourceSymbolBuffer.h : header file
//
#include "ResourceSymbolList.h"
#include "ResourceSymbolNamesMap.h"
#include "ResourceSymbolValuesMap.h"
class CResourceSymbol;
struct RESORGUTILS_EXT_CLASS CResourceSymbolCounts
{
CResourceSymbolCounts(void)
{
m_nControls = 0;
m_nResources = 0;
m_nCommands = 0;
}
int m_nControls;
int m_nResources;
int m_nCommands;
};
/////////////////////////////////////////////////////////////////////////////
// CResourceSymbolBuffer class
#define CResourceSymbolBuffer_BASE CNGTextBuffer
class RESORGUTILS_EXT_CLASS CResourceSymbolBuffer : public CNGTextBuffer
{
DECLARE_DYNCREATE(CResourceSymbolBuffer)
public:
CResourceSymbolBuffer(void);
virtual ~CResourceSymbolBuffer(void);
// Attributes
public:
CString m_sResourceFileName;
int m_nConflicts; // How many symbols with conflicting values
BOOL m_bModified;
public:
BOOL m_b3dControls;
UINT m_uNextResourceValue;
UINT m_uNextControlValue;
UINT m_uNextSymedValue;
UINT m_uNextCommandValue;
protected:
// The main list of symbols
CResourceSymbolList m_listSymbols;
// Used to keep track of how many symbols are using a given name/value
CResourceSymbolNamesMap m_mapNames;
CResourceSymbolValuesMap m_mapValues;
// Operations
public:
CString GetResourceFileName(void) const
{ return m_sResourceFileName; }
BOOL Read(CArchive& ar);
BOOL Write(CArchive& ar);
int GetSymbols(CResourceSymbolList& rlistSymbols) const;
int GetSymbols( const CString& sName,
CResourceSymbolList& rlistSymbols) const;
int GetSymbols( UINT uValue,
CResourceSymbolList& rlistSymbols) const;
CResourceSymbol* Add( const CString& sSymbolName,
UINT uSymbolValue,
int nLineNo,
BOOL bUpdateMetrics = TRUE);
BOOL Set( CResourceSymbol* pSymbol,
const CString& sName,
UINT uValue,
BOOL bReadOnly = FALSE);
BOOL SetModifiedFlag(BOOL bModified);
BOOL IsModified(void) const
{ return m_bModified; }
BOOL Renumber( CResourceSymbolList* plistSymbols,
UINT uBaseResource,
UINT uBaseCommand,
UINT uBaseControl,
BOOL bSortByName = TRUE);
BOOL Renumber( UINT uBaseResource,
UINT uBaseCommand,
UINT uBaseControl,
BOOL bSortByName = TRUE);
BOOL CalculateBaseValues(UINT& ruBaseResource,
UINT& ruBaseCommand) const;
BOOL UpdateNextSymbolValues(void);
BOOL Add( CResourceSymbol* pSymbol,
BOOL bUpdateMetrics = TRUE);
BOOL Remove(CResourceSymbol* pSymbol,
BOOL bUpdateMetrics = TRUE);
void RemoveAll(void);
POSITION GetFirstSymbolPosition(void) const
{ return m_listSymbols.GetHeadPosition(); }
CResourceSymbol* GetNextSymbol(POSITION& rPos) const
{ return m_listSymbols.GetNext(rPos); }
int GetSymbolCount(void) const
{ return m_listSymbols.GetCount(); }
int GetSymbolCount(CResourceSymbolCounts& rInfo) const;
void SortByName(void)
{ m_listSymbols.SortByName(); }
void SortByValue(void)
{ m_listSymbols.SortByValue(); }
CString GetDisplayedStatus(CResourceSymbol* pSymbol) const;
// Methods for dealing with Conflicting symbols
int GetConflicts(CResourceSymbolList& rlistConflicts) const;
int GetConflicts( CResourceSymbol* pSymbol,
CResourceSymbolList& rlistConflicts) const;
int GetConflictCount(void) const
{ return m_nConflicts; }
BOOL IsUnique(const CString& sName) const;
BOOL IsUnique(UINT uValue) const;
BOOL IsInUse(const CString& sName) const;
BOOL IsInUse(UINT uValue) const;
CString GetUnusedName(int eType) const;
UINT GetNextFreeValue(UINT uValue) const;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CResourceSymbolBuffer)
public:
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
virtual BOOL Parse(const CString& rsLine);
// Implementation
protected:
void CountConflicts(void);
// File read implementation
CString GetToken(CString& rsLine);
BOOL IsComment(const CString& sToken) const;
BOOL IsDefine(const CString& sToken) const;
BOOL IsInteger(const CString& sToken) const;
// File write implementation
void Add(CString sText);
void AddComment(const CString& sComment);
void AddNewline(void);
BOOL Build(void);
BOOL AddSymbols(void);
CString FormatHexSymbolDefine( const CString& sName,
UINT uValue);
CString FormatSymbolDefine( const CString& sName,
UINT uValue);
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(__ResourceSymbolBuffer_H__)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -