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

Method AddField

contrib/libs/flatbuffers/src/idl_parser.cpp:875–897  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

873}
874
875CheckedError Parser::AddField(StructDef &struct_def, const std::string &name,
876 const Type &type, FieldDef **dest) {
877 auto &field = *new FieldDef();
878 field.value.offset =
879 FieldIndexToOffset(static_cast<voffset_t>(struct_def.fields.vec.size()));
880 field.name = name;
881 field.file = struct_def.file;
882 field.value.type = type;
883 if (struct_def.fixed) { // statically compute the field offset
884 auto size = InlineSize(type);
885 auto alignment = InlineAlignment(type);
886 // structs_ need to have a predictable format, so we need to align to
887 // the largest scalar
888 struct_def.minalign = std::max(struct_def.minalign, alignment);
889 struct_def.PadLastField(alignment);
890 field.value.offset = static_cast<voffset_t>(struct_def.bytesize);
891 struct_def.bytesize += size;
892 }
893 if (struct_def.fields.Add(name, &field))
894 return Error("field already exists: " + name);
895 *dest = &field;
896 return NoError();
897}
898
899CheckedError Parser::ParseField(StructDef &struct_def) {
900 std::string name = attribute_;

Callers

nothing calls this directly

Calls 9

InlineSizeFunction · 0.85
InlineAlignmentFunction · 0.85
NoErrorFunction · 0.85
PadLastFieldMethod · 0.80
ErrorFunction · 0.70
FieldIndexToOffsetFunction · 0.50
maxFunction · 0.50
sizeMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected