template < class T >

class Buffer

Library: Foundation
Package: Core
Header: Poco/Buffer.h


A very simple buffer class that allocates a buffer of a given type and size in the constructor and deallocates the buffer in the destructor.

This class is useful everywhere where a temporary buffer is needed.

Member Summary

Member Functions: begin, end, operator [], resize, size


Buffer inline

    std::size_t size

Creates and allocates the Buffer.


~Buffer inline


Destroys the Buffer.

Member Functions

begin inline

T * begin();

Returns a pointer to the beginning of the buffer.

begin inline

const T * begin() const;

Returns a pointer to the beginning of the buffer.

end inline

T * end();

Returns a pointer to end of the buffer.

end inline

const T * end() const;

Returns a pointer to the end of the buffer.

operator [] inline

T & operator[] (
    std::size_t index

operator [] inline

const T & operator[] (
    std::size_t index
) const;

resize inline

void resize(
    std::size_t newSize,
    bool preserveContent = true

Resizes the buffer. If preserveContent is true, the content of the old buffer is copied over to the new buffer. NewSize can be larger or smaller than the current size, but it must not be 0.

size inline

std::size_t size() const;

Returns the size of the buffer.