MCPcopy Create free account
hub / github.com/MaaXYZ/MaaFramework / clean_cr

Method clean_cr

source/MaaAdbControlUnit/Screencap/ScreencapHelper.cpp:156–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156bool ScreencapHelper::clean_cr(std::string& buffer)
157{
158 if (buffer.size() < 2) {
159 return false;
160 }
161
162 auto check = [](std::string::iterator it) {
163 return *it == '\r' && *(it + 1) == '\n';
164 };
165
166 auto scan = buffer.end();
167 for (auto it = buffer.begin(); it != buffer.end() - 1; ++it) {
168 if (check(it)) {
169 scan = it;
170 break;
171 }
172 }
173 if (scan == buffer.end()) {
174 return false;
175 }
176
177 auto last = buffer.end() - 1;
178 auto ptr = scan;
179 while (++scan != last) {
180 if (!check(scan)) {
181 *ptr = *scan;
182 ++ptr;
183 }
184 }
185 *ptr = *last;
186 ++ptr;
187 buffer.erase(ptr, buffer.end());
188 return true;
189}
190
191bool ScreencapHelper::check_head_tail(std::string_view input, std::string_view head, std::string_view tail)
192{

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected