Esempio n. 1
0
template <typename Iter, typename Traits> NEXTWEB_INLINE typename StreamBuffer<Iter, Traits>::PosType
StreamBuffer<Iter, Traits>::seekoff(typename StreamBuffer<Iter, Traits>::OffType off, std::ios::seekdir dir, std::ios::openmode which) {
	
	if (!(which & std::ios::in)) {
		return BAD_POSITION;
	}		
	
	DistanceType size = std::distance(begin_, end_);
	DistanceType dist = static_cast<DistanceType>(off);
	DistanceType position = static_cast<DistanceType>(-1);
	
	if ((std::ios::beg == dir) && (dist >= 0) && (dist < size)) {
		position = dist;
	}
	else if ((std::ios::end == dir) && (dist >= 0) && (dist < size)) {
		position = size - dist;
	}
	else if (std::ios::cur == dir) {
		position = std::distance(begin_, current_) - static_cast<DistanceType>(egptr() - gptr()) + dist;
		if ((position < 0) || (position >= size)) {
			return BAD_POSITION;
		}
	}
	if (static_cast<DistanceType>(-1) != position) {
		current_ = begin_;
		std::advance(current_, position);
		fill();
		return static_cast<PosType>(position);
	}
	return BAD_POSITION;
}
Esempio n. 2
0
template <typename Iter, typename Traits> NEXTWEB_INLINE typename StreamBuffer<Iter, Traits>::IntType
StreamBuffer<Iter, Traits>::underflow() {
	assert(gptr() == egptr());
	if (end_ == current_) {
		return Traits::eof();
	}
	return fill();
}
Esempio n. 3
0
template <typename Iter, typename Traits> NEXTWEB_INLINE typename StreamBuffer<Iter, Traits>::IntType
StreamBuffer<Iter, Traits>::pbackfail(typename StreamBuffer<Iter, Traits>::IntType value) {
	assert(gptr() == eback());
	if (begin_ == current_) {
		return Traits::eof();
	}
	--current_;
	DistanceType dist = static_cast<DistanceType>(egptr() - eback());
	memmove(buffer_ + 1, buffer_, dist - 1);
	buffer_[0] = value;
	return Traits::to_int_type(value);
}
Esempio n. 4
0
template <typename Iter, typename Traits> NEXTWEB_INLINE std::streamsize
StreamBuffer<Iter, Traits>::showmanyc() {
	assert(gptr() == egptr());
	DistanceType dist = std::distance(current_, end_);
	return (0 == dist) ? static_cast<std::streamsize>(-1) : static_cast<std::streamsize>(dist);
}