MCPcopy Create free account
hub / github.com/F-Stack/f-stack / csv_open_level

Function csv_open_level

tools/libxo/encoder/csv/enc_csv.c:420–457  ·  view source on GitHub ↗

* Open a "level" of hierarchy, either a container or an instance. Look * for a match in the path=x/y/z hierarchy, and ignore if not a match. * If we're at the end of the path, start recording leaf values. */

Source from the content-addressed store, hash-verified

418 * If we're at the end of the path, start recording leaf values.
419 */
420static int
421csv_open_level (xo_handle_t *xop UNUSED, csv_private_t *csv,
422 const char *name, int instance)
423{
424 /* An new "open" event means we stop recording */
425 if (csv->c_flags & CF_RECORD_DATA) {
426 csv->c_flags &= ~CF_RECORD_DATA;
427 csv_emit_record(xop, csv);
428 return 0;
429 }
430
431 const char *path_top = csv_path_top(csv, 0);
432
433 /* If the top of the stack does not match the name, then ignore */
434 if (path_top == NULL) {
435 if (instance && !(csv->c_flags & CF_HAS_PATH)) {
436 csv_dbg(xop, csv, "csv: recording (no-path) ...\n");
437 csv->c_flags |= CF_RECORD_DATA;
438 }
439
440 } else if (xo_streq(path_top, name)) {
441 csv->c_path_cur += 1; /* Advance to next path member */
442
443 csv_dbg(xop, csv, "csv: match: [%s] (%zd/%zd)\n", name,
444 csv->c_path_cur, csv->c_path_max);
445
446 /* If we're all the way thru the path members, start recording */
447 if (csv->c_path_cur == csv->c_path_max) {
448 csv_dbg(xop, csv, "csv: recording ...\n");
449 csv->c_flags |= CF_RECORD_DATA;
450 }
451 }
452
453 /* Push the name on the stack */
454 csv_stack_push(csv, name);
455
456 return 0;
457}
458
459/*
460 * Close a "level", either a container or an instance.

Callers 1

csv_handlerFunction · 0.85

Calls 5

csv_emit_recordFunction · 0.85
csv_path_topFunction · 0.85
csv_dbgFunction · 0.85
xo_streqFunction · 0.85
csv_stack_pushFunction · 0.85

Tested by

no test coverage detected