📄 adorswizardsheet.cpp
字号:
CString strText;
CString strDef(m_strClassName);
strDef.MakeUpper();
//Collecting data
strText.Format(
"#ifndef _%s_H_\n" \
"#define _%s_H_\n\n" \
"#if _MSC_VER >= 1000\n"
"#pragma once\n" \
"#endif // _MSC_VER >= 1000\n\n"
"// NOTE : In order to use this code against a different version of ADO, the appropriate\n" \
"// ADO library needs to be used in the #import statement\n" \
"#import \"C:\\Program Files\\Common Files\\System\\ADO\\msado15.dll\" rename_namespace(\"ADOCG\") rename(\"EOF\", \"EndOfFile\")\n" \
"using namespace ADOCG;\n" \
"#include \"icrsint.h\"\n\n" \
"#include \"oledb.h\"\n\n" \
"// %s : header file\n" \
"//\n\n" \
"/////////////////////////////////////////////////////////////////////////////\n" \
"// %s class\n\n" \
"class %s : public CADORecordBinding\n" \
"{\n" \
"BEGIN_ADO_BINDING(%s)\n", strDef, strDef, m_strFileName, m_strClassName, m_strClassName, m_strClassName);
//Writing data to file
fOutput.WriteString(strText);
fOutput.WriteString(strMACRO);
//Collecting data
strText =
"END_ADO_BINDING()\n\n" \
"//Attributes\n" \
"public:\n";
//Writing data to file
fOutput.WriteString(strText);
fOutput.WriteString(strAttributes);
//Collecting data
strText.Format(
"};\n\n" \
"//{{AFX_INSERT_LOCATION}}\n" \
"// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n" \
"#endif // !_%s_H_\n", strDef);
//Writing data to file
fOutput.WriteString(strText);
//Close file
fOutput.Close();
return TRUE;
}
void CADORsWizardSheet::BuildClassBindingString(FieldPtr pField, LPCTSTR lpszName, int nIndex, CString& strClassAttributes, CString& strClassMACRO)
{
nIndex++;
CString strDataType;
char szMemberName[100] = {0};
LONG lDefinedSize = pField->GetDefinedSize();
BOOL bExcept = FALSE;
int propType = (int)pField->GetType();
switch(propType)
{
case adBigInt:
strDataType = "adBigInt";
wsprintf(szMemberName , "m_li%s", lpszName);
strClassAttributes.Format("\tLARGE_INTEGER\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adBinary:
bExcept = TRUE;
strDataType = "adBinary";
wsprintf(szMemberName , "m_bt%s", lpszName);
strClassAttributes.Format("\tBYTE\t\t\t%s[%u];\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lDefinedSize, lpszName );
break;
case adBoolean:
strDataType = "adBoolean";
wsprintf(szMemberName , "m_b%s", lpszName);
strClassAttributes.Format("\tVARIANT_BOOL\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adBSTR:
strDataType = "adBSTR";
wsprintf(szMemberName , "m_bst%s", lpszName);
strClassAttributes.Format("\tBSTR\t\t\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adChapter:
strDataType = "adChapter";
break;
case adChar:
bExcept = TRUE;
strDataType = "adChar";
wsprintf(szMemberName , "m_sz%s", lpszName);
strClassAttributes.Format("\tCHAR\t\t\t%s[%u];\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lDefinedSize + 1, lpszName );
break;
case adCurrency:
strDataType = "adCurrency";
wsprintf(szMemberName , "m_li%s", lpszName);
strClassAttributes.Format("\tLARGE_INTEGER\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adDate:
strDataType = "adDate";
wsprintf(szMemberName , "m_dt%s", lpszName);
strClassAttributes.Format("\tDATE\t\t\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adDBDate:
strDataType = "adDBDate";
wsprintf(szMemberName , "m_dbdt%s", lpszName);
strClassAttributes.Format("\tDBDATE\t\t\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adDBTime:
strDataType = "adDBTime";
wsprintf(szMemberName , "m_dbtm%s", lpszName);
strClassAttributes.Format("\tDBTIME\t\t\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adDBTimeStamp:
strDataType = "adDBTimeStamp";
wsprintf(szMemberName , "m_dbtm%s", lpszName);
strClassAttributes.Format("\tDBTIMESTAMP\t\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adDecimal:
strDataType = "adDecimal";
wsprintf(szMemberName , "m_dec%s", lpszName);
strClassAttributes.Format("\tDBDECIMAL\t\t\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adDouble:
strDataType = "adDouble";
wsprintf(szMemberName , "m_d%s", lpszName);
strClassAttributes.Format("\tDOUBLE\t\t\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adEmpty:
strDataType = "adEmpty";
break;
case adError:
strDataType = "adError";
wsprintf(szMemberName , "m_err%s", lpszName);
strClassAttributes.Format("\tSCODE\t\t\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adFileTime:
strDataType = "adFileTime";
break;
case adGUID:
bExcept = TRUE;
strDataType = "adGUID";
wsprintf(szMemberName , "m_sz%s", lpszName);
strClassAttributes.Format("\tCHAR\t\t\t%s[%u];\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lDefinedSize + 1, lpszName );
break;
case adIDispatch:
strDataType = "adIDispatch";
wsprintf(szMemberName , "m_Id%s", lpszName);
strClassAttributes.Format("\tIDispatch * %s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adInteger:
strDataType = "adInteger";
wsprintf(szMemberName , "m_l%s", lpszName);
strClassAttributes.Format("\tLONG\t\t\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adIUnknown:
strDataType = "adIUnknown";
break;
case adLongVarBinary:
bExcept = TRUE;
strDataType = "adLongVarBinary";
wsprintf(szMemberName , "m_bt%s", lpszName);
lDefinedSize = (lDefinedSize <= 4096 * 2) ? lDefinedSize : 4096 * 2;
strClassAttributes.Format("\tBYTE\t\t\t%s[%u];\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lDefinedSize, lpszName );
break;
case adLongVarChar:
bExcept = TRUE;
strDataType = "adLongVarChar";
wsprintf(szMemberName , "m_sz%s", lpszName);
lDefinedSize = (lDefinedSize <= 4096 * 2) ? lDefinedSize : 4096 * 2;
strClassAttributes.Format("\tCHAR\t\t\t%s[%u];\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lDefinedSize, lpszName );
break;
case adLongVarWChar:
bExcept = TRUE;
strDataType = "adLongVarWChar";
wsprintf(szMemberName , "m_sz%s", lpszName);
lDefinedSize = (lDefinedSize <= 4096 * 2) ? lDefinedSize : 4096 * 2;
strClassAttributes.Format("\tCHAR\t\t\t%s[%u];\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lDefinedSize, lpszName );
break;
case adNumeric:
strDataType = "adNumeric";
wsprintf(szMemberName , "m_num%s", lpszName);
strClassAttributes.Format("\tDBNUMERIC\t\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adPropVariant:
strDataType = "adPropVariant";
break;
case adSingle:
strDataType = "adSingle";
wsprintf(szMemberName , "m_f%s", lpszName);
strClassAttributes.Format("\tFLOAT\t\t\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adSmallInt:
strDataType = "adSmallInt";
wsprintf(szMemberName , "m_s%s", lpszName);
strClassAttributes.Format("\tSHORT\t\t\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adTinyInt:
strDataType = "adTinyInt";
wsprintf(szMemberName , "m_c%s", lpszName);
strClassAttributes.Format("\tsigned char %s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adUnsignedBigInt:
strDataType = "adUnsignedBigInt";
wsprintf(szMemberName , "m_uli%s", lpszName);
strClassAttributes.Format("\tULARGE_INTEGER\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adUnsignedInt:
strDataType = "adUnsignedInt";
wsprintf(szMemberName , "m_u%s", lpszName);
strClassAttributes.Format("\tunsigned int\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adUnsignedSmallInt:
strDataType = "adUnsignedSmallInt";
wsprintf(szMemberName , "m_us%s", lpszName);
strClassAttributes.Format("\tunsigned short\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adUnsignedTinyInt:
strDataType = "adUnsignedTinyInt";
wsprintf(szMemberName , "m_bt%s", lpszName);
strClassAttributes.Format("\tBYTE\t\t\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adUserDefined:
strDataType = "adUserDefined";
break;
case adVarBinary:
bExcept = TRUE;
strDataType = "adVarBinary";
wsprintf(szMemberName , "m_sz%s", lpszName);
lDefinedSize = (lDefinedSize <= 4096 * 2) ? lDefinedSize : 4096 * 2;
strClassAttributes.Format("\tBYTE\t\t\t%s[%u];\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lDefinedSize, lpszName );
break;
case adVarChar:
bExcept = TRUE;
strDataType = "adVarChar";
wsprintf(szMemberName , "m_sz%s", lpszName);
strClassAttributes.Format("\tCHAR\t\t\t%s[%u];\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lDefinedSize + 1, lpszName );
break;
case adVariant:
strDataType = "adVariant";
wsprintf(szMemberName , "m_vt%s", lpszName);
strClassAttributes.Format("\tVARIANT\t\t\t%s;\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lpszName );
break;
case adVarNumeric:
strDataType = "adVarNumeric";
break;
case adVarWChar:
bExcept = TRUE;
strDataType = "adVarWChar";
wsprintf(szMemberName , "m_sz%s", lpszName);
strClassAttributes.Format("\tCHAR\t\t\t%s[%u];\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lDefinedSize + 1, lpszName );
break;
case adWChar:
bExcept = TRUE;
strDataType = "adWChar";
wsprintf(szMemberName , "m_sz%s", lpszName);
strClassAttributes.Format("\tCHAR\t\t\t%s[%u];\n\tULONG\t\t\tm_l%sStatus;\n", szMemberName, lDefinedSize + 1, lpszName );
break;
default:
strDataType = "*UNKNOWN*";
break;
}
if(pField->Attributes & adFldFixed && !bExcept)
{
strClassMACRO.Format("\tADO_FIXED_LENGTH_ENTRY (%3d, %s, %s, m_l%sStatus, FALSE)\n", nIndex, strDataType, szMemberName, lpszName);
}
else
{
strClassMACRO.Format("\tADO_VARIABLE_LENGTH_ENTRY2(%3d, %s, %s, sizeof(%s), m_l%sStatus, FALSE)\n", nIndex, strDataType, szMemberName, szMemberName, lpszName);
}
}
void CADORsWizardSheet::OnAbout()
{
CAboutBox dlg;
dlg.DoModal();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -