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 Functor<void (std::streambuf &)> &code) = 0;
53 virtual bool Open(const std::string &path, const Functor<void (std::streambuf &)> &code) = 0;
54 virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code) = 0;
61 const std::string path_;
62 std::map<std::string, std::string> commit_;
64 std::string Path(const std::string &path);
66 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);
69 DiskFolder(const std::string &path);
72 virtual void Save(const std::string &path, const Functor<void (std::streambuf &)> &code);
73 virtual bool Open(const std::string &path, const Functor<void (std::streambuf &)> &code);
74 virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code);
85 SubFolder(Folder &parent, const std::string &path);
87 virtual void Save(const std::string &path, const Functor<void (std::streambuf &)> &code);
88 virtual bool Open(const std::string &path, const Functor<void (std::streambuf &)> &code);
89 virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code);
103 StringBuffer(const StringBuffer &rhs) :
104 std::stringbuf(rhs.str())
110 std::map<std::string, StringBuffer> files_;
113 UnionFolder(Folder &parent);
115 virtual void Save(const std::string &path, const Functor<void (std::streambuf &)> &code);
116 virtual bool Open(const std::string &path, const Functor<void (std::streambuf &)> &code);
117 virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code);
119 std::stringbuf &operator [](const std::string &path) {
124 std::string Bundle(const std::string &root, Folder &folder, const std::string &key, std::map<std::string, std::vector<char>> &remote, const std::string &entitlements);
126 typedef std::map<uint32_t, std::vector<char>> Slots;
128 void Sign(const void *idata, size_t isize, std::streambuf &output, const std::string &identifier, const std::string &entitlements, const std::string &key, const Slots &slots);