OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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

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  }
Ogre::DataStream::DataStream ( const DataStream )
delete

Member Function Documentation

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

Definition at line 38 of file StdMeshLoaderDataStream.h.

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

38 { return end - cursor; }

Here is the caller graph for this function:

DataStream& Ogre::DataStream::operator= ( const DataStream )
delete
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.

References GetRemainingBytes().

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T >
std::enable_if<!std::is_pod<T>::value, T>::type Ogre::DataStream::Peek ( ) const
void Ogre::DataStream::Peek ( void *  dest,
size_t  size 
) const
inline

Definition at line 71 of file StdMeshLoaderDataStream.h.

References GetRemainingBytes().

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

Here is the call graph for this function:

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  }
size_t GetRemainingBytes() const
template<class T >
T Ogre::DataStream::Read ( )
inline

Definition at line 65 of file StdMeshLoaderDataStream.h.

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().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 77 of file StdMeshLoaderDataStream.h.

References Peek().

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

Here is the call graph for this function:

void Ogre::DataStream::Rewind ( )
inline

Definition at line 39 of file StdMeshLoaderDataStream.h.

39 { cursor = begin; }
void Ogre::DataStream::Seek ( ptrdiff_t  offset)
inline

Definition at line 40 of file StdMeshLoaderDataStream.h.

References GetRemainingBytes().

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

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  }
size_t GetRemainingBytes() const

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: