00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <string>
00021 #include <iomanip>
00022 #include "fssIO.h"
00023
00024 using std::string;
00025
00026 namespace FastSatSolver {
00027
00028
00029
00030 GenericException::GenericException(std::string text):
00031 text_(text)
00032 {
00033 }
00034 string GenericException::getText() {
00035 return text_;
00036 }
00037
00038 namespace StreamDecorator {
00039
00040
00041 struct FixedFloat::Private {
00042 int width;
00043 int precision;
00044 };
00045 FixedFloat::FixedFloat(int integral, int decimal):
00046 d(new Private)
00047 {
00048 d->width = integral+decimal+1;
00049 d->precision = decimal;
00050 }
00051 FixedFloat::~FixedFloat() {
00052 delete d;
00053 }
00054 std::ostream& operator<< (std::ostream &stream, const FixedFloat &manip) {
00055 return stream
00056 << std::fixed
00057 << std::setw(manip.d->width)
00058 << std::setprecision(manip.d->precision);
00059 }
00060
00061
00062
00063 bool Color::useColors = false;
00064 struct Color::Private {
00065 EColor color;
00066 };
00067 Color::Color(EColor color):
00068 d(new Private)
00069 {
00070 d->color = color;
00071 }
00072 Color::Color(const Color &cObj):
00073 d(new Private)
00074 {
00075 d->color = cObj.d->color;
00076 }
00077 Color::~Color() {
00078 delete d;
00079 }
00080 void Color::enable(bool b) {
00081 Color::useColors = b;
00082 }
00083 bool Color::isEnabled() {
00084 return Color::useColors;
00085 }
00086 std::ostream& operator<< (std::ostream &stream, const Color &cObj) {
00087 if (Color::useColors) {
00088 static const char ESC = '\033';
00089 stream << ESC;
00090 switch (cObj.d->color) {
00091 case C_NO_COLOR: stream << "[0m"; break;
00092 case C_BLUE: stream << "[0;34m"; break;
00093 case C_GREEN: stream << "[0;32m"; break;
00094 case C_CYAN: stream << "[0;36m"; break;
00095 case C_RED: stream << "[0;31m"; break;
00096 case C_PURPLE: stream << "[0;35m"; break;
00097 case C_BROWN: stream << "[0;33m"; break;
00098 case C_LIGHT_GRAY: stream << "[0;37m"; break;
00099 case C_DARK_GRAY: stream << "[1;30m"; break;
00100 case C_LIGHT_BLUE: stream << "[1;34m"; break;
00101 case C_LIGHT_GREEN: stream << "[1;32m"; break;
00102 case C_LIGHT_CYAN: stream << "[1;36m"; break;
00103 case C_LIGHT_RED: stream << "[1;31m"; break;
00104 case C_LIGHT_PURPLE: stream << "[1;35m"; break;
00105 case C_YELLOW: stream << "[1;33m"; break;
00106 case C_WHITE: stream << "[1;37m"; break;
00107 }
00108 }
00109 return stream;
00110 }
00111 }
00112
00113 }