Click here to Skip to main content
15,897,518 members
Articles / Database Development / SQL Server

A scripted SQL query generation framework with IDE: SQLpp (v1.4)

Rate me:
Please Sign up or sign in to vote.
4.98/5 (47 votes)
12 Sep 200311 min read 416.5K   5.4K   133  
A helper framework for generation of SQL queries in C++ and Lua
// CallStack.cpp: implementation of the CCallStack class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ide2.h"
#include "CallStack.h"

#include "ScintillaView.h"
#include "MainFrame.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCallStack::CCallStack()
{

}

CCallStack::~CCallStack()
{

}

BOOL CCallStack::Create(CWnd *pParentWnd, UINT nID, LPCTSTR lpszWindowName, CSize sizeDefault, DWORD dwStyle)
{
	BOOL bRet = CCJTabCtrlBar::Create(pParentWnd, nID, lpszWindowName, sizeDefault, dwStyle);
	if ( !bRet )
		return FALSE;

	AddView(_T("Call Stack"),    RUNTIME_CLASS(CScintillaView));

	CLuaEditor* pEditor = ((CScintillaView*)GetView(0))->GetEditor();
	pEditor->SetCallStackMargins();

	Clear();
	return TRUE;
}

int CCallStack::OnSci(CScintillaView* pView, SCNotification* pNotify)
{
	CLuaEditor* pEditor = ((CScintillaView*)GetView(0))->GetEditor();

	CPoint pt;
	int nLine;
	CString strLine;
	switch (pNotify->nmhdr.code)
	{
		case SCN_DOUBLECLICK:
			GetCursorPos(&pt);
			pEditor->ScreenToClient(&pt);
			nLine = pEditor->LineFromPoint(pt);
			GotoStackTraceLevel(nLine-1);
		break;
	};

	return 0;
}

void CCallStack::Clear()
{
	((CScintillaView*)GetView(0))->Clear();

	m_nCurrentLevel = -1;
	m_lines.RemoveAll();
	m_files.RemoveAll();
}

void CCallStack::Add(const char *szDesc, const char *szFile, int nLine)
{
	((CScintillaView*)GetView(0))->Write(CString(szDesc)+"\n");

	m_files.Add(szFile);
	m_lines.Add(nLine);
}

void CCallStack::GotoStackTraceLevel(int nLevel)
{
	if ( nLevel<0 || nLevel>=m_files.GetSize() )
		return;

	m_nCurrentLevel = nLevel;

	CLuaEditor* pEditor = ((CScintillaView*)GetView(0))->GetEditor();
	pEditor->SetStackTraceLevel(nLevel);

	((CMainFrame*)AfxGetMainWnd())->GotoFileLine(m_files[nLevel], m_lines[nLevel]);	
	((CMainFrame*)AfxGetMainWnd())->GetDebugger()->StackLevelChanged();
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Engineer
United States United States
Jonathan de Halleux is Civil Engineer in Applied Mathematics. He finished his PhD in 2004 in the rainy country of Belgium. After 2 years in the Common Language Runtime (i.e. .net), he is now working at Microsoft Research on Pex (http://research.microsoft.com/pex).

Comments and Discussions