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

Method Parse

tools/enum_parser/parse_enum/parse_enum.cpp:415–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

413}
414
415void TEnumParser::Parse(const char* dataIn, size_t lengthIn) {
416 TMemoryInput mi(dataIn, lengthIn);
417
418 TString line;
419 TString result;
420
421 while (mi.ReadLine(line)) {
422 if (line.find("if (GetOwningArena() == other->GetOwningArena()) {") == TString::npos) {
423 result += line;
424 result += "\n";
425 }
426 }
427
428 const char* data = result.c_str();
429 size_t length = result.length();
430
431 const TStringBuf span(data, length);
432 const bool hasPragmaOnce = span.Contains("#pragma once");
433 const bool isProtobufHeader = span.Contains("// Generated by the protocol buffer compiler");
434 const bool isFlatbuffersHeader = span.Contains("// automatically generated by the FlatBuffers compiler");
435 Y_ENSURE(
436 hasPragmaOnce || isProtobufHeader || isFlatbuffersHeader,
437 "Serialization functions can be generated only for enums in header files. "
438 "A valid header should either contain `#pragma once` or be an protobuf/flatbuf autogenerated header file. "
439 "See SEARCH-975 for more information. "
440 );
441 TCppContext cppContext(data, SourceFileName);
442 TMemoryInput in(data, length);
443 TCppSaxParser parser(&cppContext);
444 TransferData(&in, &parser);
445 parser.Finish();
446 // obtain result
447 Enums = cppContext.Enums;
448 if (cppContext.Scope) {
449 cppContext.PrintEnums();
450 cppContext.PrintScope();
451 ythrow yexception() << "Unbalanced scope, something is wrong with enum parser. ";
452 }
453}

Callers

nothing calls this directly

Calls 9

TransferDataFunction · 0.85
PrintEnumsMethod · 0.80
PrintScopeMethod · 0.80
ReadLineMethod · 0.45
findMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45
ContainsMethod · 0.45
FinishMethod · 0.45

Tested by

no test coverage detected