MyGUI
3.2.1
Main Page
Related Pages
Namespaces
Data Structures
Files
Examples
File List
Globals
mygui
MyGUIEngine
src
MyGUI_DataMemoryStream.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_DataMemoryStream.h
"
9
10
namespace
MyGUI
11
{
12
13
DataMemoryStream::DataMemoryStream
() :
14
mData(
nullptr
),
15
mSize(0),
16
mStream(0)
17
{
18
}
19
20
DataMemoryStream::DataMemoryStream
(
unsigned
char
* _data,
size_t
_size) :
21
mData(_data),
22
mSize(_size),
23
mStream(
nullptr
)
24
{
25
}
26
27
DataMemoryStream::~DataMemoryStream
()
28
{
29
delete
mStream
;
30
}
31
32
size_t
DataMemoryStream::size
()
33
{
34
return
mSize
;
35
}
36
37
bool
DataMemoryStream::eof
()
38
{
39
if
(
mStream
==
nullptr
)
40
prepareStream();
41
42
return
mStream
->eof();
43
}
44
45
void
DataMemoryStream::readline
(std::string& _source,
Char
_delim)
46
{
47
if
(
mStream
==
nullptr
)
48
prepareStream();
49
50
std::getline(*
mStream
, _source, (
char
)_delim);
51
}
52
53
size_t
DataMemoryStream::read
(
void
* _buf,
size_t
_count)
54
{
55
if
(
mData
==
nullptr
)
56
return
0;
57
58
size_t
count = (std::min)(
size
(), _count);
59
::memcpy(_buf,
mData
, count);
60
return
count;
61
}
62
63
void
DataMemoryStream::prepareStream()
64
{
65
if
(
mData
==
nullptr
)
66
return
;
67
68
mStream
=
new
std::stringstream((
const
char
*)
mData
);
69
}
70
71
}
// namespace MyGUI
Generated on Wed Aug 20 2014 00:03:32 for MyGUI by
1.8.3.1