MCPcopy Create free account
hub / github.com/cinemast/libjson-rpc-cpp / createStubGenerators

Method createStubGenerators

src/stubgenerator/stubgeneratorfactory.cpp:24–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22using namespace std;
23
24bool StubGeneratorFactory::createStubGenerators(int argc, char **argv, vector<Procedure> &procedures, vector<StubGenerator *> &stubgenerators, FILE *_stdout,
25 FILE *_stderr) {
26 struct arg_file *inputfile = arg_file0(NULL, NULL, "<specfile>", "path of input specification file");
27 struct arg_lit *help = arg_lit0("h", "help", "print this help and exit");
28 struct arg_lit *version = arg_lit0(NULL, "version", "print version and exit");
29 struct arg_lit *verbose = arg_lit0("v", "verbose", "print more information about what is happening");
30 struct arg_str *cppserver = arg_str0(NULL, "cpp-server", "<namespace::classname>", "name of the C++ server stub class");
31 struct arg_str *cppserverfile = arg_str0(NULL, "cpp-server-file", "<filename.h>", "name of the C++ server stub file");
32 struct arg_str *cppclient = arg_str0(NULL, "cpp-client", "<namespace::classname>", "name of the C++ client stub class");
33 struct arg_str *cppclientfile = arg_str0(NULL, "cpp-client-file", "<filename.h>", "name of the C++ client stub file");
34 struct arg_str *jsclient = arg_str0(NULL, "js-client", "<classname>", "name of the JavaScript client stub class");
35 struct arg_str *jsclientfile = arg_str0(NULL, "js-client-file", "<filename.js>", "name of the JavaScript client stub file");
36 struct arg_str *pyclient = arg_str0(NULL, "py-client", "<classname>", "name of the Python client stub class");
37 struct arg_str *pyclientfile = arg_str0(NULL, "py-client-file", "<filename.py>", "name of the Python client stub file");
38
39 struct arg_end *end = arg_end(20);
40 void *argtable[] = {inputfile, help, version, verbose, cppserver, cppserverfile, cppclient, cppclientfile,
41 jsclient, jsclientfile, pyclient, pyclientfile, end};
42
43 if (arg_parse(argc, argv, argtable) > 0) {
44 arg_print_errors(_stderr, end, argv[0]);
45 arg_freetable(argtable, sizeof(argtable) / sizeof(argtable[0]));
46 return false;
47 }
48
49 if (help->count > 0) {
50 fprintf(_stdout, "Usage: %s ", argv[0]);
51 arg_print_syntax(_stdout, argtable, "\n");
52 cout << endl;
53 arg_print_glossary_gnu(_stdout, argtable);
54 arg_freetable(argtable, sizeof(argtable) / sizeof(argtable[0]));
55 return true;
56 }
57
58 if (version->count > 0) {
59 fprintf(_stdout, "jsonrpcstub version %d.%d.%d\n", JSONRPC_CPP_MAJOR_VERSION, JSONRPC_CPP_MINOR_VERSION, JSONRPC_CPP_PATCH_VERSION);
60 arg_freetable(argtable, sizeof(argtable) / sizeof(argtable[0]));
61 return true;
62 }
63
64 if (inputfile->count == 0) {
65 fprintf(_stderr, "Invalid arguments: specfile must be provided.\n");
66 arg_freetable(argtable, sizeof(argtable) / sizeof(argtable[0]));
67 return false;
68 }
69
70 try {
71 procedures = SpecificationParser::GetProceduresFromFile(inputfile->filename[0]);
72 if (verbose->count > 0) {
73 fprintf(_stdout, "Found %zu procedures in %s\n", procedures.size(), inputfile->filename[0]);
74 for (unsigned int i = 0; i < procedures.size(); ++i) {
75 if (procedures.at(i).GetProcedureType() == RPC_METHOD) {
76 fprintf(_stdout, "\t[Method] ");
77 } else {
78 fprintf(_stdout, "\t[Notification] ");
79 }
80 fprintf(_stdout, "%s\n", procedures.at(i).GetProcedureName().c_str());
81 }

Callers

nothing calls this directly

Calls 6

arg_endClass · 0.85
sizeMethod · 0.80
GetProcedureTypeMethod · 0.80
c_strMethod · 0.80
GetProcedureNameMethod · 0.80
whatMethod · 0.45

Tested by

no test coverage detected