1 #ifndef ossimBlockStreamBuffer_HEADER 2 #define ossimBlockStreamBuffer_HEADER 1 38 if(m_blockSize&&m_blockBufferPtr&&(pos>=0))
40 result = pos/m_blockSize;
55 return (m_blockLoaded&&
57 (pos<(m_startByte+m_blockSize)));
69 return (m_blockLoaded&&
81 if(m_validSize>=0)
return m_startByte+(m_validSize);
92 if(isWithinValidWindow(absolutePosition))
94 return m_blockBufferPtr+(absolutePosition-m_startByte);
104 return m_blockBufferPtr;
111 return m_blockBufferPtr;
129 m_blockBufferPtr = bufPtr;
130 m_blockSize = blockSize;
131 m_blockLoaded =
false;
205 virtual std::streambuf* setbuf (
char* s, std::streamsize
n);
228 virtual pos_type seekoff(off_type offset, std::ios_base::seekdir dir,
229 std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out);
242 virtual pos_type seekpos(pos_type pos,
243 std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out);
257 virtual std::streamsize xsgetn(char_type* s, std::streamsize
n);
267 virtual int underflow();
279 void syncCurrentPosition();
std::vector< char > m_blockBuffer
The block buffer that we set the buf pointers to.
ossim_int64 m_blockSize
Is the size of the buffer.
ossim_int64 m_startByte
Is the starting absolute byte offset for the buffer.
bool m_blockLoaded
Variable used to invalidate a block or specify whether the block is loaded.
char * m_blockBufferPtr
Starting address of the block.
This code was derived from https://gist.github.com/mshockwave.
ossim_int64 m_currentPosValue
holds the current absolute byte position
ossim_int64 m_validSize
is the valid size of the buffer.
bool isWithinWindow(ossim_int64 pos) const
This just tests if the given abolute position is within a block window.
ossim_int64 getBlockIndex(ossim_int64 pos)
Returns the index of a block.
This is a utility class used by the BlockStreamBuffer.
os2<< "> n<< " > nendobj n
ossim_int64 getEndByte() const
Convenient method to get the absolute byte position of the end byte.
unsigned long long ossim_uint64
unsigned int ossim_uint32
virtual ~BlockStreamBuffer()
const char * getBuffer() const
bool isWithinValidWindow(ossim_int64 pos) const
This just tests if the given abolute position is within a valid window.
const char * getBufferStart(ossim_int64 absolutePosition) const
Get the starting address in the buffer of the absolute position.
std::basic_istream< char > istream
Base class for char input streams.
void setBuffer(char *bufPtr, ossim_uint32 blockSize)
Will set the buffer and then reset the loaded flag to be false.
ossim::istream * m_adaptStream
The stream we are adapting.
This is the BlockStreamBuffer class and derives from stream buf.
BlockBufInfo m_blockInfo
Holds the information about the block.