1 /*
2 * Copyright (C) 2020 Veloman Yunkan
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied
11 * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and
12 * NON-INFRINGEMENT. See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 *
18 */
19
20 #include "istreamreader.h"
21 #include "buffer_reader.h"
22
23 namespace zim
24 {
25
26 ////////////////////////////////////////////////////////////////////////////////
27 // IDataStream
28 ////////////////////////////////////////////////////////////////////////////////
29
30 std::unique_ptr<const Reader>
sub_reader(zsize_t size)31 IStreamReader::sub_reader(zsize_t size)
32 {
33 auto buffer = Buffer::makeBuffer(size);
34 readImpl(const_cast<char*>(buffer.data()), size);
35 return std::unique_ptr<Reader>(new BufferReader(buffer));
36 }
37
38 } // namespace zim
39