69 begin_(static_cast<const TByte*>(begin)),
81 begin_(static_cast<const TByte*>(begin)),
85 off_type size =
static_cast<const TByte*
>(end) -
static_cast<const TByte*
>(begin);
88 size_ =
static_cast<pos_type
>(size);
92 setstate(std::ios_base::badbit);
100size_t BinaryIMemoryBlock::doRead(
void* out,
size_t numberOfBytes)
104 setstate(std::ios_base::badbit);
111 if (position_ >= size_)
113 setstate(std::ios_base::eofbit);
116 pos_type
next = position_ + numberOfBytes;
117 if (next > size_ || next < position_)
120 numberOfBytes = size_ - position_;
122 memcpy(out, &begin_[position_], numberOfBytes);
124 return numberOfBytes;
129BinaryIMemoryBlock::pos_type BinaryIMemoryBlock::doTellg()
const
136void BinaryIMemoryBlock::doSeekg(pos_type position)
139 position_ = position;
144void BinaryIMemoryBlock::doSeekg(off_type offset, std::ios_base::seekdir direction)
148 auto seek = [
this](pos_type current, off_type offset)
152 const pos_type negoffset =
static_cast<pos_type
>(-offset);
153 if (negoffset > current)
155 setstate(std::ios_base::failbit);
158 this->position_ = current - negoffset;
162 const pos_type posoffset =
static_cast<pos_type
>(offset);
163 if (current > num::NumTraits<pos_type>::max - posoffset)
165 setstate(std::ios_base::failbit);
168 this->position_ = current + posoffset;
174 case std::ios_base::beg:
177 setstate(std::ios_base::failbit);
180 position_ =
static_cast<pos_type
>(offset);
182 case std::ios_base::cur:
183 seek(position_, offset);
185 case std::ios_base::end:
BinaryIMemoryBlock()
Construct an "empty" closed stream.
const lass::python::impl::IterNextSlot next("__next__", Py_tp_iternext)
__next__ method (iterator next)
streams, binary streams, vrmlstreams, ...
Library for Assembled Shared Sources.