~ubuntu-branches/ubuntu/vivid/mygui/vivid

« back to all changes in this revision

Viewing changes to MyGUIEngine/src/MyGUI_DataMemoryStream.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Howard, Bret Curtis, Scott Howard
  • Date: 2014-09-18 17:57:48 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140918175748-dd8va78mvpw1jbes
Tags: 3.2.1-1
[ Bret Curtis ]
* Updated license for majority of files from LGPL to Expat (MIT)

[ Scott Howard ]
* New upstream release
* Updated patch to add build option for system GLEW libraries
* All patches accepted upstream except shared_libraries.patch
* Bumped SONAME due to dropped symbols, updated *.symbols and package
  names
* Updated license of debian/* to Expat with permission of all authors
* Don't install Doxygen autogenerated md5 and map files (thanks
  lintian)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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