2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 19:08:59 +00:00
qpdf/libtests/json_parse.cc
Jay Berkenbilt 12f1eb15ca Programmatically apply new formatting to code
Run this:

for i in  **/*.cc **/*.c **/*.h **/*.hh; do
  clang-format < $i >| $i.new && mv $i.new $i
done
2022-04-04 08:10:40 -04:00

25 lines
624 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;
}