karazeh
A cross-platform software updating library.
version_manifest.hpp
Go to the documentation of this file.
1 
21 #ifndef H_KARAZEH_VERSION_MANIFEST_H
22 #define H_KARAZEH_VERSION_MANIFEST_H
23 
24 #include <map>
25 #include <vector>
26 #include "json11/json11.hpp"
27 #include "karazeh_export.h"
28 #include "karazeh/karazeh.hpp"
29 #include "karazeh/config.hpp"
30 #include "karazeh/hasher.hpp"
32 #include "karazeh/file_manager.hpp"
33 #include "karazeh/downloader.hpp"
34 #include "karazeh/operation.hpp"
38 
39 namespace kzh {
40  typedef json11::Json JSON;
41 
42  using std::vector;
43  using std::map;
44 
46  public:
47  explicit version_manifest(config_t const&);
48  virtual ~version_manifest();
49 
57  void load_from_uri(string_t const& uri);
58 
70  void load_from_string(string_t const& raw_json);
71 
81  void load_release_from_uri(string_t const&);
82 
91  void load_release_from_string(string_t const& raw_json);
92 
118  void parse(JSON const&);
119 
120  void parse_release(JSON const&);
121 
125  int get_release_count() const;
126 
130  int get_release_count(string_t const& identity) const;
131 
142  string_t get_current_version() const;
143 
148  vector<string_t> get_available_updates(const string_t& current_version) const;
149 
153  release_manifest const* get_release(const string_t&) const;
154 
155  private:
156  struct identity_list_t {
157  inline explicit identity_list_t(string_t const& name) : name(name) {};
158  inline ~identity_list_t() {
159  files.clear();
160  };
161 
162  string_t name;
163  vector<path_t> files;
164  };
165 
166  map<string_t, identity_list_t> identity_lists_;
167  vector<release_manifest*> releases_;
168  config_t const &config_;
169 
170  release_manifest* find_or_create_release(JSON const&);
171  operation* parse_operation(release_manifest const&, JSON const&, JSON const&) const;
172  };
173 
174 } // end of namespace kzh
175 
176 #endif
json11::Json JSON
Definition: version_manifest.hpp:40
Definition: operation.hpp:50
std::string string_t
Definition: karazeh.hpp:55
Definition: config.hpp:32
Definition: release_manifest.hpp:32
Definition: version_manifest.hpp:45
Definition: config.hpp:27