You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.0 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//////////////////////////////////////////////////////////////////////////////
//文件 GlobalMark.h
//主要功能:
//
//程序编写: 2005-12-07
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include <afx.h>
#include "MapStringToPtrNoCase.h"
#include <memory>
//全局性的符号管理
class AFX_EXT_CLASS CGlobalMark
{
private:
CMapStringToPtrNoCase* m_pBakMark;
std::shared_ptr<CArray<void*,void*>> m_arBakMark;
// 注意m_arBakMark 不要在构造函数里面 new在构造函数里面 new 的话,把它放成 thread_local 成员会有问题
std::shared_ptr<CArray<void*, void*>> GetArBakMark();
public:
CGlobalMark(void);
virtual ~CGlobalMark(void);
virtual void Serialize(CArchive& ar, short ver);
void WriteMark(CFile &fw, const short& ver);
void WriteMarkDML(CFile &fw, const short& ver, int nBaseTabNum);
void WriteMarkPCG(CFile &fw, const short& ver, int nBaseTabNum);
void SerializeMark_One(CArchive& ar, CString &key, void*& pDraw, short ver);
static void WriteMark_One(CFile &fw, void* pDraw, short ver);
void WriteMarkDML_One(CFile &fw, void* pDraw, const short& ver, int nBaseTabNum);
void WriteMarkPCG_One(CFile &fw, void* pDraw, const short& ver, int nBaseTabNum);
void SetMark(CMapStringToPtrNoCase* t);
void* GetMark(CString key);
void BackupMark(void);
void RestoreMark(void);
BOOL Lookup(LPCTSTR key, void*& rValue);
BOOL RemoveKey(LPCTSTR key);
void SetAt(LPCTSTR key, void* pNewValue);
int GetCount(void);
private:
CMapStringToPtrNoCase* m_pGlobalMark = nullptr;
};
extern thread_local CGlobalMark m_GlobalMark;
AFX_INLINE BOOL CGlobalMark::Lookup(LPCTSTR key, void*& rValue)
{
return m_pGlobalMark->Lookup(key,rValue);
}
AFX_INLINE BOOL CGlobalMark::RemoveKey(LPCTSTR key)
{
return m_pGlobalMark->RemoveKey(key);
}
AFX_INLINE void CGlobalMark::SetAt(LPCTSTR key, void* pNewValue)
{
m_pGlobalMark->SetAt(key,pNewValue);
}
AFX_INLINE int CGlobalMark::GetCount(void)
{
return (int)m_pGlobalMark->GetCount();
}
extern "C" AFX_EXT_API CGlobalMark * WINAPI AfxGetGlobalMark();