MCPcopy Create free account
hub / github.com/ElementsProject/elements / ToString

Method ToString

src/rpc/util.cpp:625–674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

623}
624
625std::string RPCHelpMan::ToString() const
626{
627 std::string ret;
628
629 // Oneline summary
630 ret += m_name;
631 bool was_optional{false};
632 for (const auto& arg : m_args) {
633 if (arg.m_hidden) break; // Any arg that follows is also hidden
634 const bool optional = arg.IsOptional();
635 ret += " ";
636 if (optional) {
637 if (!was_optional) ret += "( ";
638 was_optional = true;
639 } else {
640 if (was_optional) ret += ") ";
641 was_optional = false;
642 }
643 ret += arg.ToString(/* oneline */ true);
644 }
645 if (was_optional) ret += " )";
646
647 // Description
648 ret += "\n\n" + TrimString(m_description) + "\n";
649
650 // Arguments
651 Sections sections;
652 for (size_t i{0}; i < m_args.size(); ++i) {
653 const auto& arg = m_args.at(i);
654 if (arg.m_hidden) break; // Any arg that follows is also hidden
655
656 if (i == 0) ret += "\nArguments:\n";
657
658 // Push named argument name and description
659 sections.m_sections.emplace_back(::ToString(i + 1) + ". " + arg.GetFirstName(), arg.ToDescriptionString());
660 sections.m_max_pad = std::max(sections.m_max_pad, sections.m_sections.back().m_left.size());
661
662 // Recursively push nested args
663 sections.Push(arg);
664 }
665 ret += sections.ToString();
666
667 // Result
668 ret += m_results.ToDescriptionString();
669
670 // Examples
671 ret += m_examples.ToDescriptionString();
672
673 return ret;
674}
675
676UniValue RPCHelpMan::GetArgMap() const
677{

Callers 15

BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
mempool_tests.cppFile · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
TestParseFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
~prevector_testerMethod · 0.45

Calls 11

TrimStringFunction · 0.85
JoinFunction · 0.85
IsOptionalMethod · 0.80
emplace_backMethod · 0.80
GetFirstNameMethod · 0.80
ToDescriptionStringMethod · 0.80
PushMethod · 0.80
ToStringObjMethod · 0.80
ToStringFunction · 0.50
sizeMethod · 0.45
emptyMethod · 0.45

Tested by 15

BOOST_AUTO_TEST_CASEFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
TestParseFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
~prevector_testerMethod · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36