MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / operator+=

Method operator+=

native/thirdpart/flatbuffers/code_generators.cpp:33–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31namespace flatbuffers {
32
33void CodeWriter::operator+=(std::string text) {
34 if (!ignore_ident_ && !text.empty()) AppendIdent(stream_);
35
36 while (true) {
37 auto begin = text.find("{{");
38 if (begin == std::string::npos) { break; }
39
40 auto end = text.find("}}");
41 if (end == std::string::npos || end < begin) { break; }
42
43 // Write all the text before the first {{ into the stream.
44 stream_.write(text.c_str(), begin);
45
46 // The key is between the {{ and }}.
47 const std::string key = text.substr(begin + 2, end - begin - 2);
48
49 // Find the value associated with the key. If it exists, write the
50 // value into the stream, otherwise write the key itself into the stream.
51 auto iter = value_map_.find(key);
52 if (iter != value_map_.end()) {
53 const std::string &value = iter->second;
54 stream_ << value;
55 } else {
56 FLATBUFFERS_ASSERT(false && "could not find key");
57 stream_ << key;
58 }
59
60 // Update the text to everything after the }}.
61 text = text.substr(end + 2);
62 }
63 if (!text.empty() && string_back(text) == '\\') {
64 text.pop_back();
65 ignore_ident_ = true;
66 stream_ << text;
67 } else {
68 ignore_ident_ = false;
69 stream_ << text << std::endl;
70 }
71}
72
73void CodeWriter::AppendIdent(std::stringstream &stream) {
74 int lvl = cur_ident_lvl_;

Callers

nothing calls this directly

Calls 6

string_backFunction · 0.85
emptyMethod · 0.80
writeMethod · 0.80
pop_backMethod · 0.80
c_strMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected