MCPcopy Create free account
hub / github.com/cloudwego/dynamicgo / ReadBaseTypeWithDesc

Method ReadBaseTypeWithDesc

proto/binary/binary.go:1136–1250  ·  view source on GitHub ↗

ReadBaseType with desc, not thread safe

(desc *proto.TypeDescriptor, hasMessageLen bool, copyString bool, disallowUnknown bool, useFieldName bool)

Source from the content-addressed store, hash-verified

1134
1135// ReadBaseType with desc, not thread safe
1136func (p *BinaryProtocol) ReadBaseTypeWithDesc(desc *proto.TypeDescriptor, hasMessageLen bool, copyString bool, disallowUnknown bool, useFieldName bool) (interface{}, error) {
1137 switch desc.Type() {
1138 case proto.BOOL:
1139 v, e := p.ReadBool()
1140 return v, e
1141 case proto.ENUM:
1142 v, e := p.ReadEnum()
1143 return v, e
1144 case proto.INT32:
1145 v, e := p.ReadInt32()
1146 return v, e
1147 case proto.SINT32:
1148 v, e := p.ReadSint32()
1149 return v, e
1150 case proto.UINT32:
1151 v, e := p.ReadUint32()
1152 return v, e
1153 case proto.FIX32:
1154 v, e := p.ReadFixed32()
1155 return v, e
1156 case proto.SFIX32:
1157 v, e := p.ReadSfixed32()
1158 return v, e
1159 case proto.INT64:
1160 v, e := p.ReadInt64()
1161 return v, e
1162 case proto.SINT64:
1163 v, e := p.ReadInt64()
1164 return v, e
1165 case proto.UINT64:
1166 v, e := p.ReadUint64()
1167 return v, e
1168 case proto.FIX64:
1169 v, e := p.ReadFixed64()
1170 return v, e
1171 case proto.SFIX64:
1172 v, e := p.ReadSfixed64()
1173 return v, e
1174 case proto.FLOAT:
1175 v, e := p.ReadFloat()
1176 return v, e
1177 case proto.DOUBLE:
1178 v, e := p.ReadDouble()
1179 return v, e
1180 case proto.STRING:
1181 v, e := p.ReadString(copyString)
1182 return v, e
1183 case proto.BYTE:
1184 v, e := p.ReadBytes()
1185 return v, e
1186 case proto.MESSAGE:
1187 messageLength := len(p.Buf) - p.Read
1188 if hasMessageLen {
1189 length, messageLengthErr := p.ReadLength()
1190 if messageLengthErr != nil {
1191 return nil, messageLengthErr
1192 }
1193 if length == 0 {

Callers 3

ReadListMethod · 0.95
ReadPairMethod · 0.95
ReadAnyWithDescMethod · 0.95

Calls 15

ReadBoolMethod · 0.95
ReadEnumMethod · 0.95
ReadInt32Method · 0.95
ReadSint32Method · 0.95
ReadUint32Method · 0.95
ReadFixed32Method · 0.95
ReadSfixed32Method · 0.95
ReadInt64Method · 0.95
ReadUint64Method · 0.95
ReadFixed64Method · 0.95
ReadSfixed64Method · 0.95
ReadFloatMethod · 0.95

Tested by

no test coverage detected