1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
/*
* File: XmlGenericWriterAttributes.h
* Author: john
*
* Created on November 6, 2009, 10:48 AM
*/
#ifndef __XML_GENERIC_WRITER_ATTRIBUTES_H__
#define __XML_GENERIC_WRITER_ATTRIBUTES_H__
#include <QString>
#include <QVector>
/**
* Maintains attribute for XML Generic Writer.
*/
class XmlGenericWriterAttributes {
public:
/**
* Constructor.
*/
XmlGenericWriterAttributes() {
this->clear();
}
/**
* Clear the attributes.
*/
void clear() {
this->names.clear();
this->values.clear();
}
/**
* Add an attribute.
*
* @param name - Name of attribute.
* @param value - Value of attribute.
*/
void addAttribute(QString name, QString value) {
names.append(name);
values.append(value);
}
/**
* Add an attribute.
*
* @param name - Name of attribute.
* @param value - Value of attribute.
*/
void addAttribute(QString name, char value) {
names.append(name);
values.append(QString::number(value));
}
/**
* Add an attribute.
*
* @param name - Name of attribute.
* @param value - Value of attribute.
*/
void addAttribute(QString name, short value) {
names.append(name);
values.append(QString::number(value));
}
/**
* Add an attribute.
*
* @param name - Name of attribute.
* @param value - Value of attribute.
*/
void addAttribute(QString name, int value) {
names.append(name);
values.append(QString::number(value));
}
/**
* Add an attribute.
*
* @param name - Name of attribute.
* @param value - Value of attribute.
*/
void addAttribute(QString name, long value) {
names.append(name);
values.append(QString::number(value));
}
/**
* Add an attribute.
*
* @param name - Name of attribute.
* @param value - Value of attribute.
*/
void addAttribute(QString name, float value) {
names.append(name);
values.append(QString::number(value, 'f'));
}
/**
* Add an attribute.
*
* @param name - Name of attribute.
* @param value - Value of attribute.
*/
void addAttribute(QString name, double value) {
names.append(name);
values.append(QString::number(value, 'f'));
}
/**
* Get the number of attributes.
*
* @return Number of attributes.
*/
int getNumberOfAttributes() {
return this->names.size();
}
/**
* Get the name of an attribute.
*
* @param index - index of attribute.
*
* @return Name of attribute at index.
*/
QString getAttributeName(int index) {
return this->names.at(index);
}
/**
* Get the value of an attribute.
*
* @param index - index of attribute.
*
* @return Value of attribute at index.
*/
QString getAttributeValue(int index) {
return this->values.at(index);
}
private:
/** attribute names. */
QVector<QString> names;
/** attribute values. */
QVector<QString> values;
};
#endif /* __XML_GENERIC_WRITER_ATTRIBUTES_H__ */
|