1
#include "attribute.h"
2
3
Attribute::Attribute()
4
{
5
key="";
6
value="";
7
}
8
9
void Attribute::setKey (const QString &k)
10
11
key=k;
12
13
14
QString Attribute::getKey ()
15
16
return key;
17
18
19
void Attribute::setValue(const QString &v)
20
21
value=v;
22
23
24
QString Attribute::getValue()
25
26
return value;
27
28
29
void Attribute::setTable (AttributeTable *at)
30
31
table=at;
32
33
34
AttributeTable* Attribute::getTable()
35
36
return table;
37
38
39
QString Attribute::getDataXML()
40
41
return valueElement ("attribute",key,value);
42
43
44
45
///////////////////////////////////////////////////////////////
46
AttributeTable::AttributeTable()
47
48
clear();
49
50
51
AttributeTable::~AttributeTable()
52
53
54
55
void AttributeTable::clear ()
56
57
keys.clear();
58
values.clear();
59
60
61
void AttributeTable::addKey (const QString &k)
62
63
if (!keys.contains (k) )
64
65
keys.append (k);
66
values.append (QStringList() );
67
68
69
70
void AttributeTable::removeKey (const QString &k)
71
72
int i=keys.indexOf (k);
73
if (i>=0)
74
75
keys.removeAt(i);
76
values.removeAt(i);
77
78
79
80
int AttributeTable::countKeys()
81
82
return keys.count();
83
84
85
void AttributeTable::addValue (const QString &k, const QString &v)
86
87
88
if (i<0)
89
90
91
values.append (QStringList (v));
92
} else
93
94
int j=values.at(i).indexOf(k);
95
if (j<0) values[i].append (QString(v));
96
97
98
99
QStringList AttributeTable::getKeys ()
100
101
return keys;
102
103
104
QStringList AttributeTable::getValues(const QString &k)
105
106
107
108
return values.at(i);
109
else
110
return QStringList();
111
112
113
QString AttributeTable::getDataXML()
114
115
return valueElement ("attributeList","key","value");
116