BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[C++ Error] CAutoLookup.h(144): E2034 Cannot convert 'XXX' t

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Upgrade)
View previous topic :: View next topic  
Author Message
Mars
Guest





PostPosted: Mon Apr 10, 2006 3:03 am    Post subject: [C++ Error] CAutoLookup.h(144): E2034 Cannot convert 'XXX' t Reply with quote



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__
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Upgrade) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.