kan ik bstr_t in een switch statement gebruiken?

Status
Niet open voor verdere reacties.

Jabber

Gebruiker
Lid geworden
8 feb 2007
Berichten
271
Ik heb de volgende code:
Code:
const bstr_t EQUIPMENTID	= "EquipmentID";
const bstr_t GW_LICENSE		= "GWLicense";
const bstr_t SDR_LICENSE	= "SDRLicense";
const bstr_t GW_VERSION		= "GWVersion";
const bstr_t SDR_VERSION	= "SDRVersion";
const bstr_t GW_SERIAL		= "GWSerial";
const bstr_t SDR_SERIAL		= "SDRSerial";

bstr_t strNodeName = pParent->nodeName;
	
	switch(strNodeName)
	{
		case EQUIPMENTID:	{this->m_pCGemdb->m_EquipmentID	= pChild->text; break;}
		case GW_LICENSE:	{this->m_pCGemdb->m_GWLicense	= pChild->text; break;}
		case SDR_LICENSE:	{this->m_pCGemdb->m_SDRLicense	= pChild->text; break;}
		case GW_VERSION:	{this->m_pCGemdb->m_GWVersion	= pChild->text; break;}
		case SDR_VERSION:	{this->m_pCGemdb->m_SDRVersion	= pChild->text; break;}
		case GW_SERIAL:		{this->m_pCGemdb->m_GWSerial	= pChild->text; break;}
		case SDR_SERIAL:	{this->m_pCGemdb->m_SDRSerial	= pChild->text; break;}
		default:			{break;}
	}

Echter geeft dit de volgende foutmeldingen:
Code:
xxxx.cpp(147) : error C2450: switch expression of type 'class _bstr_t' is illegal
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
xxxx.cpp(148) : error C2051: case expression not constant
xxxx.cpp(149) : error C2051: case expression not constant
xxxx.cpp(150) : error C2051: case expression not constant
xxxx.cpp(151) : error C2051: case expression not constant
xxxx.cpp(152) : error C2051: case expression not constant
xxxx.cpp(153) : error C2051: case expression not constant
xxxx.cpp(154) : error C2051: case expression not constant

Heeft iemand enig idee? Of een handig trucj hiervoor?
Anders moet ik alles gaan casten of if-elsen...
 
Nou ja, ik heb alles maar even omgeschreven.
Ik heb de hoop opgegeven dat iemand het antwoord wist:

Code:
IXMLDOMNodePtr pParent = pChild->GetparentNode();
bstr_t strNodeName = pParent->nodeName;

if (strNodeName == EQUIPMENTID) {this->m_pCGemdb->m_EquipmentID = pChild->text;}
else if (strNodeName == GW_LICENSE) {this->m_pCGemdb->m_GWLicense = pChild->ext;}
else if (strNodeName == SDR_LICENSE) {this->m_pCGemdb->m_SDRLicense = pChild->text;}
else if (strNodeName == GW_VERSION) {this->m_pCGemdb->m_GWVersion = pChild->text;}
else if (strNodeName == SDR_VERSION) {this->m_pCGemdb->m_SDRVersion = pChild->text;}
else if (strNodeName == GW_SERIAL) {this->m_pCGemdb->m_GWSerial = pChild->text;}
else if (strNodeName == SDR_SERIAL) {this->m_pCGemdb->m_SDRSerial = pChild->text;}
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan