13 // I wish Apple cared about providing quality toolchains :/
15 template <typename Function_>
18 template <typename Type_, typename... Args_>
19 class Functor<Type_ (Args_...)> {
21 virtual Type_ operator ()(Args_... args) const = 0;
24 template <typename Function_>
27 template <typename Value_, typename Type_, typename... Args_>
28 class FunctorImpl<Type_ (Value_::*)(Args_...) const> :
29 public Functor<Type_ (Args_...)>
35 FunctorImpl(const Value_ &value) :
40 virtual Type_ operator ()(Args_... args) const {
41 return (*value_)(args...);
45 template <typename Function_>
46 FunctorImpl<decltype(&Function_::operator())> fun(const Function_ &value) {
52 virtual void Save(const std::string &path, const void *flag, const Functor<void (std::streambuf &)> &code) = 0;
53 virtual bool Look(const std::string &path) = 0;
54 virtual void Open(const std::string &path, const Functor<void (std::streambuf &, const void *)> &code) = 0;
55 virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link) = 0;
62 const std::string path_;
63 std::map<std::string, std::string> commit_;
65 std::string Path(const std::string &path);
67 void Find(const std::string &root, const std::string &base, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link);
70 DiskFolder(const std::string &path);
73 virtual void Save(const std::string &path, const void *flag, const Functor<void (std::streambuf &)> &code);
74 virtual bool Look(const std::string &path);
75 virtual void Open(const std::string &path, const Functor<void (std::streambuf &, const void *)> &code);
76 virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link);
87 SubFolder(Folder &parent, const std::string &path);
89 virtual void Save(const std::string &path, const void *flag, const Functor<void (std::streambuf &)> &code);
90 virtual bool Look(const std::string &path);
91 virtual void Open(const std::string &path, const Functor<void (std::streambuf &, const void *)> &code);
92 virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link);
100 public std::stringbuf
106 StringBuffer(const StringBuffer &rhs) :
107 std::stringbuf(rhs.str())
113 std::set<std::string> deletes_;
115 std::map<std::string, std::string> remaps_;
116 std::map<std::string, std::pair<StringBuffer, const void *>> resets_;
118 std::string Map(const std::string &path);
119 void Map(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code, const std::string &file, const Functor<void (const Functor<void (std::streambuf &, const void *)> &)> &save);
122 UnionFolder(Folder &parent);
124 virtual void Save(const std::string &path, const void *flag, const Functor<void (std::streambuf &)> &code);
125 virtual bool Look(const std::string &path);
126 virtual void Open(const std::string &path, const Functor<void (std::streambuf &, const void *)> &code);
127 virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link);
129 void operator ()(const std::string &from) {
130 deletes_.insert(from);
133 void operator ()(const std::string &from, const std::string &to) {
138 std::stringbuf &operator ()(const std::string &from, const void *flag) {
140 auto &reset(resets_[from]);
148 std::vector<char> hash;
151 Bundle Sign(const std::string &root, Folder &folder, const std::string &key, const std::string &entitlements, const std::string &requirement);
153 typedef std::map<uint32_t, std::vector<char>> Slots;
155 std::string Analyze(const void *data, size_t size);
156 std::vector<char> Sign(const void *idata, size_t isize, std::streambuf &output, const std::string &identifier, const std::string &entitlements, const std::string &requirement, const std::string &key, const Slots &slots);