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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
|
#ifndef _H_XMLSPEC_
#define _H_XMLSPEC_
// standard C++ includes
#include <iostream>
#include <string>
#include <vector>
// our includes
#include "XMLAttrs.h"
#include "XMLBase.h"
#include "XMLChangelog.h"
#include "XMLMacro.h"
#include "XMLPackage.h"
#include "XMLScript.h"
#include "XMLSource.h"
// rpm includes
#include <rpmbuild.h>
using namespace std;
// <spec ...>
class XMLSpec : public XMLBase
{
//
// static object creation functions
//
public:
/**
* Creates an XMLSpec from values parsed
* .
* @param pAttrs The XML attributes
* @param szFilename The XML spec filename
* @return Pointer to the created spec
**/
static XMLSpec* parseCreate(XMLAttrs* pAttrs,
const char* szFilename);
/**
* Creates and XMLSpec from an RPM Spec structure
* .
* @param pSpec The RPM spec structure
* @return Pointer to the created spec
**/
static XMLSpec* structCreate(Spec pSpec);
//
// constructors/destructor
//
public:
/**
* Default constructor
* .
* @param szFilename Filename of the spec on disk
* @param szName spec name
* @param szVersion Spec version
* @param szRelease spec release
* @param szEpoch spec epoch
* @param szDistribution spec distribution
* @param szVendor spec vendor
* @param szPackage spec packager
* @param szPkgEmail email address for the packager
* @param szCopyright spec copyright/licence
* @param szURL main package url
* @param szBuildRoot buildroot
* @return none
**/
XMLSpec(const char* szFilename,
const char* szName,
const char* szVersion,
const char* szRelease,
const char* szEpoch,
const char* szDistribution,
const char* szVendor,
const char* szPackager,
const char* szPkgrEmail,
const char* szCopyright,
const char* szURL,
const char* szBuildRoot);
/**
* Destructor
* .
* @param none
* @return none
**/
~XMLSpec();
//
// public member functions
//
public:
/**
* Converts the spec object to a normal RPM spec file
* .
* @param rOut Reference to the stream to write the information to
* @return none
**/
void toSpecFile(ostream& rOut);
/**
* Converts the spec object to an XML spec file
* .
* @param rOut Reference to the stream to write the information to
* @return none
**/
void toXMLFile(ostream& rOut);
/**
* Converts the spec object to an internal RPM structure
* .
* @param none
* @return the created RPM structure
**/
void toRPMStruct(Spec* pRPMSpec);
//
// member variable get/set functions
//
public:
/**
* Adds a package to the internal list
* .
* @param rPkg Reference to the package to add
* @return none
**/
void addPackage(XMLPackage& rPkg)
{
m_vPackages.push_back(rPkg);
}
/**
* Gets the number of packages
* .
* @param none
* @return the number of packages
**/
unsigned int numPackages()
{
return m_vPackages.size();
}
/**
* Gets a specific package
* .
* @param nNum The package number
* @return the required package
**/
XMLPackage& getPackage(unsigned int nNum)
{
return m_vPackages[nNum];
}
/**
* Gets the last package added
* .
* @param none
* @return the last package added
**/
XMLPackage& lastPackage()
{
return m_vPackages[numPackages()-1];
}
/**
* Adds a source to the internal list
* .
* @param rSource Reference to the source to add
* @return none
**/
void addSource(XMLSource& rSource)
{
m_vSources.push_back(rSource);
}
/**
* Gets the number of sources
* .
* @param none
* @return the number of sources
**/
unsigned int numSources()
{
return m_vSources.size();
}
/**
* Gets a specific source
* .
* @param nNum The source number
* @return the required source
**/
XMLSource& getSource(unsigned int nNum)
{
return m_vSources[nNum];
}
/**
* Gets the last source added
* .
* @param none
* @return the last source added
**/
XMLSource& lastSource()
{
return m_vSources[numSources()-1];
}
/**
* Adds a source to the internal list
* .
* @param rSource Reference to the source to add
* @return none
**/
void addNoSource(XMLNoSource& rSource)
{
m_vNoSources.push_back(rSource);
}
/**
* Gets the number of nosources
* .
* @param none
* @return the number of nsources
**/
unsigned int numNoSources()
{
return m_vNoSources.size();
}
/**
* Gets a specific nosource
* .
* @param nNum The nosource number
* @return the required nosource
**/
XMLNoSource& getNoSource(unsigned int nNum)
{
return m_vNoSources[nNum];
}
/**
* Gets the last nosource added
* .
* @param none
* @return the last nosource added
**/
XMLNoSource& lastNoSource()
{
return m_vNoSources[numNoSources()-1];
}
/**
* Adds a patch to the internal list
* .
* @param rSource Reference to the patch to add
* @return none
**/
void addPatch(XMLPatch& rSource)
{
m_vPatches.push_back(rSource);
}
/**
* Gets the number of patches
* .
* @param none
* @return the number of patches
**/
unsigned int numPatches()
{
return m_vPatches.size();
}
/**
* Gets a specific patch
* .
* @param nNum The patch number
* @return the required patch
**/
XMLPatch& getPatch(unsigned int nNum)
{
return m_vPatches[nNum];
}
/**
* Gets the last patch added
* .
* @param none
* @return the last patch added
**/
XMLPatch& lastPatch()
{
return m_vPatches[numPatches()-1];
}
/**
* Adds a macro to the internal list
* .
* @param rMacro Reference to the macro to add
* @return none
**/
void addXMacro(XMLMacro& rMacro)
{
m_vMacros.push_back(rMacro);
}
/**
* Gets the number of macros
* .
* @param none
* @return the number of macros
**/
unsigned int numXMacros()
{
return m_vMacros.size();
}
/**
* Gets a specific macro
* .
* @param nNum The macro number
* @return the required macro
**/
XMLMacro& getXMacro(unsigned int nNum)
{
return m_vMacros[nNum];
}
/**
* Checks if we have a filename
* .
* @param none
* @return true if available, false otherwise
**/
bool hasFilename()
{
return m_sFilename.length() ? true : false;
}
/**
* Gets the filename
* .
* @param none
* @return string containing the filename
**/
const char* getFilename()
{
return m_sFilename.c_str();
}
/**
* Checks if we have a name
* .
* @param none
* @return true if available, false otherwise
**/
bool hasName()
{
return m_sName.length() ? true : false;
}
/**
* Gets the name
* .
* @param none
* @return string containing the name
**/
const char* getName()
{
return m_sName.c_str();
}
/**
* Checks if we have a version
* .
* @param none
* @return true if available, false otherwise
**/
bool hasVersion()
{
return m_sVersion.length() ? true : false;
}
/**
* Gets the version
* .
* @param none
* @return string containing the version
**/
const char* getVersion()
{
return m_sVersion.c_str();
}
/**
* Checks if we have a release
* .
* @param none
* @return true if available, false otherwise
**/
bool hasRelease()
{
return m_sRelease.length() ? true : false;
}
/**
* Gets the release
* .
* @param none
* @return string containing the release
**/
const char* getRelease()
{
return m_sRelease.c_str();
}
/**
* Checks if we have a epoch
* .
* @param none
* @return true if available, false otherwise
**/
bool hasEpoch()
{
return m_sEpoch.length() ? true : false;
}
/**
* Gets the epoch
* .
* @param none
* @return string containing the epoch
**/
const char* getEpoch()
{
return m_sEpoch.c_str();
}
/**
* Checks if we have a distribution
* .
* @param none
* @return true if available, false otherwise
**/
bool hasDistribution()
{
return m_sDistribution.length() ? true : false;
}
/**
* Gets the distribution
* .
* @param none
* @return string containing the distribution
**/
const char* getDistribution()
{
return m_sDistribution.c_str();
}
/**
* Checks if we have a vendor
* .
* @param none
* @return true if available, false otherwise
**/
bool hasVendor()
{
return m_sVendor.length() ? true : false;
}
/**
* Gets the vendor
* .
* @param none
* @return string containing the vendor
**/
const char* getVendor()
{
return m_sVendor.c_str();
}
/**
* Checks if we have a packager
* .
* @param none
* @return true if available, false otherwise
**/
bool hasPackager()
{
return m_sPackager.length() ? true : false;
}
/**
* Gets the packager
* .
* @param none
* @return string containing the packager
**/
const char* getPackager()
{
return m_sPackager.c_str();
}
/**
* Checks if we have a packager email
* .
* @param none
* @return true if available, false otherwise
**/
bool hasPkgrEmail()
{
return m_sPkgrEmail.length() ? true : false;
}
/**
* Gets the packager's email address
* .
* @param none
* @return string containing the packager's email address
**/
const char* getPkgrEmail()
{
return m_sPkgrEmail.c_str();
}
/**
* Checks if we have a copyright
* .
* @param none
* @return true if available, false otherwise
**/
bool hasCopyright()
{
return m_sCopyright.length() ? true : false;
}
/**
* Gets the copyright
* .
* @param none
* @return string containing the copyright
**/
const char* getCopyright()
{
return m_sCopyright.c_str();
}
/**
* Checks if we have an URL
* .
* @param none
* @return true if available, false otherwise
**/
bool hasURL()
{
return m_sURL.length() ? true : false;
}
/**
* Gets the URL
* .
* @param none
* @return string containing the URL
**/
const char* getURL()
{
return m_sURL.c_str();
}
/**
* Checks if we have a BuildRoot
* .
* @param none
* @return true if available, false otherwise
**/
bool hasBuildRoot()
{
return m_sBuildRoot.length() ? true : false;
}
/**
* Gets the buildroot
* .
* @param none
* @return string containing the buildroor
**/
const char* getBuildRoot()
{
return m_sBuildRoot.c_str();
}
/**
* Gets the prep section
* .
* @param none
* @return reference to the prep section
**/
XMLScripts& getPrep()
{
return m_Prep;
}
/**
* Gets the build section
* .
* @param none
* @return reference to the build section
**/
XMLScripts& getBuild()
{
return m_Build;
}
/**
* Gets the install section
* .
* @param none
* @return reference to the install section
**/
XMLScripts& getInstall()
{
return m_Install;
}
/**
* Gets the clean section
* .
* @param none
* @return reference to the clean section
**/
XMLScripts& getClean()
{
return m_Clean;
}
/**
* Gets the changelog section
* .
* @param none
* @return reference to the changelog section
**/
XMLChangelog& getChangelog()
{
return m_Changelog;
}
//
// internal member variables
//
protected:
string m_sFilename;
string m_sName;
string m_sVersion;
string m_sRelease;
string m_sEpoch;
string m_sDistribution;
string m_sVendor;
string m_sPackager;
string m_sPkgrEmail;
string m_sCopyright;
string m_sURL;
string m_sBuildRoot;
vector<XMLPackage> m_vPackages;
vector<XMLSource> m_vSources;
vector<XMLNoSource> m_vNoSources;
vector<XMLPatch> m_vPatches;
vector<XMLMacro> m_vMacros;
XMLScripts m_Prep;
XMLScripts m_Build;
XMLScripts m_Install;
XMLScripts m_Clean;
XMLChangelog m_Changelog;
};
#endif
|