mirror of
https://github.com/qpdf/qpdf.git
synced 2024-11-16 01:27:07 +00:00
76bf91765e
git-svn-id: svn+q:///qpdf/trunk@607 71b93d88-0707-0410-a8cf-f5a4172ac649
63 lines
1.4 KiB
C++
63 lines
1.4 KiB
C++
|
|
#include <qpdf/Pl_Buffer.hh>
|
|
#include <qpdf/Pl_Count.hh>
|
|
#include <qpdf/Pl_Discard.hh>
|
|
#include <stdlib.h>
|
|
|
|
typedef unsigned char* uc;
|
|
|
|
int main()
|
|
{
|
|
try
|
|
{
|
|
Pl_Discard discard;
|
|
Pl_Count count("count", &discard);
|
|
Pl_Buffer bp1("bp1", &count);
|
|
bp1.write((uc)"12345", 5);
|
|
bp1.write((uc)"67890", 5);
|
|
bp1.finish();
|
|
std::cout << "count: " << count.getCount() << std::endl;
|
|
bp1.write((uc)"abcde", 5);
|
|
bp1.write((uc)"fghij", 6);
|
|
bp1.finish();
|
|
std::cout << "count: " << count.getCount() << std::endl;
|
|
Buffer* b = bp1.getBuffer();
|
|
std::cout << "size: " << b->getSize() << std::endl;
|
|
std::cout << "data: " << b->getBuffer() << std::endl;
|
|
delete b;
|
|
bp1.write((uc)"qwert", 5);
|
|
bp1.write((uc)"yuiop", 6);
|
|
bp1.finish();
|
|
std::cout << "count: " << count.getCount() << std::endl;
|
|
b = bp1.getBuffer();
|
|
std::cout << "size: " << b->getSize() << std::endl;
|
|
std::cout << "data: " << b->getBuffer() << std::endl;
|
|
delete b;
|
|
|
|
Pl_Buffer bp2("bp2");
|
|
bp2.write((uc)"moo", 3);
|
|
bp2.write((uc)"quack", 6);
|
|
try
|
|
{
|
|
delete bp2.getBuffer();
|
|
}
|
|
catch (std::exception& e)
|
|
{
|
|
std::cout << e.what() << std::endl;
|
|
}
|
|
bp2.finish();
|
|
b = bp2.getBuffer();
|
|
std::cout << "size: " << b->getSize() << std::endl;
|
|
std::cout << "data: " << b->getBuffer() << std::endl;
|
|
delete b;
|
|
}
|
|
catch (std::exception& e)
|
|
{
|
|
std::cout << "unexpected exception: " << e.what() << std::endl;
|
|
exit(2);
|
|
}
|
|
|
|
std::cout << "done" << std::endl;
|
|
return 0;
|
|
}
|