2011-04-30 19:19:30 +00:00
|
|
|
// Copyright (c) 2005-2011 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_COUNT_HH__
|
|
|
|
#define __PL_COUNT_HH__
|
|
|
|
|
|
|
|
// This pipeline is reusable; i.e., it is safe to call write() after
|
|
|
|
// calling finish().
|
|
|
|
|
|
|
|
#include <qpdf/Pipeline.hh>
|
2012-06-20 15:20:57 +00:00
|
|
|
#include <qpdf/Types.h>
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2009-10-21 00:27:24 +00:00
|
|
|
class Pl_Count: 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_Count(char const* identifier, Pipeline* next);
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2008-04-29 12:55:25 +00:00
|
|
|
virtual ~Pl_Count();
|
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();
|
|
|
|
// Returns the number of bytes written
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2012-06-20 15:20:57 +00:00
|
|
|
off_t getCount() const;
|
2008-04-29 12:55:25 +00:00
|
|
|
// Returns the last character written, or '\0' if no characters
|
|
|
|
// have been written (in which case getCount() returns 0)
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2008-04-29 12:55:25 +00:00
|
|
|
unsigned char getLastChar() const;
|
|
|
|
|
|
|
|
private:
|
2012-06-20 15:20:57 +00:00
|
|
|
off_t count;
|
2008-04-29 12:55:25 +00:00
|
|
|
unsigned char last_char;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __PL_COUNT_HH__
|