souffle  2.0.2-371-g6315b36
Public Member Functions | Private Attributes
souffle::InnerNode Class Reference

#include <ExplainTree.h>

Inheritance diagram for souffle::InnerNode:
Inheritance graph
Collaboration diagram for souffle::InnerNode:
Collaboration graph

Public Member Functions

void add_child (Own< TreeNode > child)
 
 InnerNode (const std::string &nodeText="", std::string label="")
 
void place (uint32_t x, uint32_t y) override
 
void printJSON (std::ostream &os, int pos) override
 
void render (ScreenBuffer &s) override
 
- Public Member Functions inherited from souffle::TreeNode
uint32_t getHeight () const
 
size_t getSize ()
 
uint32_t getWidth () const
 
void setSize (size_t s)
 
 TreeNode (std::string t="")
 
virtual ~TreeNode ()=default
 

Private Attributes

VecOwn< TreeNodechildren
 
std::string label
 

Additional Inherited Members

- Protected Attributes inherited from souffle::TreeNode
uint32_t height = 0
 
uint32_t size = 0
 
std::string txt
 
uint32_t width = 0
 
int xpos = 0
 
int ypos = 0
 

Detailed Description

Definition at line 133 of file ExplainTree.h.

Constructor & Destructor Documentation

◆ InnerNode()

souffle::InnerNode::InnerNode ( const std::string &  nodeText = "",
std::string  label = "" 
)
inline

Definition at line 137 of file ExplainTree.h.

138  {

References children.

Member Function Documentation

◆ add_child()

void souffle::InnerNode::add_child ( Own< TreeNode child)
inline

Definition at line 141 of file ExplainTree.h.

149  : children) {

◆ place()

void souffle::InnerNode::place ( uint32_t  x,
uint32_t  y 
)
inlineoverridevirtual

Implements souffle::TreeNode.

Definition at line 146 of file ExplainTree.h.

149  : children) {
150  k->place(x, y + 2);
151  x += k->getWidth() + 1;
152  width += k->getWidth() + 1;
153  height = std::max(height, k->getHeight());
154  }
155  height += 2;
156 
157  // text of inner node is longer than all its sub-trees
158  if (width < txt.length()) {
159  width = txt.length();
160  }
161  };
162 
163  // render node text and separator line
164  void render(ScreenBuffer& s) override {
165  s.write(xpos + (width - txt.length()) / 2, ypos, txt);
166  for (const Own<TreeNode>& k : children) {
167  k->render(s);
168  }
169  std::string separator(width - label.length(), '-');

References souffle::TreeNode::height, k, and souffle::TreeNode::width.

◆ printJSON()

void souffle::InnerNode::printJSON ( std::ostream &  os,
int  pos 
)
inlineoverridevirtual

Implements souffle::TreeNode.

Definition at line 183 of file ExplainTree.h.

184  {
185  os << ",\n";
186  }
187  k->printJSON(os, pos + 1);
188  }
189  os << tab << "]\n";
190  os << tab << "}";
191  }
192 
193 private:
194  VecOwn<TreeNode> children;
195  std::string label;
196 };
197 
198 /***
199  * Concrete class for leafs

◆ render()

void souffle::InnerNode::render ( ScreenBuffer s)
inlineoverridevirtual

Implements souffle::TreeNode.

Definition at line 172 of file ExplainTree.h.

175  {
176  std::string tab(pos, '\t');
177  os << tab << R"({ "premises": ")" << stringify(txt) << "\",\n";
178  os << tab << R"( "rule-number": ")" << label << "\",\n";
179  os << tab << " \"children\": [\n";
180  bool first = true;

Field Documentation

◆ children

VecOwn<TreeNode> souffle::InnerNode::children
private

Definition at line 202 of file ExplainTree.h.

Referenced by InnerNode().

◆ label

std::string souffle::InnerNode::label
private

Definition at line 203 of file ExplainTree.h.


The documentation for this class was generated from the following file:
souffle::TreeNode::xpos
int xpos
Definition: ExplainTree.h:128
souffle::InnerNode::label
std::string label
Definition: ExplainTree.h:203
souffle::TreeNode::ypos
int ypos
Definition: ExplainTree.h:129
souffle::stringify
std::string stringify(const std::string &input)
Stringify a string using escapes for escape, newline, tab, double-quotes and semicolons.
Definition: StringUtil.h:334
k
var k
Definition: htmlJsChartistMin.h:15
souffle::InnerNode::children
VecOwn< TreeNode > children
Definition: ExplainTree.h:202
souffle::TreeNode::height
uint32_t height
Definition: ExplainTree.h:127
souffle::TreeNode::txt
std::string txt
Definition: ExplainTree.h:125
souffle::InnerNode::render
void render(ScreenBuffer &s) override
Definition: ExplainTree.h:172
souffle::TreeNode::width
uint32_t width
Definition: ExplainTree.h:126