14 // I wish Apple cared about providing quality toolchains :/
16 template <typename Function_>
19 template <typename Type_, typename... Args_>
20 class Functor<Type_ (Args_...)> {
22 virtual Type_ operator ()(Args_... args) const = 0;
25 template <typename Function_>
28 template <typename Value_, typename Type_, typename... Args_>
29 class FunctorImpl<Type_ (Value_::*)(Args_...) const> :
30 public Functor<Type_ (Args_...)>
36 FunctorImpl(const Value_ &value) :
41 virtual Type_ operator ()(Args_... args) const {
42 return (*value_)(args...);
46 template <typename Function_>
47 FunctorImpl<decltype(&Function_::operator())> fun(const Function_ &value) {
53 virtual void Save(const std::string &path, bool edit, const void *flag, const Functor<void (std::streambuf &)> &code) = 0;
54 virtual bool Look(const std::string &path) const = 0;
55 virtual void Open(const std::string &path, const Functor<void (std::streambuf &, const void *)> &code) const = 0;
56 virtual void Find(const std::string &path, const Functor<void (const std::string &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link) const = 0;
63 const std::string path_;
64 std::map<std::string, std::string> commit_;
66 std::string Path(const std::string &path) const;
68 void Find(const std::string &root, const std::string &base, const Functor<void (const std::string &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link) const;
71 DiskFolder(const std::string &path);
74 virtual void Save(const std::string &path, bool edit, const void *flag, const Functor<void (std::streambuf &)> &code);
75 virtual bool Look(const std::string &path) const;
76 virtual void Open(const std::string &path, const Functor<void (std::streambuf &, const void *)> &code) const;
77 virtual void Find(const std::string &path, const Functor<void (const std::string &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link) const;
88 SubFolder(Folder &parent, const std::string &path);
90 virtual void Save(const std::string &path, bool edit, const void *flag, const Functor<void (std::streambuf &)> &code);
91 virtual bool Look(const std::string &path) const;
92 virtual void Open(const std::string &path, const Functor<void (std::streambuf &, const void *)> &code) const;
93 virtual void Find(const std::string &path, const Functor<void (const std::string &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link) const;
101 public std::stringbuf
107 StringBuffer(const StringBuffer &rhs) :
108 std::stringbuf(rhs.str())
114 std::set<std::string> deletes_;
116 std::map<std::string, std::string> remaps_;
117 mutable std::map<std::string, std::pair<StringBuffer, const void *>> resets_;
119 std::string Map(const std::string &path) const;
120 void Map(const std::string &path, const Functor<void (const std::string &)> &code, const std::string &file, const Functor<void (const Functor<void (std::streambuf &, const void *)> &)> &save) const;
123 UnionFolder(Folder &parent);
125 virtual void Save(const std::string &path, bool edit, const void *flag, const Functor<void (std::streambuf &)> &code);
126 virtual bool Look(const std::string &path) const;
127 virtual void Open(const std::string &path, const Functor<void (std::streambuf &, const void *)> &code) const;
128 virtual void Find(const std::string &path, const Functor<void (const std::string &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link) const;
130 void operator ()(const std::string &from) {
131 deletes_.insert(from);
134 void operator ()(const std::string &from, const std::string &to) {
139 std::stringbuf &operator ()(const std::string &from, const void *flag) {
141 auto &reset(resets_[from]);
149 std::vector<char> hash;
152 Bundle Sign(const std::string &root, Folder &folder, const std::string &key, const std::string &requirement, const Functor<std::string (const std::string &, const std::string &)> &alter);
154 typedef std::map<uint32_t, std::vector<char>> Slots;
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);