avoid direct usage of `std::cout` by firewave · Pull Request #499 · cppcheck-opensource/simplecpp
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm these functions are for usage in the debugger. will I be able to call these during debugging? I guess std::cout symbol is not available while I debug inside the simplecpp.
We don't need to have these functions in release builds? would that solve your itch?
Not directly specifying any stream is good style as you do not want some "random" print something. It would also allow to use it in more contexts.
Not sure about calling it directly from the debugger since I rarely do that. I thought about adding a default parameter but I did not want to have the <iostream> include in the header.
danmar
left a comment
•
Loading
danmar
left a comment
•
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can still call it directly in the debugger:
(gdb) call rawtok->printAll(std::cout)
so well this complicates debugging but it works.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integrating the proposed API while maintaining the possibility to just call the function seems like a reasonable trade-off to finalize this.
| void printAll() const; | ||
| void printOut() const; | ||
| void printAll(std::ostream& ostr) const; | ||
| void printOut(std::ostream& ostr) const; |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| void printOut(std::ostream& ostr) const; | |
| void printOut(std::ostream& ostr) const; | |
| void printAll() const { | |
| this->printAll(std::cout); | |
| } | |
| void printOut() const { | |
| this->printOut(std::cout); | |
| } |
| void push_back(Token *tok); | ||
|
|
||
| void dump() const; | ||
| void dump(std::ostream& ostr) const; |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| void dump(std::ostream& ostr) const; | |
| void dump(std::ostream& ostr) const; | |
| void dump() const { | |
| this->dump(std::cout); | |
| } |
Integrating the proposed API while maintaining the possibility to just call the function seems like a reasonable trade-off to finalize this.
Like I said that would introduce the <iostream> header which it is one of the heavier headers that and as it is just debug code that seems unnecessary to spill into user code.
Also we could use default parameters which would require less code.