| 413 | } |
| 414 | |
| 415 | void 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 | } |
nothing calls this directly
no test coverage detected