* updated gstreamer (1.18.3 -> 1.18.5)
[t2-trunk.git] / source / desc-parser.hh
blob280a64211233bc5d573ee6a9a12f6aeef19b4fe5
1 /*
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"
18 #include <sstream>
20 // some inteligent Version information class, that contains
21 // some logic to compare version numbers, including -beta and
22 // -alpha suffixes
24 class DownloadInfo
26 public:
27 std::string chksum;
28 std::string file;
29 std::string url;
30 std::string down_url;
31 std::string protocol;
34 class DownloadTag : public Tag
36 public:
37 DownloadTag () : Tag ("D","DOWN","DOWNLOAD") {}
39 bool Parse ()
41 std::string::size_type line_start = 0;
42 std::string::size_type line_end;
43 do {
44 line_end = value.find('\n', line_start);
45 std::string line = value.substr(line_start, line_end-line_start);
46 ParseLine (line);
47 line_start = line_end+1;
48 } while (line_end != std::string::npos && line_end < value.length()-1);
50 return true;
53 virtual void ClearImpl ()
55 download_infos.clear ();
58 std::vector<DownloadInfo> download_infos;
60 private:
61 bool ParseLine (const std::string& line)
62 { // Todo: Error evaluation !
63 DownloadInfo info;
64 std::stringstream sstr(line);
65 sstr >> info.chksum;
66 sstr >> info.file;
67 sstr >> info.url;
69 if (info.url[0] == '!') { // overwriting filename
70 info.url.erase(0,1);
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);
74 } else
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);
81 return true;
86 // TODO: IMHO better tag bookkeeping ... -ReneR
87 class Package : public TagParser
89 public:
90 Package()
91 : copyright("COPY","",""),
93 title("I","","INFO"),
94 text("T","","TEXT"),
95 url("U","","URL"),
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"),
110 download (),
111 cv_url("","","CV-URL"),
112 cv_flags("","","CV-FLAGS"),
114 sourcepackage("SRC","","SRCPACKAGE"),
115 conf("O","","CONF")
117 tags.push_back(&copyright);
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);
142 ~Package()
145 bool ParsePackage(const std::string& file)
147 return Parse(file) && download.Parse();
150 Tag copyright;
152 Tag title;
153 Tag text;
154 Tag url;
156 Tag author;
157 Tag maintainer;
159 Tag category;
160 Tag flags;
161 Tag arch;
162 Tag kernel;
163 Tag dependency;
165 Tag license;
166 Tag status;
167 Tag version;
168 Tag priority;
170 DownloadTag download;
171 Tag cv_url;
172 Tag cv_flags;
174 Tag sourcepackage;
175 Tag conf;