MCPcopy Create free account
hub / github.com/apache/brpc / decode_name

Function decode_name

src/json2pb/encode_decode.cpp:83–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83bool decode_name(const std::string& content, std::string& decoded_content) {
84 const int pattern_length = 6;
85 int begin = 0;
86 int second = 0;
87 bool convert = false;
88 for (std::string::const_iterator it = content.begin(); it < content.end(); ++it, ++second) {
89 if (*it != '_') {
90 continue;
91 }
92 int val = match_pattern(content, second);
93 if (val != -1) {
94 if (!convert) {
95 decoded_content.clear();
96 decoded_content.reserve(content.size());
97 convert = true;
98 }
99 decoded_content.append(content, begin, second - begin);
100 decoded_content.push_back(static_cast<char>(val));
101 second += pattern_length - 1;
102 begin = second + 1;
103 it += pattern_length - 1;
104 }
105 }
106 if (!convert) {
107 return false;
108 } else {
109 decoded_content.append(content, begin, second - begin);
110 return true;
111 }
112}
113
114} // namespace json2pb

Callers 3

TEST_FFunction · 0.85
JsonValueToProtoMessageFunction · 0.85
ConvertMethod · 0.85

Calls 8

match_patternFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
clearMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45
push_backMethod · 0.45

Tested by 1

TEST_FFunction · 0.68