2015-05-24 21:11:36 +00:00
|
|
|
// Copyright (c) 2005-2015 Jay Berkenbilt
|
2008-04-29 12:55:25 +00:00
|
|
|
//
|
|
|
|
// This file is part of qpdf. This software may be distributed under
|
|
|
|
// the terms of version 2 of the Artistic License which may be found
|
|
|
|
// in the source distribution. It is provided "as is" without express
|
|
|
|
// or implied warranty.
|
|
|
|
|
|
|
|
#ifndef __PL_BUFFER_HH__
|
|
|
|
#define __PL_BUFFER_HH__
|
|
|
|
|
|
|
|
// This pipeline accumulates the data passed to it into a memory
|
|
|
|
// buffer. Each subsequent use of this buffer appends to the data
|
|
|
|
// accumulated so far. getBuffer() may be called only after calling
|
|
|
|
// finish() and before calling any subsequent write(). At that point,
|
|
|
|
// a dynamically allocated Buffer object is returned and the internal
|
2009-02-21 02:54:31 +00:00
|
|
|
// buffer is reset. The caller is responsible for deleting the
|
2008-04-29 12:55:25 +00:00
|
|
|
// returned Buffer.
|
|
|
|
//
|
|
|
|
// For this pipeline, "next" may be null. If a next pointer is
|
|
|
|
// provided, this pipeline will also pass the data through to it.
|
|
|
|
|
|
|
|
#include <qpdf/Pipeline.hh>
|
|
|
|
#include <qpdf/PointerHolder.hh>
|
|
|
|
#include <qpdf/Buffer.hh>
|
|
|
|
#include <list>
|
|
|
|
|
2009-10-21 00:27:24 +00:00
|
|
|
class Pl_Buffer: public Pipeline
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2008-04-29 12:55:25 +00:00
|
|
|
Pl_Buffer(char const* identifier, Pipeline* next = 0);
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2008-04-29 12:55:25 +00:00
|
|
|
virtual ~Pl_Buffer();
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2012-06-20 15:20:57 +00:00
|
|
|
virtual void write(unsigned char*, size_t);
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2008-04-29 12:55:25 +00:00
|
|
|
virtual void finish();
|
|
|
|
|
|
|
|
// Each call to getBuffer() resets this object -- see notes above.
|
|
|
|
// The caller is responsible for deleting the returned Buffer
|
|
|
|
// object.
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2008-04-29 12:55:25 +00:00
|
|
|
Buffer* getBuffer();
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool ready;
|
|
|
|
std::list<PointerHolder<Buffer> > data;
|
|
|
|
size_t total_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __PL_BUFFER_HH__
|