Thread View: borland.public.cppbuilder.upgrade
1 messages
1 total messages
Started by Mars
Mon, 10 Apr 2006 02:40
[C++ Error] CAutoLookup.h(144): E2034 Cannot convert 'XXX' to 'XXX *'
Author: Mars
Date: Mon, 10 Apr 2006 02:40
Date: Mon, 10 Apr 2006 02:40
291 lines
8482 bytes
8482 bytes
When I upgrade my BCB6 code to BDS2006, the project code compile fail
with E2034 in using STL mem_fun function.
Error Message:
[C++ Error] CAutoLookup.h(144): E2034 Cannot convert
'_Vector_iterator<TCNameCodeInfo,allocator<TCNameCodeInfo> >' to
'TCNameCodeInfo *'
Full parser context
CAutoLookup.h(132): decision to instantiate: void
CAutoLookup<TCNameCodeInfoList,int (TCNameCodeInfo::*)(),string
(TCNameCodeInfo::*)()>::FillComboBox(TComboBox *)
--- Resetting parser context for instantiation...
CPublicFunc.cpp(23): #include
E:\CVSWork\products\openboss\\public_win\util\CAutoLookup.h
CAutoLookup.h(113): class CAutoLookup<TypeList,FnGetCode,FnGetName>
CAutoLookup.h(132): parsing: void
CAutoLookup<TCNameCodeInfoList,int (TCNameCodeInfo::*)(),string
(TCNameCodeInfo::*)()>::FillComboBox(TComboBox *)
my Code:CAutoLookup.h
#ifndef __C_AUTO_LOOKUP_H__
#define __C_AUTO_LOOKUP_H__
#ifndef __cplusplus
#error CAutoLookup requires C++ compilation (use a .cpp suffix)
#endif
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;
#ifdef INC_VCL
#include <vcl.h>
#include <StdCtrls.hpp>
#endif
template <class TypeList>
class CBasicLookup
{
public:
typedef auto_ptr<CBasicLookup<TypeList> > safe_ptr;
CBasicLookup(TypeList &vDataList) : m_vNameCodeList(vDataList)
{
};
~CBasicLookup(void)
{
};
CBasicLookup& operator=(const CBasicLookup &rhs)
{
if (&rhs != this)
{
m_vNameCodeList = rhs.m_vNameCodeList;
}
return (*this);
};
void SetSourceList(const TypeList &vDataList)
{
m_vNameCodeList = vDataList;
return;
};
const TypeList& GetSourceList(void) const
{
return (m_vNameCodeList);
};
#ifdef INC_VCL
virtual void FillComboBox(TComboBox *pComboBox) = 0;
virtual void FillListBox(TListBox *pListBox) = 0;
#endif
virtual int CNameToCodeID(const char *pszCName) = 0;
virtual int NameToCode(const char *pszCName) = 0;
virtual const char* CodeIDToCName(int nCodeID) = 0;
virtual const char* CodeToName(int nCodeID) = 0;
protected:
TypeList m_vNameCodeList;
protected:
CBasicLookup(void);
};
template <class TypeList, typename FnGetCode, typename FnGetName>
class CAutoLookup : public CBasicLookup<TypeList>
{
public:
CAutoLookup(TypeList &vDataList, FnGetCode pGetCode, FnGetName
pGetName) :
CBasicLookup<TypeList>(vDataList),
m_pGetCode(pGetCode),
m_pGetName(pGetName)
{
};
virtual ~CAutoLookup(void)
{
};
#ifdef INC_VCL
void FillComboBox(TComboBox *pComboBox)
{
if (NULL == pComboBox)
{
return;
}
TypeList::iterator IndexPtr = m_vNameCodeList.begin();
TypeList::iterator EndPtr = m_vNameCodeList.end();
for (; IndexPtr != EndPtr; ++IndexPtr)
{
const char *Result = MergeCodeName(
mem_fun(m_pGetCode)(IndexPtr),
mem_fun(m_pGetName)(IndexPtr).c_str()
);
pComboBox->Items->Add(Result);
}
if (pComboBox->Items->Count > 0)
{
pComboBox->ItemIndex = 0;
}
return;
};
void FillListBox(TListBox *pListBox)
{
if (NULL != pListBox)
{
TypeList::iterator IndexPtr = NULL;
TypeList::iterator EndPtr = m_vNameCodeList.end();
for (IndexPtr = m_vNameCodeList.begin(); IndexPtr !=
EndPtr; ++IndexPtr)
{
pListBox->Items->Add(MergeCodeName(mem_fun(m_pGetCode)(IndexPtr),
mem_fun(m_pGetName)(IndexPtr).c_str()));
}
}
return;
};
#endif
int CNameToCodeID(const char *pszCName)
{
TypeList::iterator IndexPtr = NULL;
TypeList::iterator EndPtr = m_vNameCodeList.end();
for (IndexPtr = m_vNameCodeList.begin(); IndexPtr != EndPtr;
++IndexPtr)
{
if (strcmpi(MergeCodeName(mem_fun(m_pGetCode)(IndexPtr),
mem_fun(m_pGetName)(IndexPtr).c_str()), pszCName) == 0)
{
return (mem_fun(m_pGetCode)(IndexPtr));
}
}
return (atoi(pszCName));
};
int NameToCode(const char *pszCName)
{
TypeList::iterator IndexPtr = NULL;
TypeList::iterator EndPtr = m_vNameCodeList.end();
for (IndexPtr = m_vNameCodeList.begin(); IndexPtr != EndPtr;
++IndexPtr)
{
if
(strcmpi(MergeCodeName(mem_fun(m_pGetName)(IndexPtr).c_str()),
pszCName) == 0)
{
return (mem_fun(m_pGetCode)(IndexPtr));
}
}
return (atoi(pszCName));
};
const char* CodeIDToCName(int nCodeID)
{
static char szCName[128] = "";
memset(szCName, 0, sizeof(szCName));
itoa(nCodeID, szCName, 10);
TypeList::iterator IndexPtr = NULL;
TypeList::iterator EndPtr = m_vNameCodeList.end();
for (IndexPtr = m_vNameCodeList.begin(); IndexPtr != EndPtr;
++IndexPtr)
{
if (mem_fun(m_pGetCode)(IndexPtr) == nCodeID)
{
strncpy(szCName,
MergeCodeName(mem_fun(m_pGetCode)(IndexPtr),
mem_fun(m_pGetName)(IndexPtr).c_str()), (sizeof(szCName) - 1));
break;
}
}
return (szCName);
};
const char* CodeToName(int nCodeID)
{
static char szCName[128] = "";
memset(szCName, 0, sizeof(szCName));
TypeList::iterator IndexPtr = NULL;
TypeList::iterator EndPtr = m_vNameCodeList.end();
for (IndexPtr = m_vNameCodeList.begin(); IndexPtr != EndPtr;
++IndexPtr)
{
if (mem_fun(m_pGetCode)(IndexPtr) == nCodeID)
{
strncpy(szCName,
MergeCodeName(mem_fun(m_pGetName)(IndexPtr).c_str()), (sizeof(szCName)
- 1));
break;
}
}
return (szCName);
};
protected:
CAutoLookup(void);
const char* MergeCodeName(int nCodeID, const char *pszCName)
{
static char szResult[128] = "";
memset(szResult, 0, sizeof(szResult));
if (NULL != pszCName)
{
snprintf(szResult, (sizeof(szResult) - 1), "[%d] %s",
nCodeID, pszCName);
}
return (szResult);
};
const char* MergeCodeName(const char *pszCName)
{
static char szResult[128] = "";
memset(szResult, 0, sizeof(szResult));
if (NULL != pszCName)
{
snprintf(szResult, (sizeof(szResult) - 1), "%s", pszCName);
}
return (szResult);
};
private:
FnGetCode m_pGetCode;
FnGetName m_pGetName;
};
template <class TypeList, typename FnGetCode, typename FnGetName>
CBasicLookup<TypeList>* CreateAutoLookup(TypeList& vDataList, FnGetCode
fnGetCode, FnGetName fnGetName)
{
return (new CAutoLookup<TypeList, FnGetCode, FnGetName>(vDataList,
fnGetCode, fnGetName));
}
#endif //__C_AUTO_LOOKUP_H__
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads