MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / Expr

Function Expr

src/script/descriptor.cpp:397–414  ·  view source on GitHub ↗

Return the expression that sp begins with, and update sp to skip it. */

Source from the content-addressed store, hash-verified

395
396/** Return the expression that sp begins with, and update sp to skip it. */
397Span<const char> Expr(Span<const char>& sp)
398{
399 int level = 0;
400 auto it = sp.begin();
401 while (it != sp.end()) {
402 if (*it == '(') {
403 ++level;
404 } else if (level && *it == ')') {
405 --level;
406 } else if (level == 0 && (*it == ')' || *it == ',')) {
407 break;
408 }
409 ++it;
410 }
411 Span<const char> ret = sp.first(it - sp.begin());
412 sp = sp.subspan(it - sp.begin());
413 return ret;
414}
415
416/** Split a string on every instance of sep, returning a vector. */
417std::vector<Span<const char>> Split(const Span<const char>& sp, char sep)

Callers 1

ParseScriptFunction · 0.85

Calls 4

firstMethod · 0.80
subspanMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected