MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / String

Function String

Libs/flatbuffers/flexbuffers.h:1029–1046  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1027 size_t Key(const std::string &str) { return Key(str.c_str(), str.size()); }
1028
1029 size_t String(const char *str, size_t len) {
1030 auto reset_to = buf_.size();
1031 auto sloc = CreateBlob(str, len, 1, FBT_STRING);
1032 if (flags_ & BUILDER_FLAG_SHARE_STRINGS) {
1033 StringOffset so(sloc, len);
1034 auto it = string_pool.find(so);
1035 if (it != string_pool.end()) {
1036 // Already in the buffer. Remove string we just serialized, and use
1037 // existing offset instead.
1038 buf_.resize(reset_to);
1039 sloc = it->first;
1040 stack_.back().u_ = sloc;
1041 } else {
1042 string_pool.insert(so);
1043 }
1044 }
1045 return sloc;
1046 }
1047 size_t String(const char *str) { return String(str, strlen(str)); }
1048 size_t String(const std::string &str) {
1049 return String(str.c_str(), str.size());

Callers 3

EmptyStringMethod · 0.70
AsStringMethod · 0.70
AddFunction · 0.70

Calls 9

CreateBlobFunction · 0.85
lengthMethod · 0.80
KeyFunction · 0.70
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
resizeMethod · 0.45
insertMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected