bc6c3d35 | /* Copyright (C) CJ Affiliate * * You may use, distribute and modify this code under the * terms of the GNU General Public License version 2 or * later. * * You should have received a copy of the license with this * file. If not, you will find a copy in the "LICENSE" file * at https://github.com/cjdev/dual-control. */ |
215ea751 | #ifndef SYS_FSTREAM_H #define SYS_FSTREAM_H #include <memory> #include <sstream> |
bc6c3d35 | class fstreams_ifc { public: typedef std::shared_ptr<std::istream> pstream; |
4d825470 | virtual ~fstreams_ifc() {} |
bc6c3d35 | virtual pstream open_fstream (const std::string &file_path) { return pstream (new std::istringstream ("")); } |
215ea751 | }; |
3ae0e083 | class fstreams |
bc6c3d35 | { public: typedef std::shared_ptr<fstreams_ifc> delegate; private: delegate delegate_; public: |
3ae0e083 | typedef fstreams_ifc::pstream pstream; |
bc6c3d35 | fstreams (const delegate &delegate) : delegate_ (delegate) {} fstreams() : fstreams (delegate (new fstreams_ifc)) {} pstream open_fstream (const std::string &file_path) { return delegate_->open_fstream (file_path); } static fstreams create(); |
215ea751 | }; #endif |