diff -r 000000000000 -r 9f739222ee8c attribute.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/attribute.cpp Thu Nov 08 15:28:04 2007 +0000 @@ -0,0 +1,101 @@ +#include "attribute.h" + +Attribute::Attribute() +{ + key=""; + value=""; +} + +void Attribute::setKey (const QString &k) +{ + key=k; +} + +QString Attribute::getKey () +{ + return key; +} + +void Attribute::setValue(const QString &v) +{ + value=v; +} + +QString Attribute::getValue() +{ + return value; +} + +QString Attribute::getDataXML() +{ + return valueElement ("attribute",key,value); +} + + +/////////////////////////////////////////////////////////////// +AttributeTable::AttributeTable() +{ + clear(); +} + +AttributeTable::~AttributeTable() +{ +} + +void AttributeTable::clear () +{ + keys.clear(); + values.clear(); +} + +void AttributeTable::addKey (const QString &k) +{ + if (!keys.contains (k) ) + { + keys.append (k); + values.append (QStringList() ); + } +} + +void AttributeTable::removeKey (const QString &k) +{ + int i=keys.indexOf (k); + if (i>=0) + { + keys.removeAt(i); + values.removeAt(i); + } +} + +void AttributeTable::addValue (const QString &k, const QString &v) +{ + int i=keys.indexOf (k); + if (i<0) + { + keys.append (k); + values.append (QStringList (v)); + } else + { + int j=values.at(i).indexOf(k); + if (j<0) values[i].append (QString(v)); + } +} + +QStringList AttributeTable::getKeys () +{ + return keys; +} + +QStringList AttributeTable::getValues(const QString &k) +{ + int i=keys.indexOf (k); + if (i>=0) + return values.at(i); + else + return QStringList(); +} + +QString AttributeTable::getDataXML() +{ + return valueElement ("attributeList","key","value"); +}