scope.cpp

来自「这是一个能够自动生成文档的程序」· C++ 代码 · 共 93 行

CPP
93
字号

#include "stdafx.h"

#include "Scope.h"

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

BEGIN_TEST_DUMP(CScope)
    TEST_DUMP(mCurrScope)
    TEST_DUMP(mCurrScopeName)
    TEST_DUMP(mEyeableScopes)
END_TEST_DUMP()


CScope::CScope()
{
    Init();
}

CScope::~CScope()
{
    Init();
}

NOTEST
void CScope::Init()
{
	POSITION pos = NULL;

	pos = mCurrScope.GetHeadPosition();
	while(pos != NULL)
		delete mCurrScope.GetNext(pos);
	mCurrScope.RemoveAll();

	pos = mEyeableScopes.GetHeadPosition();
	while(pos != NULL)
	    delete mEyeableScopes.GetNext(pos);
    mEyeableScopes.RemoveAll();

	mCurrScopeName = "";
}

void CScope::EnterScope(LPCTSTR iScope) 
{
	ASSERT(iScope != NULL);

	CString* pScope = new CString(iScope); 
	mCurrScope.AddTail(pScope);

    mCurrScopeName.Empty();
	POSITION pos = mCurrScope.GetHeadPosition();
	while(pos != NULL)
	{
		CString* pScope = mCurrScope.GetNext(pos);
		ASSERT(pScope != NULL);
		mCurrScopeName += *pScope;
		mCurrScopeName += "::";
	}

	TEST_TRACE(mCurrScopeName);
}

void CScope::ExitScope() 
{
	if(!mCurrScope.IsEmpty())
	{
	    delete mCurrScope.GetTail();
	    mCurrScope.RemoveTail();
    }

    if(mCurrScope.IsEmpty())
	{
		mCurrScopeName = "";
		return;
	}

    mCurrScopeName.Empty();
	POSITION pos = mCurrScope.GetHeadPosition();
	while(pos != NULL)
	{
		CString* pScope = mCurrScope.GetNext(pos);
		ASSERT(pScope != NULL);
		mCurrScopeName += *pScope;
		mCurrScopeName += "::";
	}

	TEST_TRACE(mCurrScopeName);
}

⌨️ 快捷键说明

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