#ifndef QTESTCOREELEMENT_H #define QTESTCOREELEMENT_H #include "qtestcorelist.h" #include "qtestelementattribute.h" QT_BEGIN_NAMESPACE template class QTestCoreElement: public QTestCoreList { public: QTestCoreElement( int type = -1 ); virtual ~QTestCoreElement(); void addAttribute(const QTest::AttributeIndex index, const char *value); QTestElementAttribute *attributes() const; const char *attributeValue(QTest::AttributeIndex index) const; const char *attributeName(QTest::AttributeIndex index) const; const QTestElementAttribute *attribute(QTest::AttributeIndex index) const; const char *elementName() const; QTest::LogElementType elementType() const; private: QTestElementAttribute *listOfAttributes; QTest::LogElementType type; }; template QTestCoreElement::QTestCoreElement(int t) :listOfAttributes(0), type((QTest::LogElementType)t) { } template QTestCoreElement::~QTestCoreElement() { delete listOfAttributes; } template void QTestCoreElement::addAttribute(const QTest::AttributeIndex attributeIndex, const char *value) { if(attributeIndex == -1) return; if (attribute(attributeIndex)) return; QTestElementAttribute *attribute = new QTestElementAttribute; attribute->setPair(attributeIndex, value); attribute->addToList(&listOfAttributes); } template QTestElementAttribute *QTestCoreElement::attributes() const { return listOfAttributes; } template const char *QTestCoreElement::attributeValue(QTest::AttributeIndex index) const { const QTestElementAttribute *attrb = attribute(index); if(attrb) return attrb->value(); return 0; } template const char *QTestCoreElement::attributeName(QTest::AttributeIndex index) const { const QTestElementAttribute *attrb = attribute(index); if(attrb) return attrb->name(); return 0; } template const char *QTestCoreElement::elementName() const { const char *xmlElementNames[] = { "property", "properties", "failure", "error", "testcase", "testsuite", "benchmark", "system-err" }; if(type != QTest::LET_Undefined) return xmlElementNames[type]; return 0; } template QTest::LogElementType QTestCoreElement::elementType() const { return type; } template const QTestElementAttribute *QTestCoreElement::attribute(QTest::AttributeIndex index) const { QTestElementAttribute *iterator = listOfAttributes; while(iterator){ if(iterator->index() == index) return iterator; iterator = iterator->nextElement(); } return 0; } QT_END_NAMESPACE #endif