2 * --- T2-COPYRIGHT-NOTE-BEGIN ---
3 * T2 SDE: source/desc-parser.hh
4 * Copyright (C) 2004 - 2021 The T2 SDE Project
6 * This Copyright note is generated by scripts/Create-CopyPatch,
7 * more information can be found in the files COPYING and README.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2.
11 * --- T2-COPYRIGHT-NOTE-END ---
14 #include "tag-parser.hh"
17 // some inteligent Version information class, that contains
18 // some logic to compare version numbers, including -beta and
31 class DownloadTag
: public Tag
34 DownloadTag () : Tag ("D","DOWN","DOWNLOAD") {}
38 std::string::size_type line_start
= 0;
39 std::string::size_type line_end
;
41 line_end
= value
.find('\n', line_start
);
42 std::string line
= value
.substr(line_start
, line_end
-line_start
);
44 line_start
= line_end
+1;
45 } while (line_end
!= std::string::npos
&& line_end
< value
.length()-1);
50 virtual void ClearImpl ()
52 download_infos
.clear ();
55 std::vector
<DownloadInfo
> download_infos
;
58 bool ParseLine (const std::string
& line
)
59 { // Todo: Error evaluation !
61 std::stringstream
sstr(line
);
66 if (info
.url
[0] == '!') { // overwriting filename
68 info
.down_url
= info
.url
;
69 std::string::size_type url_end
= info
.url
.rfind('/');
70 info
.url
= info
.url
.substr(0,url_end
);
72 info
.down_url
= info
.url
+info
.file
;
74 std::string::size_type protocol_end
= info
.url
.find(':');
75 info
.protocol
= info
.url
.substr(0, protocol_end
);
77 download_infos
.push_back(info
);
83 // TODO: IMHO better tag bookkeeping ... -ReneR
84 class Package
: public TagParser
88 : copyright("COPY","",""),
94 author("A","AUTH","AUTHOR"),
95 maintainer("M","","MAINTAINER"),
96 category("C","","CATEGORY"),
97 flags("F","","FLAGS"),
98 arch("R","ARCH","ARCHITECTUR"),
99 kernel("K","KERN","KERNEL"),
100 dependency("E","DEP","DEPENDENCY"),
102 license("L","","LICENCE"),
103 status("S","","STATUS"),
104 version("V","VER","VERSION"),
105 priority("P","","PRIORITY"),
108 cv_url("","","CV-URL"),
109 cv_flags("","","CV-FLAGS"),
111 sourcepackage("SRC","","SRCPACKAGE"),
114 tags
.push_back(©right
);
115 tags
.push_back(&title
);
116 tags
.push_back(&text
);
117 tags
.push_back(&url
);
119 tags
.push_back(&author
);
120 tags
.push_back(&maintainer
);
122 tags
.push_back(&category
);
123 tags
.push_back(&flags
);
124 tags
.push_back(&arch
);
125 tags
.push_back(&kernel
);
126 tags
.push_back(&dependency
);
128 tags
.push_back(&license
);
129 tags
.push_back(&status
);
130 tags
.push_back(&version
);
131 tags
.push_back(&priority
);
133 tags
.push_back(&download
);
134 tags
.push_back(&cv_url
);
135 tags
.push_back(&cv_flags
);
136 tags
.push_back(&sourcepackage
);
137 tags
.push_back(&conf
);
143 bool ParsePackage(const std::string
& file
)
145 return Parse(file
) && download
.Parse();
168 DownloadTag download
;