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

Method BuildString

contrib/libs/flatbuffers/src/binary_annotator.cpp:973–1034  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

971}
972
973void BinaryAnnotator::BuildString(const uint64_t string_offset,
974 const reflection::Object *const table,
975 const reflection::Field *const field) {
976 // Check if we have already generated this string section, and this is a
977 // shared string instance.
978 if (ContainsSection(string_offset)) { return; }
979
980 std::vector<BinaryRegion> regions;
981 const auto string_length = ReadScalar<uint32_t>(string_offset);
982
983 BinaryRegionComment string_length_comment;
984 string_length_comment.type = BinaryRegionCommentType::StringLength;
985
986 if (!string_length.has_value()) {
987 const uint64_t remaining = RemainingBytes(string_offset);
988
989 SetError(string_length_comment, BinaryRegionStatus::ERROR_INCOMPLETE_BINARY,
990 "4");
991
992 regions.push_back(MakeBinaryRegion(string_offset, remaining,
993 BinaryRegionType::Unknown, remaining, 0,
994 string_length_comment));
995
996 } else {
997 const uint32_t string_size = string_length.value();
998 const uint64_t string_end =
999 string_offset + sizeof(uint32_t) + string_size + sizeof(char);
1000
1001 if (!IsValidOffset(string_end - 1)) {
1002 SetError(string_length_comment,
1003 BinaryRegionStatus::ERROR_LENGTH_TOO_LONG);
1004
1005 regions.push_back(MakeBinaryRegion(string_offset, sizeof(uint32_t),
1006 BinaryRegionType::Uint32, 0, 0,
1007 string_length_comment));
1008 } else {
1009 regions.push_back(MakeBinaryRegion(string_offset, sizeof(uint32_t),
1010 BinaryRegionType::Uint32, 0, 0,
1011 string_length_comment));
1012
1013 BinaryRegionComment string_comment;
1014 string_comment.type = BinaryRegionCommentType::StringValue;
1015
1016 regions.push_back(MakeBinaryRegion(string_offset + sizeof(uint32_t),
1017 string_size, BinaryRegionType::Char,
1018 string_size, 0, string_comment));
1019
1020 BinaryRegionComment string_terminator_comment;
1021 string_terminator_comment.type =
1022 BinaryRegionCommentType::StringTerminator;
1023
1024 regions.push_back(MakeBinaryRegion(
1025 string_offset + sizeof(uint32_t) + string_size, sizeof(char),
1026 BinaryRegionType::Char, 0, 0, string_terminator_comment));
1027 }
1028 }
1029
1030 AddSection(string_offset,

Callers

nothing calls this directly

Calls 10

SetErrorFunction · 0.85
MakeBinaryRegionFunction · 0.85
MakeBinarySectionFunction · 0.85
stringClass · 0.50
moveFunction · 0.50
has_valueMethod · 0.45
push_backMethod · 0.45
valueMethod · 0.45
c_strMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected