Click here to Skip to main content
15,896,207 members
Articles / Desktop Programming / MFC

The ALXGrid Control Library.

Rate me:
Please Sign up or sign in to vote.
5.00/5 (29 votes)
10 Nov 20021 min read 201.4K   5.5K   85  
The ALXGrid Control Library is a set of classes for management of data as a table.
/////////////////////////////////////////////////////////////////////////////
// WizUtil.cpp - Miscellaneous utility functions
// CG: This file was added by the AppWizard Tools component

#include "stdafx.h"
#include "ALXGridAw.h"
#include "WizUtil.h"

/////////////////////////////////////////////////////////////////////////////
// Miscellaneous utility functions

// These are generic macro-setting functions. They set macros or remove
// them from the dictionary.

void DefineMacro(LPCTSTR lpszKey, LPCTSTR lpszValue)
{
	ALXAppWz.m_Dictionary[lpszKey] = lpszValue;
}

void UndefMacro(LPCTSTR lpszKey)
{
	ALXAppWz.m_Dictionary.RemoveKey(lpszKey);
}

// These are more specific macro-setting functions. They set macros
// depending on the "type", and work correctly in BEGINLOOP/ENDLOOP
// blocks.

static void MakeKey(CString& strKey, int iItem)
{
	CString strOriginal = strKey;
	strKey.Format(_T("%s_%d"), (LPCTSTR) strKey, iItem);
}

void DefineIntMacro(LPCTSTR pszKey, int iValue)
{
	CString strValue;
	strValue.Format(_T("%d"), iValue);
	DefineMacro(pszKey, strValue);
}

void DefineIntMacro(LPCTSTR pszKey, int iItem, int iValue)
{
	CString strKey(pszKey);
	MakeKey(strKey, iItem);
	DefineIntMacro(strKey, iValue);
}

void DefineBoolMacro(LPCTSTR pszKey, BOOL bValue)
{
	if (bValue)
		DefineMacro(pszKey, _T("1"));
	else
		UndefMacro(pszKey);
}

void DefineBoolMacro(LPCTSTR pszKey, int iItem, BOOL bValue)
{
	CString strKey(pszKey);
	MakeKey(strKey, iItem);
	DefineBoolMacro(strKey, bValue);
}

void DefineStringMacro(LPCTSTR pszKey, LPCTSTR pszValue)
{
	DefineMacro(pszKey, pszValue);
}

void DefineStringMacro(LPCTSTR pszKey, int iItem, LPCTSTR pszValue)
{
	CString strKey(pszKey);
	MakeKey(strKey, iItem);
	DefineStringMacro(strKey, pszValue);
}

BOOL IsMacroDefine(LPCTSTR pszKey)
{
	return ALXAppWz.m_Dictionary.Lookup(pszKey, CString(""));
}

BOOL IsValidFileName(LPCTSTR psz)
{
	if (*psz == _T('\0') || *psz == _T('.'))
		return FALSE;

	TCHAR ch;
	while (ch = *psz)
	{
		if (ch == _T('\\') || ch == _T('//') || ch == _T(':'))
			return FALSE;

		psz = _tcsinc(psz);
	}

	return TRUE;
}

BOOL IsValidSymbol(LPCTSTR psz)
{
	if (!_istalpha(*psz) && *psz != _T('_'))
	{
		return FALSE;
	}

	psz = _tcsinc(psz);
	while (*psz != NULL)
	{
		if (!_istalnum(*psz) && *psz != _T('_'))
			return FALSE;
		psz = _tcsinc(psz);
	}

	return TRUE;
}

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