added methods to buffer elements
This commit is contained in:
parent
38d3fd991e
commit
238ca0cef9
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <c++utilities/conversion/types.h>
|
#include <c++utilities/conversion/types.h>
|
||||||
#include <c++utilities/io/copy.h>
|
#include <c++utilities/io/copy.h>
|
||||||
|
#include <c++utilities/misc/memory.h>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
@ -27,7 +28,6 @@ namespace Media {
|
||||||
template <class ImplementationType>
|
template <class ImplementationType>
|
||||||
class GenericFileElement;
|
class GenericFileElement;
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \class Media::FileElementIterator
|
* \class Media::FileElementIterator
|
||||||
* \brief The FileElementIterator class helps iterating through the childs of a FileElement.
|
* \brief The FileElementIterator class helps iterating through the childs of a FileElement.
|
||||||
|
@ -191,6 +191,10 @@ public:
|
||||||
void copyHeader(std::ostream &targetStream);
|
void copyHeader(std::ostream &targetStream);
|
||||||
void copyWithoutChilds(std::ostream &targetStream);
|
void copyWithoutChilds(std::ostream &targetStream);
|
||||||
void copyEntirely(std::ostream &targetStream);
|
void copyEntirely(std::ostream &targetStream);
|
||||||
|
void makeBuffer();
|
||||||
|
void releaseBuffer();
|
||||||
|
void copyBuffer(std::ostream &targetStream);
|
||||||
|
const std::unique_ptr<char[]> &buffer();
|
||||||
implementationType *denoteFirstChild(uint32 offset);
|
implementationType *denoteFirstChild(uint32 offset);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -202,6 +206,7 @@ protected:
|
||||||
implementationType* m_parent;
|
implementationType* m_parent;
|
||||||
std::unique_ptr<implementationType> m_nextSibling;
|
std::unique_ptr<implementationType> m_nextSibling;
|
||||||
std::unique_ptr<implementationType> m_firstChild;
|
std::unique_ptr<implementationType> m_firstChild;
|
||||||
|
std::unique_ptr<char[]> m_buffer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void copyInternal(std::ostream &targetStream, uint64 startOffset, uint64 bytesToCopy);
|
void copyInternal(std::ostream &targetStream, uint64 startOffset, uint64 bytesToCopy);
|
||||||
|
@ -767,7 +772,7 @@ void GenericFileElement<ImplementationType>::validateSubsequentElementStructure(
|
||||||
parse();
|
parse();
|
||||||
gatheredNotifications.insert(gatheredNotifications.end(), notifications().begin(), notifications().end());
|
gatheredNotifications.insert(gatheredNotifications.end(), notifications().begin(), notifications().end());
|
||||||
if(firstChild()) { // element is parent
|
if(firstChild()) { // element is parent
|
||||||
firstChild()->validateSubsequentElementStructure(gatheredNotifications);
|
firstChild()->validateSubsequentElementStructure(gatheredNotifications, paddingSize);
|
||||||
} else if(paddingSize && isPadding()) { // element is padding
|
} else if(paddingSize && isPadding()) { // element is padding
|
||||||
*paddingSize += totalSize();
|
*paddingSize += totalSize();
|
||||||
}
|
}
|
||||||
|
@ -811,6 +816,32 @@ void GenericFileElement<ImplementationType>::copyEntirely(std::ostream &targetSt
|
||||||
copyInternal(targetStream, startOffset(), totalSize());
|
copyInternal(targetStream, startOffset(), totalSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class ImplementationType>
|
||||||
|
void GenericFileElement<ImplementationType>::makeBuffer()
|
||||||
|
{
|
||||||
|
m_buffer = std::make_unique<char[]>(totalSize());
|
||||||
|
container().stream().seekg(startOffset());
|
||||||
|
container().stream().read(m_buffer.get(), totalSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ImplementationType>
|
||||||
|
inline void GenericFileElement<ImplementationType>::releaseBuffer()
|
||||||
|
{
|
||||||
|
m_buffer.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ImplementationType>
|
||||||
|
inline void GenericFileElement<ImplementationType>::copyBuffer(std::ostream &targetStream)
|
||||||
|
{
|
||||||
|
targetStream.write(m_buffer.get(), totalSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ImplementationType>
|
||||||
|
inline const std::unique_ptr<char[]> &GenericFileElement<ImplementationType>::buffer()
|
||||||
|
{
|
||||||
|
return m_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Internally used to perform copies of the atom.
|
* \brief Internally used to perform copies of the atom.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue