Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/util.cpp
Show First 20 Lines • Show All 412 Lines • ▼ Show 20 Lines | struct Sections { | ||||
/** | /** | ||||
* Concatenate all sections with proper padding | * Concatenate all sections with proper padding | ||||
*/ | */ | ||||
std::string ToString() const { | std::string ToString() const { | ||||
std::string ret; | std::string ret; | ||||
const size_t pad = m_max_pad + 4; | const size_t pad = m_max_pad + 4; | ||||
for (const auto &s : m_sections) { | for (const auto &s : m_sections) { | ||||
// The left part of a section is assumed to be a single line, | |||||
// usually it is the name of the JSON struct or a brace like | |||||
// {, }, [, or ] | |||||
CHECK_NONFATAL(s.m_left.find('\n') == std::string::npos); | |||||
if (s.m_right.empty()) { | if (s.m_right.empty()) { | ||||
ret += s.m_left; | ret += s.m_left; | ||||
ret += "\n"; | ret += "\n"; | ||||
continue; | continue; | ||||
} | } | ||||
std::string left = s.m_left; | std::string left = s.m_left; | ||||
left.resize(pad, ' '); | left.resize(pad, ' '); | ||||
▲ Show 20 Lines • Show All 495 Lines • Show Last 20 Lines |