Shows how to control formatting of flow styles.
5438 return ryml::emitrs_yaml<std::string>(n, opts);
5441 return ryml::emitrs_json<std::string>(n, opts);
5462 CHECK(tree[
"map"].is_flow_ml1());
5463 CHECK(tree[
"map"][
"seq"].is_flow_ml1());
5464 CHECK(tree[
"map"][
"seq"][4].is_flow_sl());
5466 CHECK(tostr(tree, emit_defaults) == yaml);
5468 CHECK(tostr_json(tree, emit_defaults) ==
5489 CHECK(tree[
"map"].is_flow_sl());
5491 CHECK(tostr(tree, emit_defaults) ==
5492 "{map: {seq: [0,1,2,3,[40,41]]}}");
5494 CHECK(tostr_json(tree, emit_defaults) ==
5495 "{\"map\": {\"seq\": [0,1,2,3,[40,41]]}}");
5500 CHECK(tostr(tree, with_spaces) ==
5501 "{map: {seq: [0, 1, 2, 3, [40, 41]]}}");
5503 CHECK(tostr_json(tree, with_spaces) ==
5504 "{\"map\": {\"seq\": [0, 1, 2, 3, [40, 41]]}}");
5513 CHECK(tree[
"map"].is_flow_mln());
5514 CHECK(tree[
"map"][
"seq"][4].is_flow_sl());
5515 CHECK(tostr(tree, emit_defaults) ==
5519 " 0,1,2,3,[40,41]" "\n"
5523 CHECK(tostr_json(tree, emit_defaults) ==
5527 " 0,1,2,3,[40,41]" "\n"
5534 CHECK(tostr(tree, with_spaces) ==
5538 " 0, 1, 2, 3, [40, 41]" "\n"
5542 CHECK(tostr_json(tree, with_spaces) ==
5546 " 0, 1, 2, 3, [40, 41]" "\n"
5557 CHECK(tree[
"map"].is_flow_ml1());
5558 CHECK(tree[
"map"][
"seq"][4].is_flow_sl());
5559 CHECK(tostr(tree, noindent) ==
""
5572 CHECK(tostr_json(tree, noindent) ==
""
5591 " 0, 1, 2, 3, 4, 5, 6, 7, 8, 9," "\n"
5592 " 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, " "\n"
5593 " 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, " "\n"
5594 " 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, " "\n"
5595 " 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, " "\n"
5596 " 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, " "\n"
5597 " 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, " "\n"
5598 " 70, 71, 72, 73, 74, 75, 76, 77, 78, 79 " "\n"
5609 CHECK(tostr(tree, emit_defaults) ==
""
5611 " 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,\n"
5612 " 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,\n"
5613 " 56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79\n"
5616 CHECK(tostr_json(tree, emit_defaults) ==
""
5618 " 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,\n"
5619 " 29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,\n"
5620 " 55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79\n"
5626 CHECK(tostr(tree, maxcols40) ==
""
5628 " 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,\n"
5629 " 16,17,18,19,20,21,22,23,24,25,26,27,28,\n"
5630 " 29,30,31,32,33,34,35,36,37,38,39,40,41,\n"
5631 " 42,43,44,45,46,47,48,49,50,51,52,53,54,\n"
5632 " 55,56,57,58,59,60,61,62,63,64,65,66,67,\n"
5633 " 68,69,70,71,72,73,74,75,76,77,78,79\n"
5636 CHECK(tostr_json(tree, maxcols40) ==
""
5638 " 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,\n"
5639 " 16,17,18,19,20,21,22,23,24,25,26,27,28,\n"
5640 " 29,30,31,32,33,34,35,36,37,38,39,40,41,\n"
5641 " 42,43,44,45,46,47,48,49,50,51,52,53,54,\n"
5642 " 55,56,57,58,59,60,61,62,63,64,65,66,67,\n"
5643 " 68,69,70,71,72,73,74,75,76,77,78,79\n"
5650 CHECK(tostr(tree, with_spaces) ==
""
5652 " 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,\n"
5653 " 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,\n"
5654 " 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,\n"
5655 " 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79\n"
5658 CHECK(tostr_json(tree, with_spaces) ==
""
5660 " 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,\n"
5661 " 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,\n"
5662 " 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,\n"
5663 " 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79\n"
5670 CHECK(tostr(tree, maxcols40_spc) ==
""
5672 " 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\n"
5673 " 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,\n"
5674 " 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,\n"
5675 " 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,\n"
5676 " 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,\n"
5677 " 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,\n"
5678 " 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,\n"
5679 " 72, 73, 74, 75, 76, 77, 78, 79\n"
5682 CHECK(tostr_json(tree, maxcols40_spc) ==
""
5684 " 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\n"
5685 " 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,\n"
5686 " 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,\n"
5687 " 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,\n"
5688 " 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,\n"
5689 " 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,\n"
5690 " 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,\n"
5691 " 72, 73, 74, 75, 76, 77, 78, 79\n"
5699 CHECK(tostr(tree, maxcols40_spc_noindent) ==
""
5701 "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\n"
5702 "13, 14, 15, 16, 17, 18, 19, 20, 21, 22,\n"
5703 "23, 24, 25, 26, 27, 28, 29, 30, 31, 32,\n"
5704 "33, 34, 35, 36, 37, 38, 39, 40, 41, 42,\n"
5705 "43, 44, 45, 46, 47, 48, 49, 50, 51, 52,\n"
5706 "53, 54, 55, 56, 57, 58, 59, 60, 61, 62,\n"
5707 "63, 64, 65, 66, 67, 68, 69, 70, 71, 72,\n"
5708 "73, 74, 75, 76, 77, 78, 79\n"
5711 CHECK(tostr_json(tree, maxcols40_spc_noindent) ==
""
5713 "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\n"
5714 "13, 14, 15, 16, 17, 18, 19, 20, 21, 22,\n"
5715 "23, 24, 25, 26, 27, 28, 29, 30, 31, 32,\n"
5716 "33, 34, 35, 36, 37, 38, 39, 40, 41, 42,\n"
5717 "43, 44, 45, 46, 47, 48, 49, 50, 51, 52,\n"
5718 "53, 54, 55, 56, 57, 58, 59, 60, 61, 62,\n"
5719 "63, 64, 65, 66, 67, 68, 69, 70, 71, 72,\n"
5720 "73, 74, 75, 76, 77, 78, 79\n"
bool indent_flow_ml() const noexcept
Indent the contents of FLOW_ML1 and FLOW_MLN containers.
ParserOptions & detect_flow_ml(bool enabled) noexcept
enable/disable detection of flow multiline container style.
bool is_flow_mln() const noexcept
mark container with multi-line flow style, n elements per line, < wrapped (as set by EmitOptions::max...
void parse_in_arena(Parser *parser, csubstr filename, csubstr yaml, Tree *tree, id_type node_id)
(1) parse YAML into an existing tree node. The filename will be used in any error messages arising du...
Options to give to the ParseEngine to control its behavior.
EmitOptions & force_flow_spc(bool enabled) noexcept
Force everywhere a space after comma in flow mode, overriding the FLOW_SPC status of individual conta...
#define CHECK(predicate)
a testing assertion, used only in this quickstart
Holds a pointer to an existing tree, and a node id.
EmitOptions & max_cols(id_type cols) noexcept
Set max columns for the emitted YAML in FLOW_MLN mode.
NodeRef rootref()
Get the root as a NodeRef . Note that a non-const Tree implicitly converts to NodeRef.
A lightweight object containing options to be used when emitting.
ParserOptions & flow_ml_style(NodeType style) noexcept
choose the default style of multiline flow containers, when a container is detected as flow multiline...
NodeType type() const RYML_NOEXCEPT
Forward to Tree::type().