From e32250e806e59aaae2937eafd6c9c70ed55f416a Mon Sep 17 00:00:00 2001 From: David Kolossa Date: Tue, 31 Mar 2009 19:00:26 +0200 Subject: [PATCH] Moved Printer class into Out class --- src/output.cc | 68 +++++++++++++++++----------------- src/output.hh | 116 +++++++++++++++++++++++++++++----------------------------- 2 files changed, 92 insertions(+), 92 deletions(-) diff --git a/src/output.cc b/src/output.cc index 5e7b17a..be1185c 100644 --- a/src/output.cc +++ b/src/output.cc @@ -35,34 +35,34 @@ // Printer class // -Printer::Printer(void printer(std::string)) +Out::Printer::Printer(void printer(std::string)) { this->printer = printer; } -Printer& -Printer::operator<<(std::string msg) +Out::Printer& +Out::Printer::operator<<(std::string msg) { this->printer(msg); return *this; } -Printer& -Printer::operator<<(const char *msg) +Out::Printer& +Out::Printer::operator<<(const char *msg) { this->printer(msg); return *this; } -Printer& -Printer::operator<<(char msg) +Out::Printer& +Out::Printer::operator<<(char msg) { this->printer(std::string(1, msg)); return *this; } -Printer& -Printer::operator<<(int msg) +Out::Printer& +Out::Printer::operator<<(int msg) { std::ostringstream tmp; tmp << msg; @@ -70,8 +70,8 @@ Printer::operator<<(int msg) return *this; } -Printer& -Printer::operator<<(short msg) +Out::Printer& +Out::Printer::operator<<(short msg) { std::ostringstream tmp; tmp << msg; @@ -79,8 +79,8 @@ Printer::operator<<(short msg) return *this; } -Printer& -Printer::operator<<(long msg) +Out::Printer& +Out::Printer::operator<<(long msg) { std::ostringstream tmp; tmp << msg; @@ -88,8 +88,8 @@ Printer::operator<<(long msg) return *this; } -Printer& -Printer::operator<<(long long msg) +Out::Printer& +Out::Printer::operator<<(long long msg) { std::ostringstream tmp; tmp << msg; @@ -97,8 +97,8 @@ Printer::operator<<(long long msg) return *this; } -Printer& -Printer::operator<<(unsigned int msg) +Out::Printer& +Out::Printer::operator<<(unsigned int msg) { std::ostringstream tmp; tmp << msg; @@ -106,8 +106,8 @@ Printer::operator<<(unsigned int msg) return *this; } -Printer& -Printer::operator<<(unsigned short msg) +Out::Printer& +Out::Printer::operator<<(unsigned short msg) { std::ostringstream tmp; tmp << msg; @@ -115,8 +115,8 @@ Printer::operator<<(unsigned short msg) return *this; } -Printer& -Printer::operator<<(unsigned long msg) +Out::Printer& +Out::Printer::operator<<(unsigned long msg) { std::ostringstream tmp; tmp << msg; @@ -124,8 +124,8 @@ Printer::operator<<(unsigned long msg) return *this; } -Printer& -Printer::operator<<(unsigned long long msg) +Out::Printer& +Out::Printer::operator<<(unsigned long long msg) { std::ostringstream tmp; tmp << msg; @@ -133,8 +133,8 @@ Printer::operator<<(unsigned long long msg) return *this; } -Printer& -Printer::operator<<(float msg) +Out::Printer& +Out::Printer::operator<<(float msg) { std::ostringstream tmp; tmp << msg; @@ -142,8 +142,8 @@ Printer::operator<<(float msg) return *this; } -Printer& -Printer::operator<<(double msg) +Out::Printer& +Out::Printer::operator<<(double msg) { std::ostringstream tmp; tmp << msg; @@ -152,7 +152,7 @@ Printer::operator<<(double msg) } int -Printer::vprintf(const char *format, va_list args) +Out::Printer::vprintf(const char *format, va_list args) { int result; int length = std::strlen(format) + FORMAT_BUFSIZE; @@ -171,7 +171,7 @@ Printer::vprintf(const char *format, va_list args) } int -Printer::printf(const char *format, ...) +Out::Printer::printf(const char *format, ...) { int result; va_list args; @@ -187,11 +187,11 @@ Printer::printf(const char *format, ...) // Out class // -Printer Out::fatal = Printer(Out::fatalPrinter); -Printer Out::error = Printer(Out::errorPrinter); -Printer Out::warning = Printer(Out::warningPrinter); -Printer Out::msg = Printer(Out::msgPrinter); -Printer Out::debug = Printer(Out::debugPrinter); +Out::Printer Out::fatal = Printer(Out::fatalPrinter); +Out::Printer Out::error = Printer(Out::errorPrinter); +Out::Printer Out::warning = Printer(Out::warningPrinter); +Out::Printer Out::msg = Printer(Out::msgPrinter); +Out::Printer Out::debug = Printer(Out::debugPrinter); int Out::isWriting = 0; int Out::flags = 0; diff --git a/src/output.hh b/src/output.hh index 21fb38c..766f471 100644 --- a/src/output.hh +++ b/src/output.hh @@ -23,94 +23,95 @@ #include #include -class Printer +/** + * This is the class for OpenStranded output to either cout or cerr. + */ +class Out { private: - void (*printer)(std::string); + class Printer + { + private: + void (*printer)(std::string); - public: - Printer(void (*printer)(std::string)); + public: + Printer(void (*printer)(std::string)); - // - // Texts - // + // + // Texts + // - Printer& - operator<<(std::string msg); + Printer& + operator<<(std::string msg); - Printer& - operator<<(const char *msg); + Printer& + operator<<(const char *msg); - Printer& - operator<<(char msg); + Printer& + operator<<(char msg); - // - // Signed integers - // + // + // Signed integers + // - Printer& - operator<<(int msg); + Printer& + operator<<(int msg); - Printer& - operator<<(short msg); + Printer& + operator<<(short msg); - Printer& - operator<<(long msg); + Printer& + operator<<(long msg); - Printer& - operator<<(long long msg); + Printer& + operator<<(long long msg); - // - // Unsigned integers - // + // + // Unsigned integers + // - Printer& - operator<<(unsigned int msg); + Printer& + operator<<(unsigned int msg); - Printer& - operator<<(unsigned short msg); + Printer& + operator<<(unsigned short msg); - Printer& - operator<<(unsigned long msg); + Printer& + operator<<(unsigned long msg); - Printer& - operator<<(unsigned long long msg); + Printer& + operator<<(unsigned long long msg); - // - // Decimals - // + // + // Decimals + // - Printer& - operator<<(float msg); + Printer& + operator<<(float msg); - Printer& - operator<<(double msg); + Printer& + operator<<(double msg); - // - // Format strings - // - int - vprintf(const char *format, va_list args); - - int - printf(const char *format, ...); -}; + // + // Format strings + // -/** - * This is the class for OpenStranded output to either cout or cerr. - */ -class Out -{ + int + vprintf(const char *format, va_list args); + + int + printf(const char *format, ...); + }; public: /** @@ -210,7 +211,6 @@ class Out * @param newflags The new mode flags. */ static void - setFlags(int newflags); - + setFlags(int newflags); }; -- 2.11.4.GIT