2 * --- T2-COPYRIGHT-NOTE-BEGIN ---
3 * This copyright note is auto-generated by scripts/Create-CopyPatch.
5 * T2 SDE: source/UpdateList.cc
6 * Copyright (C) 2004 - 2021 The T2 SDE Project
8 * More information can be found in the files COPYING and README.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2 of the License. A copy of the
13 * GNU General Public License can be found in the file COPYING.
14 * --- T2-COPYRIGHT-NOTE-END ---
17 #include "tag-parser.hh"
20 // some inteligent Version information class, that contains
21 // some logic to compare version numbers, including -beta and
34 class DownloadTag
: public Tag
37 DownloadTag () : Tag ("D","DOWN","DOWNLOAD") {}
41 std::string::size_type line_start
= 0;
42 std::string::size_type line_end
;
44 line_end
= value
.find('\n', line_start
);
45 std::string line
= value
.substr(line_start
, line_end
-line_start
);
47 line_start
= line_end
+1;
48 } while (line_end
!= std::string::npos
&& line_end
< value
.length()-1);
53 virtual void ClearImpl ()
55 download_infos
.clear ();
58 std::vector
<DownloadInfo
> download_infos
;
61 bool ParseLine (const std::string
& line
)
62 { // Todo: Error evaluation !
64 std::stringstream
sstr(line
);
69 if (info
.url
[0] == '!') { // overwriting filename
71 info
.down_url
= info
.url
;
72 std::string::size_type url_end
= info
.url
.rfind('/');
73 info
.url
= info
.url
.substr(0,url_end
);
75 info
.down_url
= info
.url
+info
.file
;
77 std::string::size_type protocol_end
= info
.url
.find(':');
78 info
.protocol
= info
.url
.substr(0, protocol_end
);
80 download_infos
.push_back(info
);
86 // TODO: IMHO better tag bookkeeping ... -ReneR
87 class Package
: public TagParser
91 : copyright("COPY","",""),
97 author("A","AUTH","AUTHOR"),
98 maintainer("M","","MAINTAINER"),
99 category("C","","CATEGORY"),
100 flags("F","","FLAGS"),
101 arch("R","ARCH","ARCHITECTUR"),
102 kernel("K","KERN","KERNEL"),
103 dependency("E","DEP","DEPENDENCY"),
105 license("L","","LICENCE"),
106 status("S","","STATUS"),
107 version("V","VER","VERSION"),
108 priority("P","","PRIORITY"),
111 cv_url("","","CV-URL"),
112 cv_flags("","","CV-FLAGS"),
114 sourcepackage("SRC","","SRCPACKAGE"),
117 tags
.push_back(©right
);
118 tags
.push_back(&title
);
119 tags
.push_back(&text
);
120 tags
.push_back(&url
);
122 tags
.push_back(&author
);
123 tags
.push_back(&maintainer
);
125 tags
.push_back(&category
);
126 tags
.push_back(&flags
);
127 tags
.push_back(&arch
);
128 tags
.push_back(&dependency
);
130 tags
.push_back(&license
);
131 tags
.push_back(&status
);
132 tags
.push_back(&version
);
133 tags
.push_back(&priority
);
135 tags
.push_back(&download
);
136 tags
.push_back(&cv_url
);
137 tags
.push_back(&cv_flags
);
138 tags
.push_back(&sourcepackage
);
139 tags
.push_back(&conf
);
145 bool ParsePackage(const std::string
& file
)
147 return Parse(file
) && download
.Parse();
170 DownloadTag download
;