MIDAS
Loading...
Searching...
No Matches
NestedOutput Class Reference
Collaboration diagram for NestedOutput:

Public Member Functions

void Clear ()
 
void Output (int nest, bool span, std::string text)
 
std::string Print ()
 

Public Attributes

std::vector< NestedLinefLines
 

Detailed Description

Definition at line 4812 of file mjsonrpc.cxx.

Member Function Documentation

◆ Clear()

void NestedOutput::Clear ( )
inline

Definition at line 4817 of file mjsonrpc.cxx.

4818 {
4819 fLines.clear();
4820 }
std::vector< NestedLine > fLines
Here is the caller graph for this function:

◆ Output()

void NestedOutput::Output ( int  nest,
bool  span,
std::string  text 
)
inline

Definition at line 4822 of file mjsonrpc.cxx.

4823 {
4824 if (text.length() < 1)
4825 return;
4826
4827 NestedLine l;
4828 l.nest = nest;
4829 l.span = span;
4830 l.text = text;
4831 fLines.push_back(l);
4832 };
std::string text
Here is the caller graph for this function:

◆ Print()

std::string NestedOutput::Print ( )
inline

Definition at line 4834 of file mjsonrpc.cxx.

4835 {
4836 std::vector<int> tablen;
4837 std::vector<std::string> tab;
4838 std::vector<std::string> tabx;
4839
4840 tablen.push_back(0);
4841 tab.push_back("");
4842 tabx.push_back("");
4843
4844 std::string xtab = "";
4845 int maxlen = 0;
4846 for (int n=0; ; n++) {
4847 int len = -1;
4848 for (unsigned i=0; i<fLines.size(); i++) {
4849 int nn = fLines[i].nest;
4850 bool pp = fLines[i].span;
4851 if (pp)
4852 continue;
4853 if (nn != n)
4854 continue;
4855 int l = fLines[i].text.length();
4856 if (l>len)
4857 len = l;
4858 }
4859 //printf("nest %d len %d\n", n, len);
4860 if (len < 0)
4861 break; // nothing with this nest level
4862 tablen.push_back(len);
4863 tab.push_back(indent(len, " ") + " | ");
4864 xtab += indent(len, " ") + " | ";
4865 tabx.push_back(xtab);
4866 maxlen += 3+len;
4867 }
4868
4869 std::string s;
4870 int nest = 0;
4871
4872 for (unsigned i=0; i<fLines.size(); i++) {
4873 int n = fLines[i].nest;
4874 bool p = fLines[i].span;
4875
4876 std::string pad;
4877
4878 if (!p) {
4879 int ipad = tablen[n+1] - fLines[i].text.length();
4880 pad = indent(ipad, " ");
4881 }
4882
4883 std::string hr = indent(maxlen-tabx[n].length(), "-");
4884
4885 if (n > nest)
4886 s += std::string(" | ") + fLines[i].text + pad;
4887 else if (n == nest) {
4888 s += "\n";
4889 if (n == 0 || n == 1)
4890 s += tabx[n] + hr + "\n";
4891 s += tabx[n] + fLines[i].text + pad;
4892 } else {
4893 s += "\n";
4894 if (n == 0 || n == 1)
4895 s += tabx[n] + hr + "\n";
4896 s += tabx[n] + fLines[i].text + pad;
4897 }
4898
4899 nest = n;
4900 }
4901
4902 return s;
4903 }
DWORD n[4]
Definition mana.cxx:247
INT i
Definition mdump.cxx:32
static std::string indent(int x, const char *p=" ")
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fLines

std::vector<NestedLine> NestedOutput::fLines

Definition at line 4815 of file mjsonrpc.cxx.


The documentation for this class was generated from the following file: