| 138 | }; |
| 139 | |
| 140 | int main(int argc, char* argv[]) { |
| 141 | if (argc != 2) { |
| 142 | fprintf(stderr, "filterkeydom key < input.json > output.json\n"); |
| 143 | return 1; |
| 144 | } |
| 145 | |
| 146 | // Prepare input stream. |
| 147 | char readBuffer[65536]; |
| 148 | FileReadStream is(stdin, readBuffer, sizeof(readBuffer)); |
| 149 | |
| 150 | // Prepare Filter |
| 151 | FilterKeyReader<FileReadStream> reader(is, argv[1], static_cast<SizeType>(strlen(argv[1]))); |
| 152 | |
| 153 | // Populates the filtered events from reader |
| 154 | Document document; |
| 155 | document.Populate(reader); |
| 156 | ParseResult pr = reader.GetParseResult(); |
| 157 | if (!pr) { |
| 158 | fprintf(stderr, "\nError(%u): %s\n", static_cast<unsigned>(pr.Offset()), GetParseError_En(pr.Code())); |
| 159 | return 1; |
| 160 | } |
| 161 | |
| 162 | // Prepare JSON writer and output stream. |
| 163 | char writeBuffer[65536]; |
| 164 | FileWriteStream os(stdout, writeBuffer, sizeof(writeBuffer)); |
| 165 | Writer<FileWriteStream> writer(os); |
| 166 | |
| 167 | // Write the document to standard output |
| 168 | document.Accept(writer); |
| 169 | return 0; |
| 170 | } |