Click here to Skip to main content
Click here to Skip to main content
Articles » Database » Database » General » Downloads
 
Add your own
alternative version

The alxBase classes for work with DBF files

, 5 Nov 2002
The alxBase classes for work with dbf files.
alxbasea2.zip
alxBASE
alxBASE.dsp
alxBASE.dsw
alxBaseDLL.dsp
DLL
INCLUDE
res
nodrop.cur
Lib
Samples
DBFView
DBFViewApp.clw
DBFViewApp.dep
DBFViewApp.dsp
DBFViewApp.dsw
Release
DBFView.exe
res
bitmap1.bmp
DBFViewApp.ico
DBFViewDoc.ico
Toolbar.bmp
SRC
alxbasea3.zip
alxBASE.dep
alxBASE.dsp
alxBASE.dsw
alxBASE.mak
alxBASE.suo
alxBaseDLL.dsp
l.rus
nodrop.cur
DBFViewApp.clw
DBFViewApp.dep
DBFViewApp.dsp
DBFViewApp.dsw
RCa00472
DBFView.exe
bitmap1.bmp
DBFViewApp.ico
DBFViewDoc.ico
Toolbar.bmp
/////////////////////////////////////////////////////////////////////////////
//
// ALXParserException.cpp : implementation of the ALXParserExeption.h file
//
/////////////////////////////////////////////////////////////////////////////
/*
 Copyright� 2002, Alexey Dolgachov
 mail:	alxsoft@gazinter.net	
 web:	http://www.alxsoft.narod.ru
*/
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ALXParserException.h"

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

//////////////////////////////////////////////////////////////////////////
// Info structure diagnostics

#ifdef _DEBUG
void CALXParserErrorInfo::Dump(CDumpContext& dc) const
{
	dc << "a CALXParserErrorInfo at " << (void*)this;
	dc << "\nm_nErrorCode = " << m_nErrorCode;
	dc << "\nm_strDescription = " << m_strDescription;
	dc << "\n";
}
#endif // _DEBUG

//////////////////////////////////////////////////////////////////////////
// CALXParserException
IMPLEMENT_DYNAMIC(CALXParserException, CException)

CALXParserException::CALXParserException(CALXParserErrorInfoItem* pErrorInfoItem)
{
	m_nErrorCount = 0;

	if(pErrorInfoItem != NULL)
	{
		m_pErrorInfoItem = pErrorInfoItem;
		m_nErrorCount++;
		// find first error
		while(m_pErrorInfoItem->m_pstPrevErrorItem != NULL)
		{
			m_pErrorInfoItem = m_pErrorInfoItem->m_pstPrevErrorItem;
			m_nErrorCount++;
		}

		m_pErrorInfo = &m_pErrorInfoItem->m_stErrorInfo;
	}
	else
		m_pErrorInfo = NULL;

	m_pErrorInfoItem = pErrorInfoItem;
}

CALXParserException::~CALXParserException()
{
	while(m_pErrorInfoItem != NULL)
	{
		CALXParserErrorInfoItem* pDelErrorInfoItem = m_pErrorInfoItem;
		m_pErrorInfoItem = m_pErrorInfoItem->m_pstPrevErrorItem;
		delete pDelErrorInfoItem;
	}

	m_nErrorCount = 0;
	m_pErrorInfo = NULL;
}

// Operations
int CALXParserException::GetErrorCount()
{
	return m_nErrorCount;
}

void CALXParserException::GetErrorInfo(int nIndex /* = 0*/)
{
	FillErrorInfo(nIndex);
}

// Implementation
void CALXParserException::FillErrorInfo(int nIndex)
{
	ASSERT(nIndex >= 0 && nIndex < m_nErrorCount);

	int nCurIndex = m_nErrorCount - 1;
	CALXParserErrorInfoItem* pErrorInfoItem = m_pErrorInfoItem;

	while(nCurIndex != nIndex &&  pErrorInfoItem != NULL)
	{
		pErrorInfoItem = pErrorInfoItem->m_pstPrevErrorItem;
		nCurIndex--;
	}

	if(pErrorInfoItem != NULL)
		m_pErrorInfo = &pErrorInfoItem->m_stErrorInfo;
}

BOOL CALXParserException::GetErrorMessage(LPTSTR lpszError, UINT nMaxError,
	PUINT pnHelpContext)
{
	ASSERT(lpszError != NULL && AfxIsValidString(lpszError, nMaxError));

	if (pnHelpContext != NULL)
		*pnHelpContext = 0;

	if(m_pErrorInfo == NULL)
		return FALSE;

	lstrcpyn(lpszError, m_pErrorInfo->m_strDescription, nMaxError-1);
	lpszError[nMaxError-1] = '\0';

	return TRUE;
}

void AFXAPI ALXThrowFunOperException(UINT nIDS, ...)
{
	CString strError;
	if(strError.LoadString(nIDS))
	{
		va_list argList;
		va_start(argList, nIDS);
		strError.FormatV(CString(strError), argList);
		va_end(argList);
	}
	else
	{
		strError.Format("00000000%X",nIDS);
		strError = "Error number 0x" + strError.Right(8) + ".";
	}

	TRACE(strError+"\n");

	CALXParserErrorInfoItem* pErrorItem = new CALXParserErrorInfoItem; 

	pErrorItem->m_stErrorInfo.m_nErrorCode = nIDS;
	pErrorItem->m_stErrorInfo.m_strDescription = strError;
	pErrorItem->m_pstPrevErrorItem = NULL;

	CALXParserException* pException = new CALXParserException(pErrorItem);

	THROW(pException);
}

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

Share

About the Author

Alexey
Web Developer
Russian Federation Russian Federation
Year of birth - 1974.
Eeducation - was ended by Kaliningrad State University in 1997.
Now I work as the engineer-programmer in Kaliningrad (RUSSIA).

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 6 Nov 2002
Article Copyright 2002 by Alexey
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid