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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
// standard C++ includes
#include <string>
// our includes
#include "XMLChangelog.h"
#include "XMLSpec.h"
using namespace std;
bool XMLChangelogEntry::parseCreate(XMLAttrs* pAttrs,
const char* szChange,
XMLSpec* pSpec)
{
if (!pSpec)
return false;
XMLChangelogEntry change(szChange);
pSpec->getChangelog().lastDate().addEntry(change);
return true;
}
XMLChangelogEntry::XMLChangelogEntry(const char* szChange)
: XMLBase()
{
m_sChange.assign(szChange);
}
XMLChangelogEntry::XMLChangelogEntry(const XMLChangelogEntry& rEntry)
: XMLBase()
{
m_sChange.assign(rEntry.m_sChange);
}
XMLChangelogEntry::~XMLChangelogEntry()
{
}
void XMLChangelogEntry::toSpecFile(ostream& rOut)
{
rOut << endl << "- " << getChange();
}
void XMLChangelogEntry::toXMLFile(ostream& rOut)
{
rOut << endl << "\t\t\t<change>" << getChange() << "</change>";
}
// attribute structure for XMLChangelogDate
structValidAttrs g_paChangelogDateAttrs[] =
{
{0x0000, true, false, "date"},
{0x0001, true, false, "author"},
{0x0002, false, false, "author-email"},
{0x0003, false, false, "version"},
{XATTR_END, false, false, "end"}
};
bool XMLChangelogDate::parseCreate(XMLAttrs* pAttrs,
XMLSpec* pSpec)
{
// validate our attributes
if (!pAttrs->validate(g_paChangelogDateAttrs, (XMLBase*)pSpec))
return false;
XMLChangelogDate date(pAttrs->get("date"),
pAttrs->get("author"),
pAttrs->get("author-email"),
pAttrs->get("version"));
pSpec->getChangelog().addDate(date);
return true;
}
XMLChangelogDate::XMLChangelogDate(const char* szDate,
const char* szAuthor,
const char* szEmail,
const char* szVersion)
: XMLBase()
{
if (szDate)
m_sDate.assign(szDate);
if (szAuthor)
m_sAuthor.assign(szAuthor);
if (szEmail)
m_sEmail.assign(szEmail);
if (szVersion)
m_sVersion.assign(szVersion);
}
XMLChangelogDate::XMLChangelogDate(const XMLChangelogDate& rDate)
: XMLBase()
{
m_sDate.assign(rDate.m_sDate);
m_sAuthor.assign(rDate.m_sAuthor);
m_sEmail.assign(rDate.m_sEmail);
m_sVersion.assign(rDate.m_sVersion);
m_vEntries = rDate.m_vEntries;
}
XMLChangelogDate::~XMLChangelogDate()
{
}
void XMLChangelogDate::toSpecFile(ostream& rOut)
{
if (numEntries()) {
rOut << endl << "* " << getDate() << " " << getAuthor();
if (hasEmail())
rOut << " <" << getEmail() << ">";
if (hasVersion())
rOut << " " << getVersion();
for (unsigned int i = 0; i < numEntries(); i++)
getEntry(i).toSpecFile(rOut);
rOut << endl;
}
}
void XMLChangelogDate::toXMLFile(ostream& rOut)
{
if (numEntries()) {
rOut << endl << "\t\t<changes date=\"" << getDate() << "\"";
rOut << endl << "\t\t author=\"" << getAuthor() << "\"";
if (hasEmail())
rOut << endl << "\t\t author-email=\"" << getEmail() << "\"";
if (hasVersion())
rOut << endl << "\t\t version=\"" << getVersion() << "\"";
rOut << ">";
for (unsigned int i = 0; i < numEntries(); i++)
getEntry(i).toXMLFile(rOut);
rOut << endl << "\t\t</changes>";
}
}
XMLChangelog::XMLChangelog()
: XMLBase()
{
}
XMLChangelog::XMLChangelog(const XMLChangelog& rChangelog)
: XMLBase()
{
m_vDates = rChangelog.m_vDates;
}
XMLChangelog::~XMLChangelog()
{
}
void XMLChangelog::toSpecFile(ostream& rOut)
{
if (numDates()) {
rOut << endl << "%changelog";
for (unsigned int i = 0; i < numDates(); i++)
getDate(i).toSpecFile(rOut);
rOut << endl;
}
}
void XMLChangelog::toXMLFile(ostream& rOut)
{
if (numDates()) {
rOut << endl << "\t<changelog>";
for (unsigned int i = 0; i < numDates(); i++)
getDate(i).toXMLFile(rOut);
rOut << endl << "\t<changelog>";
}
}
void XMLChangelog::toRPMStruct(Spec spec)
{
}
|