-
Notifications
You must be signed in to change notification settings - Fork 94
avoid direct usage of std::cout
#499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
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 |
There was a problem hiding this 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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); | |
} |
@@ -235,7 +235,7 @@ namespace simplecpp { | |||
} | |||
void push_back(Token *tok); | |||
|
|||
void dump() const; | |||
void dump(std::ostream& ostr) const; |
There was a problem hiding this comment.
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); | |
} |
Like I said that would introduce the Also we could use default parameters which would require less code. |
No description provided.