MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / SetString

Function SetString

native/thirdpart/flatbuffers/reflection.cpp:307–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305};
306
307void SetString(const reflection::Schema &schema, const std::string &val,
308 const String *str, std::vector<uint8_t> *flatbuf,
309 const reflection::Object *root_table) {
310 auto delta = static_cast<int>(val.size()) - static_cast<int>(str->size());
311 auto str_start = static_cast<uoffset_t>(
312 reinterpret_cast<const uint8_t *>(str) - vector_data(*flatbuf));
313 auto start = str_start + static_cast<uoffset_t>(sizeof(uoffset_t));
314 if (delta) {
315 // Clear the old string, since we don't want parts of it remaining.
316 memset(vector_data(*flatbuf) + start, 0, str->size());
317 // Different size, we must expand (or contract).
318 ResizeContext(schema, start, delta, flatbuf, root_table);
319 // Set the new length.
320 WriteScalar(vector_data(*flatbuf) + str_start,
321 static_cast<uoffset_t>(val.size()));
322 }
323 // Copy new data. Safe because we created the right amount of space.
324 memcpy(vector_data(*flatbuf) + start, val.c_str(), val.size() + 1);
325}
326
327uint8_t *ResizeAnyVector(const reflection::Schema &schema, uoffset_t newsize,
328 const VectorOfAny *vec, uoffset_t num_elems,

Callers

nothing calls this directly

Calls 5

vector_dataFunction · 0.85
ResizeContextClass · 0.85
WriteScalarFunction · 0.85
sizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected