#include <cstdlib>
#include <map>
+#include <sstream>
#include <streambuf>
#include <string>
+#include <vector>
namespace ldid {
public Folder
{
private:
- Folder *parent_;
+ Folder &parent_;
std::string path_;
public:
- SubFolder(Folder *parent, const std::string &path);
+ SubFolder(Folder &parent, const std::string &path);
virtual void Save(const std::string &path, const Functor<void (std::streambuf &)> &code);
virtual bool Open(const std::string &path, const Functor<void (std::streambuf &)> &code);
virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code);
};
-std::string Bundle(const std::string &root, Folder &folder, const std::string &key, std::map<std::string, std::vector<char>> &remote);
+class UnionFolder :
+ public Folder
+{
+ private:
+ class StringBuffer :
+ public std::stringbuf
+ {
+ public:
+ StringBuffer() {
+ }
+
+ StringBuffer(const StringBuffer &rhs) :
+ std::stringbuf(rhs.str())
+ {
+ }
+ };
+
+ Folder &parent_;
+ std::map<std::string, StringBuffer> files_;
+
+ public:
+ UnionFolder(Folder &parent);
+
+ virtual void Save(const std::string &path, const Functor<void (std::streambuf &)> &code);
+ virtual bool Open(const std::string &path, const Functor<void (std::streambuf &)> &code);
+ virtual void Find(const std::string &path, const Functor<void (const std::string &, const Functor<void (const Functor<void (std::streambuf &, std::streambuf &)> &)> &)> &code);
+
+ std::stringbuf &operator [](const std::string &path) {
+ return files_[path];
+ }
+};
+
+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);
typedef std::map<uint32_t, std::vector<char>> Slots;