OpenClonk
Ogre::DataStream Class Reference

#include <StdMeshLoaderDataStream.h>

Public Member Functions

 DataStream (const char *src, size_t length)
 
 DataStream (const DataStream &)=delete
 
DataStreamoperator= (const DataStream &)=delete
 
bool AtEof () const
 
size_t GetRemainingBytes () const
 
void Rewind ()
 
void Seek (ptrdiff_t offset)
 
template<class T >
std::enable_if< std::is_pod< T >::value &&!std::is_pointer< T >::value, T >::type Peek () const
 
template<class T >
std::enable_if<!std::is_pod< T >::value, T >::type Peek () const
 
template<class T >
Read ()
 
void Peek (void *dest, size_t size) const
 
void Read (void *dest, size_t size)
 
template<>
bool Peek () const
 

Detailed Description

Definition at line 23 of file StdMeshLoaderDataStream.h.

Constructor & Destructor Documentation

◆ DataStream() [1/2]

Ogre::DataStream::DataStream ( const char *  src,
size_t  length 
)
inline

Definition at line 27 of file StdMeshLoaderDataStream.h.

28  {
29  begin = cursor = src;
30  end = cursor + length;
31  }

◆ DataStream() [2/2]

Ogre::DataStream::DataStream ( const DataStream )
delete

Member Function Documentation

◆ AtEof()

bool Ogre::DataStream::AtEof ( ) const
inline

◆ GetRemainingBytes()

size_t Ogre::DataStream::GetRemainingBytes ( ) const
inline

Definition at line 38 of file StdMeshLoaderDataStream.h.

38 { return end - cursor; }

Referenced by Peek(), Ogre::Mesh::Chunk::Read(), Ogre::Skeleton::Chunk::Read(), and Seek().

Here is the caller graph for this function:

◆ operator=()

DataStream& Ogre::DataStream::operator= ( const DataStream )
delete

◆ Peek() [1/4]

template<class T >
std::enable_if<std::is_pod<T>::value && !std::is_pointer<T>::value, T>::type Ogre::DataStream::Peek ( ) const
inline

Definition at line 52 of file StdMeshLoaderDataStream.h.

53  {
54  if (GetRemainingBytes() < sizeof(T))
55  throw InsufficientData();
56  T temp;
57  std::memcpy(reinterpret_cast<char*>(&temp), cursor, sizeof(T));
58  return temp;
59  }
size_t GetRemainingBytes() const

References GetRemainingBytes().

Referenced by Ogre::ChunkBase< _Type >::Peek(), and Read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Peek() [2/4]

template<class T >
std::enable_if<!std::is_pod<T>::value, T>::type Ogre::DataStream::Peek ( ) const

◆ Peek() [3/4]

template<>
bool Ogre::DataStream::Peek ( ) const
inline

Definition at line 84 of file StdMeshLoaderDataStream.h.

85  {
86  if (GetRemainingBytes() < 1)
87  throw InsufficientData();
88  return *cursor != '\0';
89  }

References GetRemainingBytes().

Here is the call graph for this function:

◆ Peek() [4/4]

void Ogre::DataStream::Peek ( void *  dest,
size_t  size 
) const
inline

Definition at line 71 of file StdMeshLoaderDataStream.h.

72  {
73  if (GetRemainingBytes() < size)
74  throw InsufficientData();
75  std::memcpy(dest, cursor, size);
76  }

References GetRemainingBytes().

Here is the call graph for this function:

◆ Read() [1/2]

template<class T >
T Ogre::DataStream::Read ( )
inline

Definition at line 65 of file StdMeshLoaderDataStream.h.

66  {
67  T temp = Peek<T>();
68  Seek(sizeof(T));
69  return temp;
70  }
void Seek(ptrdiff_t offset)

References Seek().

Referenced by Ogre::Mesh::Chunk::Read(), Ogre::Skeleton::Chunk::Read(), Ogre::Mesh::ChunkFileHeader::ReadImpl(), Ogre::Mesh::ChunkMesh::ReadImpl(), Ogre::Mesh::ChunkMeshSkeletonLink::ReadImpl(), Ogre::Mesh::ChunkSubmesh::ReadImpl(), Ogre::Mesh::ChunkSubmeshOp::ReadImpl(), Ogre::Mesh::ChunkMeshBoneAssignments::ReadImpl(), Ogre::Mesh::ChunkMeshBounds::ReadImpl(), Ogre::Mesh::ChunkGeometry::ReadImpl(), Ogre::Mesh::ChunkGeometryVertexDeclElement::ReadImpl(), Ogre::Mesh::ChunkGeometryVertexBuffer::ReadImpl(), Ogre::Mesh::ChunkGeometryVertexData::ReadImpl(), Ogre::Skeleton::ChunkFileHeader::ReadImpl(), Ogre::Skeleton::ChunkBlendMode::ReadImpl(), Ogre::Skeleton::ChunkBone::ReadImpl(), Ogre::Skeleton::ChunkBoneParent::ReadImpl(), Ogre::Skeleton::ChunkAnimation::ReadImpl(), Ogre::Skeleton::ChunkAnimationBaseInfo::ReadImpl(), Ogre::Skeleton::ChunkAnimationTrack::ReadImpl(), Ogre::Skeleton::ChunkAnimationTrackKF::ReadImpl(), and Ogre::Skeleton::ChunkAnimationLink::ReadImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Read() [2/2]

void Ogre::DataStream::Read ( void *  dest,
size_t  size 
)
inline

Definition at line 77 of file StdMeshLoaderDataStream.h.

78  {
79  Peek(dest, size);
80  cursor += size;
81  }
std::enable_if< std::is_pod< T >::value &&!std::is_pointer< T >::value, T >::type Peek() const

References Peek().

Here is the call graph for this function:

◆ Rewind()

void Ogre::DataStream::Rewind ( )
inline

Definition at line 39 of file StdMeshLoaderDataStream.h.

39 { cursor = begin; }

◆ Seek()

void Ogre::DataStream::Seek ( ptrdiff_t  offset)
inline

Definition at line 40 of file StdMeshLoaderDataStream.h.

41  {
42  if (offset > 0 && GetRemainingBytes() < static_cast<size_t>(offset))
43  throw InsufficientData();
44  if (cursor - begin < -offset)
45  throw InsufficientData();
46  cursor += offset;
47  }

References GetRemainingBytes().

Referenced by Read(), Ogre::Mesh::ChunkUnknown::ReadImpl(), and Ogre::Skeleton::ChunkUnknown::ReadImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: