Hello, I have this macro, that expands to some methods of my class:
Code:
#define POPULAR_COMBO_FILTRO_COM_BASE(classeTabela) \
void VisualizadorLogsFrame::PopularComboFiltroCom ## classeTabela (bool limparTexto) { \
long from, to; \
m_cbxDetalhe->GetSelection(&from, &to); \
wxString conteudoCombo = m_cbxDetalhe->GetValue(); \
m_cbxDetalhe->Clear(); \
if (!limparTexto) { \
m_cbxDetalhe->SetValue(conteudoCombo); \
m_cbxDetalhe->SetSelection(from, to); \
} \
int pos = 0; \
for (list<classeTabela*>::iterator linha = m_lista ## classeTabela ->begin(); linha != m_lista ## classeTabela ->end(); linha++) { \
wxIntClientData* idInfo = new wxIntClientData(); \
idInfo->m_valor = (*linha)->m_id; \
wxString nome = (*linha)->m_name; \
if ( (m_cbxDetalhe->GetValue().size() == 0) || (nome.MakeUpper().Find(m_cbxDetalhe->GetValue().MakeUpper()) != wxNOT_FOUND) ) {
m_cbxDetalhe->Insert((*linha)->m_name, pos, idInfo); pos++;
};
};
};
and I want to use a template instead of it. So I had translated it to:
Code:
template<class T> void PopularComboFiltroComNomeavel(list<CLASSE_TABELA*>* lista, bool limparTexto) {
long from, to;
m_cbxDetalhe->GetSelection(&from, &to);
wxString conteudoCombo = m_cbxDetalhe->GetValue();
m_cbxDetalhe->Clear();
if (!limparTexto) {
m_cbxDetalhe->SetValue(conteudoCombo);
m_cbxDetalhe->SetSelection(from, to);
}
int pos = 0;
for (list< CLASSE_TABELA *>::iterator linha = lista->begin(); linha != lista->end(); linha++) {
wxIntClientData* idInfo = new wxIntClientData();
idInfo->m_valor = (*linha)->m_id;
wxString nome = (*linha)->m_name;
if ( (m_cbxDetalhe->GetValue().size() == 0) || (nome.MakeUpper().Find(m_cbxDetalhe->GetValue().MakeUpper()) != wxNOT_FOUND) ) {
m_cbxDetalhe->Insert((*linha)->m_name, pos, idInfo); pos++;
};
};
};
but I get a compile error on this line:
Code:
for (list< CLASSE_TABELA *>::iterator linha = lista->begin(); linha != lista->end(); linha++) {
what am I doing wrong ? the error is:
VisualizadorLogsMain.h:174: error: expected ‘;’ before ‘linha’
VisualizadorLogsMain.h:174: error: ‘linha’ was not declared in this scope
-Nelson