summaryrefslogtreecommitdiff
path: root/src/pretty_printing.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/pretty_printing.h')
-rw-r--r--src/pretty_printing.h25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/pretty_printing.h b/src/pretty_printing.h
index 88028fdec..7389ad97f 100644
--- a/src/pretty_printing.h
+++ b/src/pretty_printing.h
@@ -3,52 +3,55 @@
// Pretty printing helpers
//
+#ifndef _pretty_printing_h
+#define _pretty_printing_h
+
#include <ostream>
#include "emscripten-optimizer/colors.h"
-std::ostream &doIndent(std::ostream &o, unsigned indent) {
+inline std::ostream &doIndent(std::ostream &o, unsigned indent) {
for (unsigned i = 0; i < indent; i++) {
o << " ";
}
return o;
}
-std::ostream &incIndent(std::ostream &o, unsigned& indent) {
+inline std::ostream &incIndent(std::ostream &o, unsigned& indent) {
o << '\n';
indent++;
return o;
}
-std::ostream &decIndent(std::ostream &o, unsigned& indent) {
+inline std::ostream &decIndent(std::ostream &o, unsigned& indent) {
indent--;
doIndent(o, indent);
return o << ')';
}
-std::ostream &prepareMajorColor(std::ostream &o) {
+inline std::ostream &prepareMajorColor(std::ostream &o) {
Colors::red(o);
Colors::bold(o);
return o;
}
-std::ostream &prepareColor(std::ostream &o) {
+inline std::ostream &prepareColor(std::ostream &o) {
Colors::magenta(o);
Colors::bold(o);
return o;
}
-std::ostream &prepareMinorColor(std::ostream &o) {
+inline std::ostream &prepareMinorColor(std::ostream &o) {
Colors::orange(o);
return o;
}
-std::ostream &restoreNormalColor(std::ostream &o) {
+inline std::ostream &restoreNormalColor(std::ostream &o) {
Colors::normal(o);
return o;
}
-std::ostream& printText(std::ostream &o, const char *str) {
+inline std::ostream& printText(std::ostream &o, const char *str) {
o << '"';
Colors::green(o);
o << str;
@@ -56,7 +59,7 @@ std::ostream& printText(std::ostream &o, const char *str) {
return o << '"';
}
-std::ostream& printOpening(std::ostream &o, const char *str, bool major=false) {
+inline std::ostream& printOpening(std::ostream &o, const char *str, bool major=false) {
o << '(';
major ? prepareMajorColor(o) : prepareColor(o);
o << str;
@@ -64,7 +67,7 @@ std::ostream& printOpening(std::ostream &o, const char *str, bool major=false) {
return o;
}
-std::ostream& printMinorOpening(std::ostream &o, const char *str) {
+inline std::ostream& printMinorOpening(std::ostream &o, const char *str) {
o << '(';
prepareMinorColor(o);
o << str;
@@ -72,3 +75,5 @@ std::ostream& printMinorOpening(std::ostream &o, const char *str) {
return o;
}
+#endif // _pretty_printing_h
+