1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-07 04:10:08 +00:00

Couple of additions to MemoryInputStream.

This commit is contained in:
jules 2012-06-18 08:49:41 +01:00
parent a82a42b358
commit b1cc8cce00
2 changed files with 11 additions and 5 deletions

View file

@ -26,7 +26,7 @@
MemoryInputStream::MemoryInputStream (const void* const sourceData,
const size_t sourceDataSize,
const bool keepInternalCopy)
: data (static_cast <const char*> (sourceData)),
: data (sourceData),
dataSize (sourceDataSize),
position (0)
{
@ -36,7 +36,7 @@ MemoryInputStream::MemoryInputStream (const void* const sourceData,
MemoryInputStream::MemoryInputStream (const MemoryBlock& sourceData,
const bool keepInternalCopy)
: data (static_cast <const char*> (sourceData.getData())),
: data (sourceData.getData()),
dataSize (sourceData.getSize()),
position (0)
{
@ -68,9 +68,9 @@ int MemoryInputStream::read (void* const buffer, const int howMany)
if (num <= 0)
return 0;
memcpy (buffer, data + position, (size_t) num);
memcpy (buffer, addBytesToPointer (data, position), (size_t) num);
position += num;
return (int) num;
return num;
}
bool MemoryInputStream::isExhausted()

View file

@ -70,6 +70,12 @@ public:
/** Destructor. */
~MemoryInputStream();
/** Returns a pointer to the source data block from which this stream is reading. */
const void* getData() const noexcept { return data; }
/** Returns the number of bytes of source data in the block from which this stream is reading. */
size_t getDataSize() const noexcept { return dataSize; }
//==============================================================================
int64 getPosition();
bool setPosition (int64 pos);
@ -79,7 +85,7 @@ public:
private:
//==============================================================================
const char* data;
const void* data;
size_t dataSize, position;
HeapBlock<char> internalCopy;