P4C
The P4 Compiler
Loading...
Searching...
No Matches
log_fixup.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_LIB_LOG_FIXUP_H_
20#define BACKENDS_TOFINO_BF_P4C_LIB_LOG_FIXUP_H_
21
22#include "lib/log.h"
23
24class logfix {
25 std::string text;
26 friend std::ostream &operator<<(std::ostream &out, const logfix &lf) {
27 bool newline = false;
28 for (char ch : lf.text) {
29 if (newline) out << Log::endl;
30 if (!(newline = ch == '\n')) out << ch;
31 }
32 return out;
33 }
34
35 public:
36 explicit logfix(std::string s) : text(s) {}
37 explicit logfix(const std::stringstream &ss) : text(ss.str()) {}
38};
39
40#endif /* BACKENDS_TOFINO_BF_P4C_LIB_LOG_FIXUP_H_ */
Definition log_fixup.h:24