dasdeck
1
hi,
i try to get an XML attribute with a variable attribute name.
like this:
void SomeClass::fillList(ComboBox* box,String fieldName)
{
box->addItem(someXmlData->getStringAttribute(fieldName));
}
getStringAttribute wants “const tchar *const attributeName” of course, but how to convert to this from String? i don’t get it.
thanks
D3CK
valley
2
The easiest ways is just to wrap the String in a T() macro,
I.E. instead of “hello” use T(“hello”)
dasdeck
3
thanks
but using literals does not help here.
D3CK
Well, a string will readily produce a Tchar type. Is it just a cast to const you need?
Bruce
dasdeck
5
ahh! I’m a bit shy with type casts when not using my own classes.
so:
String cat;
String text = someXmlData->getStringAttribute((const tchar*)cat);
seems to work so far.
thanks a lot!
D3CK
jules
6
There’s no need to explicitly use that (const tchar*) cast there, the compiler will handle it for you.