Difference between revisions of "Prettyprint to a string"
From Verific Design Automation FAQ
| Line 5: | Line 5: | ||
VhdlTreeNode::GetPrettyPrintedString() | VhdlTreeNode::GetPrettyPrintedString() | ||
To avoid memory leak, please free the returned string when done. | To avoid memory leak, please free the returned string when done. | ||
| + | |||
This example code is included here for historical reason: | This example code is included here for historical reason: | ||
Revision as of 15:18, 28 February 2019
Q: How do I prettyprint a parsetree node to a string?
Simple APIs:
VeriTreeNode::GetPrettyPrintedString() VhdlTreeNode::GetPrettyPrintedString()
To avoid memory leak, please free the returned string when done.
This example code is included here for historical reason:
VeriExpression *init_value = param_id -> GetInitialValue();
if (init_value) {
ostringstream os;
init_value->PrettyPrint(os, 0);
char *to_string = Strings::save(os.str().c_str()) ;
cout << "*** initial value: " << to_string << " ***\n";
Strings::free(to_string);
}