Click here to Skip to main content
15,886,362 members
Articles / Desktop Programming / MFC

The alxBase classes for work with DBF files

Rate me:
Please Sign up or sign in to vote.
5.00/5 (22 votes)
5 Nov 20021 min read 361.6K   3.8K   57  
The alxBase classes for work with dbf files.
/////////////////////////////////////////////////////////////////////////////
/*
�����:              �������� �.�.
����������:         alxsoft@gazinter.net
*/
/////////////////////////////////////////////////////////////////////////////

#if !defined(ALX_DBFEXEPTION_H__INCLUDED_)
#define ALX_DBFEXEPTION_H__INCLUDED_


// Extended error codes
#define NO_ALX_DBF_ERROR                        0
#define ALX_DBF_ERROR_MIN                       3000
#define ALX_DBF_ERROR                           ALX_DBF_ERROR_MIN
#define ALX_DBF_ERROR_DBFILE_CREATE		        ALX_DBF_ERROR+1
#define ALX_DBF_ERROR_DBFILE_OPEN		        ALX_DBF_ERROR+2
#define ALX_DBF_ERROR_DBFILE_MEMORYLOAD			ALX_DBF_ERROR+3
#define ALX_DBF_ERROR_DBFHEADER_READ			ALX_DBF_ERROR+4
#define ALX_DBF_ERROR_DBFHEADER_WRITE			ALX_DBF_ERROR+5
#define ALX_DBF_ERROR_NOT_TABLE					ALX_DBF_ERROR+6
#define ALX_DBF_ERROR_NOT_FIELDS				ALX_DBF_ERROR+7
#define ALX_DBF_ERROR_FILE_SIZE					ALX_DBF_ERROR+8
#define ALX_DBF_ERROR_FIELDS_READ				ALX_DBF_ERROR+9
#define ALX_DBF_ERROR_MEMO_OPEN					ALX_DBF_ERROR+10
#define ALX_DBF_ERROR_MEMO_HEAD_READ			ALX_DBF_ERROR+11
#define ALX_DBF_ERROR_MEMO_BLOCK_SIZE			ALX_DBF_ERROR+12
#define ALX_DBF_ERROR_MEMO_FIELD_READ			ALX_DBF_ERROR+13
#define ALX_DBF_ERROR_MEMO_FIELD_WRITE			ALX_DBF_ERROR+14
#define ALX_DBF_ERROR_MEMO_RECORD_READ			ALX_DBF_ERROR+15
#define ALX_DBF_ERROR_MEMO_RECORD_WRITE			ALX_DBF_ERROR+16
#define ALX_DBF_ERROR_RECORD_OUTOFRANGE			ALX_DBF_ERROR+17
#define ALX_DBF_ERROR_RECORD_READ				ALX_DBF_ERROR+18
#define ALX_DBF_ERROR_RECORD_WRITE				ALX_DBF_ERROR+19
#define ALX_DBF_ERROR_MAX                       ALX_DBF_ERROR+19

// Logging helpers

#ifdef _DEBUG
BOOL ALXAssertFailedLine(LPCSTR lpszDBFCall, LPCSTR lpszFile, int nLine);
#define DBF_CHECK_ERROR(f, err) \
	do \
	{ \
	if(!(f)) \
	 if(ALXAssertFailedLine(#f,THIS_FILE, __LINE__)) \
		{ AfxDebugBreak(); }\
	 else ALXThrowDBFException(err);\
	} \
	while (0)

#else
#define DBF_CHECK_ERROR(f, err) \
	if(!(f)) \
		ALXThrowDBFException(err);

#endif // _DEBUG
////////////////////////////////////////////////////////////////////////
// Info structures

struct CDBFErrorInfo
{
// Attributes
	long	m_lErrorCode;		// ��� ������
	CString	m_strDescription;	// ���������

#ifdef _DEBUG
	virtual void Dump(CDumpContext& dc) const;
#endif
};

////////////////////////////////////////////////////////////////////////
// CDBFException - DBF error trapping mechanism
class ALX_EXT_CLASS CDBFException : public CException
{
	DECLARE_DYNAMIC(CDBFException)

// Constructors
public:
	CDBFException();

// Attributes
public:
	CDBFErrorInfo* m_pErrorInfo;

	long m_nALXDBFError;     // DBF class extended error code

// Operations
public:
	void GetErrorInfo(/*int nIndex*/);

// Implementation
public:
	virtual ~CDBFException();
	virtual BOOL GetErrorMessage(LPTSTR lpszError, UINT nMaxError,
		PUINT pnHelpContext = NULL);

protected:
	void FillErrorInfo();
};

void AFXAPI ALXThrowDBFException(long nALXDBFError = NO_ALX_DBF_ERROR);

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(ALX_DBFEXEPTION_H__INCLUDED_)

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
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).

Comments and Discussions