return parent_.Open(Map(path), code);
auto &entry(file->second);
- auto &data(entry.first);
+ auto &data(*entry.data_);
auto length(data.pubseekoff(0, std::ios::end, std::ios::in));
data.pubseekpos(0, std::ios::in);
- code(data, length, entry.second);
+ code(data, length, entry.flag_);
}
void UnionFolder::Find(const std::string &path, const Functor<void (const std::string &)> &code, const Functor<void (const std::string &, const Functor<std::string ()> &)> &link) const {
for (auto &reset : resets_)
Map(path, code, reset.first, fun([&](const Functor<void (std::streambuf &, size_t, const void *)> &code) {
auto &entry(reset.second);
- auto length(entry.first.pubseekoff(0, std::ios::end, std::ios::in));
- entry.first.pubseekpos(0, std::ios::in);
- code(entry.first, length, entry.second);
+ auto &data(*entry.data_);
+ auto length(data.pubseekoff(0, std::ios::end, std::ios::in));
+ data.pubseekpos(0, std::ios::in);
+ code(data, length, entry.flag_);
}));
for (auto &remap : remaps_)
public Folder
{
private:
- class StringBuffer :
- public std::stringbuf
- {
- public:
- StringBuffer() {
- }
-
- StringBuffer(const StringBuffer &rhs) :
- std::stringbuf(rhs.str())
- {
- }
+ struct Reset {
+ const void *flag_;
+ std::streambuf *data_;
};
Folder &parent_;
std::set<std::string> deletes_;
std::map<std::string, std::string> remaps_;
- mutable std::map<std::string, std::pair<StringBuffer, const void *>> resets_;
+ mutable std::map<std::string, Reset> resets_;
std::string Map(const std::string &path) const;
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 &, size_t, const void *)> &)> &save) const;
remaps_[to] = from;
}
- std::stringbuf &operator ()(const std::string &from, const void *flag) {
+ void operator ()(const std::string &from, const void *flag, std::streambuf &data) {
operator ()(from);
auto &reset(resets_[from]);
- reset.second = flag;
- return reset.first;
+ reset.flag_ = flag;
+ reset.data_ = &data;
}
};