MCPcopy Create free account
hub / github.com/defold/defold / ReadStringField

Method ReadStringField

engine/ddf/src/ddf/ddf_message.cpp:79–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77 #undef READSCALARFIELD_CASE
78
79 Result Message::ReadStringField(LoadContext* load_context,
80 WireType wire_type,
81 const FieldDescriptor* field,
82 InputBuffer* input_buffer)
83 {
84 if (wire_type != WIRETYPE_LENGTH_DELIMITED)
85 {
86 return RESULT_WIRE_FORMAT_ERROR;
87 }
88
89 uint32_t length;
90 if (!input_buffer->ReadVarInt32(&length))
91 {
92 return RESULT_WIRE_FORMAT_ERROR;
93 }
94
95 const char* str_buf;
96 if (input_buffer->Read(length, &str_buf))
97 {
98 if (field->m_Label == LABEL_REPEATED)
99 {
100 AddString(load_context, field, str_buf, length);
101 }
102 else
103 {
104 SetString(load_context, field, str_buf, length);
105 }
106 return RESULT_OK;
107 }
108 else
109 {
110 return RESULT_WIRE_FORMAT_ERROR;
111 }
112 }
113
114 Result Message::ReadBytesField(LoadContext* load_context,
115 WireType wire_type,

Callers

nothing calls this directly

Calls 4

AddStringFunction · 0.85
SetStringFunction · 0.85
ReadVarInt32Method · 0.80
ReadMethod · 0.80

Tested by

no test coverage detected