diff options
author | vng <viktor.govako@gmail.com> | 2011-06-30 10:52:22 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:20:14 +0300 |
commit | 233683d1670e89076c82401e2693315046c7244e (patch) | |
tree | 3b0a9b71d53e853e663da18c362f6ba267b1bc85 /coding/file_container.cpp | |
parent | f0587a9105b5519903f4f2c3dada1ee3572e7ce1 (diff) |
[Refactoring] Use Reader interface everywhere, when possible. Platform class now is a Reader factory.
Diffstat (limited to 'coding/file_container.cpp')
-rw-r--r-- | coding/file_container.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/coding/file_container.cpp b/coding/file_container.cpp index c17c7cb811..808f056e93 100644 --- a/coding/file_container.cpp +++ b/coding/file_container.cpp @@ -9,11 +9,12 @@ // FilesContainerBase ///////////////////////////////////////////////////////////////////////////// -void FilesContainerBase::ReadInfo(FileReader & reader) +template <class ReaderT> +void FilesContainerBase::ReadInfo(ReaderT & reader) { uint64_t offset = ReadPrimitiveFromPos<uint64_t>(reader, 0); - ReaderSource<FileReader> src(reader); + ReaderSource<ReaderT> src(reader); src.Skip(offset); uint32_t const count = ReadVarUint<uint32_t>(src); @@ -37,12 +38,18 @@ void FilesContainerBase::ReadInfo(FileReader & reader) FilesContainerR::FilesContainerR(string const & fName, uint32_t logPageSize, uint32_t logPageCount) -: m_source(fName, logPageSize, logPageCount) + : m_source(new FileReader(fName, logPageSize, logPageCount)) +{ + ReadInfo(m_source); +} + +FilesContainerR::FilesContainerR(ReaderT const & file) + : m_source(file) { ReadInfo(m_source); } -FileReader FilesContainerR::GetReader(Tag const & tag) const +FilesContainerR::ReaderT FilesContainerR::GetReader(Tag const & tag) const { InfoContainer::const_iterator i = lower_bound(m_info.begin(), m_info.end(), tag, LessInfo()); |