MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / dg_sequence_message

Function dg_sequence_message

internal/cbm/diagram.c:649–674  ·  view source on GitHub ↗

A message line `A->>+B: text`: its arrow; false when it has none. */

Source from the content-addressed store, hash-verified

647
648/* A message line `A->>+B: text`: its arrow; false when it has none. */
649static bool dg_sequence_message(dg_t *dg, dg_str_t ln, uint32_t line) {
650 static const char *const arrows[] = {"<<-->>", "<<->>", "-->>", "->>", "--x", "-x",
651 "--)", "-)", "-->", "->", NULL};
652 const char *colon = memchr(ln.p, ':', ln.n);
653 dg_str_t head = colon ? dg_s(ln.p, (size_t)(colon - ln.p)) : ln;
654 for (int k = 0; arrows[k]; k++) {
655 size_t al = strlen(arrows[k]);
656 for (size_t i = 0; i + al <= head.n; i++) {
657 if (memcmp(head.p + i, arrows[k], al) != 0) {
658 continue;
659 }
660 dg_str_t to = dg_trim(dg_s(head.p + i + al, head.n - i - al));
661 while (to.n && (to.p[0] == '+' || to.p[0] == '-')) {
662 to.p++;
663 to.n--;
664 }
665 dg_str_t label = colon
666 ? dg_s(colon + SKIP_ONE, (size_t)(ln.p + ln.n - colon) - SKIP_ONE)
667 : dg_s(NULL, 0);
668 bool reply = arrows[k][0] == '-' && arrows[k][SKIP_ONE] == '-';
669 dg_arrow(dg, dg_s(head.p, i), to, label, reply ? "reply" : "message", line);
670 return true;
671 }
672 }
673 return false;
674}
675
676static void dg_sequence(dg_t *dg, dg_lines_t *it) {
677 static const char participant[] = "participant ";

Callers 1

dg_sequenceFunction · 0.85

Calls 3

dg_sFunction · 0.85
dg_trimFunction · 0.85
dg_arrowFunction · 0.85

Tested by

no test coverage detected