Imported Upstream version 17.23.5
[platform/upstream/libzypp.git] / zypp / media / MetaLinkParser.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/media/MetaLinkParser.h
10  *
11 */
12 #ifndef ZYPP_MEDIA_METALINKPARSER_H
13 #define ZYPP_MEDIA_METALINKPARSER_H
14
15 #include <string>
16
17 #include <zypp/base/Exception.h>
18 #include <zypp/base/NonCopyable.h>
19 #include <zypp/base/InputStream.h>
20 #include <zypp/media/MediaBlockList.h>
21 #include <zypp/Url.h>
22
23 namespace zypp {
24   namespace media {
25
26 struct ml_parsedata;
27
28 class MetaLinkParser : private zypp::base::NonCopyable {
29 public:
30   MetaLinkParser();
31   ~MetaLinkParser();
32
33   /**
34    * parse a file consisting of metalink xml data
35    * \throws Exception
36    **/
37   void parse(const Pathname &filename);
38
39   /**
40    * parse an InputStream consisting of metalink xml data
41    * \throws Exception
42    **/
43   void parse(const InputStream &is);
44
45   /**
46    * parse a chunk of a file consisting of metalink xml data.
47    * \throws Exception
48    **/
49   void parseBytes(const char* bytes, size_t len);
50   /**
51    * tells the parser that all chunks are now processed
52    * \throws Exception
53    **/
54   void parseEnd();
55
56   /**
57    * return the download urls from the parsed metalink data
58    **/
59   std::vector<Url> getUrls();
60   /**
61    * return the block list from the parsed metalink data
62    **/
63   MediaBlockList getBlockList();
64
65 private:
66   struct ml_parsedata *pd;
67 };
68
69   } // namespace media
70 } // namespace zypp
71
72 #endif // ZYPP_MEDIA_METALINKPARSER_H