MyGUI 3.5.3
MyGUI_IDataStream.cpp
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#include "MyGUI_Precompiled.h"
8#include "MyGUI_IDataStream.h"
9
10namespace MyGUI
11{
12
13 namespace
14 {
15
16 template<typename Container>
17 Container readAllData(IDataStream& _stream)
18 {
19 Container content;
20 typename Container::value_type buffer[16 * 1024];
21 while (size_t readSize = _stream.read(buffer, sizeof(buffer)))
22 content.insert(content.end(), buffer, buffer + readSize);
23 return content;
24 }
25
26 }
27
28 std::vector<std::byte> IDataStream::readAll()
29 {
30 return readAllData<std::vector<std::byte>>(*this);
31 }
32
33 std::string IDataStream::readAllText()
34 {
35 return readAllData<std::string>(*this);
36 }
37
38} // namespace MyGUI