|
28 | 28 | #include <limits> |
29 | 29 | #include <list> |
30 | 30 | #include <map> |
| 31 | +#include <ostream> |
31 | 32 | #include <set> |
32 | 33 | #include <sstream> |
33 | 34 | #include <stack> |
@@ -205,29 +206,29 @@ bool simplecpp::Token::endsWithOneOf(const char c[]) const |
205 | 206 | return std::strchr(c, string[string.size() - 1U]) != nullptr; |
206 | 207 | } |
207 | 208 |
|
208 | | -void simplecpp::Token::printAll() const |
| 209 | +void simplecpp::Token::printAll(std::ostream& ostr) const |
209 | 210 | { |
210 | 211 | const Token *tok = this; |
211 | 212 | while (tok->previous) |
212 | 213 | tok = tok->previous; |
213 | 214 | for (; tok; tok = tok->next) { |
214 | 215 | if (tok->previous) { |
215 | | - std::cout << (sameline(tok, tok->previous) ? ' ' : '\n'); |
| 216 | + ostr << (sameline(tok, tok->previous) ? ' ' : '\n'); |
216 | 217 | } |
217 | | - std::cout << tok->str(); |
| 218 | + ostr << tok->str(); |
218 | 219 | } |
219 | | - std::cout << std::endl; |
| 220 | + ostr << std::endl; |
220 | 221 | } |
221 | 222 |
|
222 | | -void simplecpp::Token::printOut() const |
| 223 | +void simplecpp::Token::printOut(std::ostream& ostr) const |
223 | 224 | { |
224 | 225 | for (const Token *tok = this; tok; tok = tok->next) { |
225 | 226 | if (tok != this) { |
226 | | - std::cout << (sameline(tok, tok->previous) ? ' ' : '\n'); |
| 227 | + ostr << (sameline(tok, tok->previous) ? ' ' : '\n'); |
227 | 228 | } |
228 | | - std::cout << tok->str(); |
| 229 | + ostr << tok->str(); |
229 | 230 | } |
230 | | - std::cout << std::endl; |
| 231 | + ostr << std::endl; |
231 | 232 | } |
232 | 233 |
|
233 | 234 | // cppcheck-suppress noConstructor - we call init() in the inherited to initialize the private members |
@@ -553,9 +554,9 @@ void simplecpp::TokenList::push_back(Token *tok) |
553 | 554 | backToken = tok; |
554 | 555 | } |
555 | 556 |
|
556 | | -void simplecpp::TokenList::dump() const |
| 557 | +void simplecpp::TokenList::dump(std::ostream& ostr) const |
557 | 558 | { |
558 | | - std::cout << stringify() << std::endl; |
| 559 | + ostr << stringify() << std::endl; |
559 | 560 | } |
560 | 561 |
|
561 | 562 | std::string simplecpp::TokenList::stringify() const |
|
0 commit comments