Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
filterkeydom.cpp File Reference
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/filereadstream.h"
#include "rapidjson/filewritestream.h"
#include "rapidjson/error/en.h"
#include <stack>
Include dependency graph for filterkeydom.cpp:

Go to the source code of this file.

Classes

class  FilterKeyHandler< OutputHandler >
 
class  FilterKeyReader< InputStream >
 

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 140 of file filterkeydom.cpp.

140 {
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));
166
167 // Write the document to standard output
168 document.Accept(writer);
169 return 0;
170}
File byte stream for input using fread().
Wrapper of C file stream for output using fwrite().
GenericDocument & Populate(Generator &g)
Populate this document by a generator which produces SAX events.
Definition document.h:2239
JSON writer.
Definition writer.h:89
os_t os
RAPIDJSON_NAMESPACE_BEGIN const RAPIDJSON_ERROR_CHARTYPE * GetParseError_En(ParseErrorCode parseErrorCode)
Maps error code of parsing into error message.
Definition en.h:36
char ** argv
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition rapidjson.h:384
Result of parsing (wraps ParseErrorCode)
Definition error.h:106
ParseErrorCode Code() const
Get the error code.
Definition error.h:116
size_t Offset() const
Get the error offset, if IsError(), 0 otherwise.
Definition error.h:118
Here is the call graph for this function: