view examples/Buffer/Buffer.cpp @ 41:7c8cd74023ce

Rework file layout, fix build, add README and SUPPORT
author Louis Opter <kalessin@kalessin.fr>
date Mon, 22 Mar 2010 02:08:24 +0100
parents src/examples/Buffer/Buffer.cpp@6ad68d5cb049
children
line wrap: on
line source

#include <iostream>

#include "Buffer.hpp"

StreamBufferImpl::StreamBufferImpl(void)
    : _buffer(NULL),
      _size(0)
{
}

StreamBufferImpl *      StreamBufferImpl::setbuf(char *, std::streamsize)
{
    if (s != NULL)
    {
        /*
         * We set the get pointer.
         * s is the beginning of the get sequence.
         * s is also the current position of the get pointer.
         * s + n is a pointer to the end of the get sequence.
         */
        this->setg(s, s, s + n);

        /*
         * We set the put pointer.
         * s is the beginning of the put sequence.
         * s + n is a pointer to the end of the put sequence.
         */
        this->setp(s, s + n);
    }
    return (*this);
}

virtual std::streampos  seekoff(std::streamoff off,
                                std::ios_base::seekdir way,
                                std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
{
    if (off != 0)
    {
    }

    if ((which == std::ios_base::in | std::ios_base::out)
        || (which == std::ios_base::in))
        return (this->gptr() - this->eback());

    return (this->pptr() - this->pbase());
}

int	StreamBufferImpl::sync(void)
{
    return (0);
}

int     StreamBufferImpl::underflow(void)
{
    return (EOF);
}