MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / strip

Method strip

common/jinja/string.cpp:163–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161 });
162}
163string string::strip(bool left, bool right, std::optional<const std::string_view> chars) {
164 static auto strip_part = [](const std::string & s, bool left, bool right, std::optional<const std::string_view> chars) -> std::string {
165 size_t start = 0;
166 size_t end = s.length();
167 auto match_char = [&chars](unsigned char c) -> bool {
168 return chars ? (*chars).find(c) != std::string::npos : isspace(c);
169 };
170 if (left) {
171 while (start < end && match_char(static_cast<unsigned char>(s[start]))) {
172 ++start;
173 }
174 }
175 if (right) {
176 while (end > start && match_char(static_cast<unsigned char>(s[end - 1]))) {
177 --end;
178 }
179 }
180 return s.substr(start, end - start);
181 };
182 if (parts.empty()) {
183 return *this;
184 }
185 if (left) {
186 for (size_t i = 0; i < parts.size(); ++i) {
187 parts[i].val = strip_part(parts[i].val, true, false, chars);
188 if (parts[i].val.empty()) {
189 // remove empty part
190 parts.erase(parts.begin() + i);
191 --i;
192 continue;
193 } else {
194 break;
195 }
196 }
197 }
198 if (right) {
199 for (size_t i = parts.size(); i-- > 0;) {
200 parts[i].val = strip_part(parts[i].val, false, true, chars);
201 if (parts[i].val.empty()) {
202 // remove empty part
203 parts.erase(parts.begin() + i);
204 continue;
205 } else {
206 break;
207 }
208 }
209 }
210 return *this;
211}
212
213} // namespace jinja

Callers 15

_set_vocab_plamoMethod · 0.80
_parse_qtype_nameMethod · 0.80
set_gguf_parametersMethod · 0.80
run_mtmd_deepseek_ocrFunction · 0.80
read_expected_outputFunction · 0.80
process_textFunction · 0.80
tts-outetts.pyFile · 0.80
test_tokenize_detokenizeFunction · 0.80
test_ctx_shift.pyFile · 0.80
_try_parse_jsonFunction · 0.80

Calls 5

lengthMethod · 0.80
findMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by 14

run_mtmd_deepseek_ocrFunction · 0.64
read_expected_outputFunction · 0.64
test_tokenize_detokenizeFunction · 0.64
_try_parse_jsonFunction · 0.64
_country_stats_mockFunction · 0.64
_climate_info_mockFunction · 0.64
_distinct_arg_valuesFunction · 0.64
_weather_mockFunction · 0.64
_stock_mockFunction · 0.64
format_template_contentFunction · 0.64
__init__Method · 0.64
render_templateMethod · 0.64