2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-15 17:17:08 +00:00
qpdf/libtests/json_parse.cc
Jay Berkenbilt 9044a24097 PointerHolder: deprecate getPointer() and getRefcount()
Use get() and use_count() instead. Add #define
NO_POINTERHOLDER_DEPRECATION to remove deprecation markers for these
only.

This commit also removes all deprecated PointerHolder API calls from
qpdf's code except in PointerHolder's test suite, which must continue
to test the deprecated APIs.
2022-02-04 13:12:37 -05:00

28 lines
639 B
C++

#include <qpdf/JSON.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
int main(int argc, char* argv[])
{
if (argc != 2)
{
std::cerr << "Usage: json_parse file" << std::endl;
return 2;
}
char const* filename = argv[1];
try
{
PointerHolder<char> buf;
size_t size;
QUtil::read_file_into_memory(filename, buf, size);
std::string s(buf.get(), size);
std::cout << JSON::parse(s).unparse() << std::endl;
}
catch (std::exception& e)
{
std::cerr << "exception: " << filename<< ": " << e.what() << std::endl;
return 2;
}
return 0;
}