| 106 | }; |
| 107 | |
| 108 | int main(int argc, char* argv[]) { |
| 109 | if (argc != 2) { |
| 110 | fprintf(stderr, "filterkey key < input.json > output.json\n"); |
| 111 | return 1; |
| 112 | } |
| 113 | |
| 114 | // Prepare JSON reader and input stream. |
| 115 | Reader reader; |
| 116 | char readBuffer[65536]; |
| 117 | FileReadStream is(stdin, readBuffer, sizeof(readBuffer)); |
| 118 | |
| 119 | // Prepare JSON writer and output stream. |
| 120 | char writeBuffer[65536]; |
| 121 | FileWriteStream os(stdout, writeBuffer, sizeof(writeBuffer)); |
| 122 | Writer<FileWriteStream> writer(os); |
| 123 | |
| 124 | // Prepare Filter |
| 125 | FilterKeyHandler<Writer<FileWriteStream> > filter(writer, argv[1], static_cast<SizeType>(strlen(argv[1]))); |
| 126 | |
| 127 | // JSON reader parse from the input stream, filter handler filters the events, and forward to writer. |
| 128 | // i.e. the events flow is: reader -> filter -> writer |
| 129 | if (!reader.Parse(is, filter)) { |
| 130 | fprintf(stderr, "\nError(%u): %s\n", static_cast<unsigned>(reader.GetErrorOffset()), GetParseError_En(reader.GetParseErrorCode())); |
| 131 | return 1; |
| 132 | } |
| 133 | |
| 134 | return 0; |
| 135 | } |
nothing calls this directly
no test coverage detected