MCPcopy Create free account
hub / github.com/catboost/catboost / main

Function main

tools/enum_parser/enum_parser/main.cpp:411–507  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409}
410
411int main(int argc, char** argv) {
412 try {
413 using namespace NLastGetopt;
414 TOpts opts = NLastGetopt::TOpts::Default();
415 opts.AddHelpOption();
416
417 TString outputFileName;
418 TString outputHeaderFileName;
419 TString outputJsonFileName;
420 TString includePath;
421 opts.AddLongOption('o', "output").OptionalArgument("<output-file>").StoreResult(&outputFileName)
422 .Help(
423 "Output generated code to specified file.\n"
424 "When not set, standard output is used."
425 );
426 opts.AddLongOption('h', "header").OptionalArgument("<output-header>").StoreResult(&outputHeaderFileName)
427 .Help(
428 "Generate appropriate header to specified file.\n"
429 "Works only if output file specified."
430 );
431 opts.AddLongOption("include-path").OptionalArgument("<header-path>").StoreResult(&includePath)
432 .Help(
433 "Include input header using this path in angle brackets.\n"
434 "When not set, header basename is used in double quotes."
435 );
436
437 opts.AddLongOption('j', "json-output").OptionalArgument("<json-output>").StoreResult(&outputJsonFileName)
438 .Help(
439 "Generate enum data in JSON format."
440 );
441
442 opts.SetFreeArgsNum(1);
443 opts.SetFreeArgTitle(0, "<input-file>", "Input header file with enum declarations");
444
445 TOptsParseResult res(&opts, argc, argv);
446
447 TVector<TString> freeArgs = res.GetFreeArgs();
448 TString inputFileName = freeArgs[0];
449
450 THolder<IOutputStream> hOut;
451 IOutputStream* out = &Cout;
452
453 THolder<IOutputStream> headerOut;
454
455 THolder<IOutputStream> jsonOut;
456
457
458 if (outputFileName) {
459 NFs::Remove(outputFileName);
460 hOut.Reset(new TFileOutput(outputFileName));
461 out = hOut.Get();
462
463 if (outputHeaderFileName) {
464 headerOut.Reset(new TFileOutput(outputHeaderFileName));
465 }
466
467 if (outputJsonFileName) {
468 jsonOut.Reset(new TFileOutput(outputJsonFileName));

Callers

nothing calls this directly

Calls 15

DefaultFunction · 0.85
OpenArrayFunction · 0.85
OutItemFunction · 0.85
FinishItemsFunction · 0.85
CloseArrayFunction · 0.85
CurrentExceptionMessageFunction · 0.85
SetFreeArgsNumMethod · 0.80
SetFreeArgTitleMethod · 0.80
WriteHeaderFunction · 0.70
GenerateEnumFunction · 0.70
TFsPathClass · 0.50
HelpMethod · 0.45

Tested by

no test coverage detected