Blame c++/freetype/src/log.h

b8976b
#ifndef LOG_H
b8976b
#define LOG_H
b8976b
b8976b
b8976b
#include <string></string>
b8976b
#include <sstream></sstream>
b8976b
#include <iomanip></iomanip>
b8976b
b8976b
#include "vector.h"
b8976b
#include "matrix.h"
b8976b
b8976b
b8976b
class Log {
b8976b
public:
b8976b
	static const std::string& tab()
b8976b
		{ static std::string t = "    "; return t; }
b8976b
	static const std::string tab(int count) {
b8976b
		const std::string &t = tab();
b8976b
		std::string tt;
b8976b
		for(int i = 0; i < count; ++i) tt += t;
b8976b
		return tt;
b8976b
	}
b8976b
b8976b
	template<typename t=""></typename>
b8976b
	static std::string to_string(const VectorT<t> &x, int w = 0) {</t>
b8976b
		std::stringstream s;
b8976b
		s << "(";
b8976b
		for(int i = 0; i < VectorT<t>::Count; ++i)</t>
b8976b
			s << (i ? ", " : "") << std::setw(w) << x[i] << std::setw(0);
b8976b
		s << ")";
b8976b
		return s.str();
b8976b
	}
b8976b
b8976b
	template<typename t=""></typename>
b8976b
	static std::string to_string(const PairT<t> &x, int w = 0)</t>
b8976b
		{ return to_string(x.p0, w) + "-" + to_string(x.p1, w); }
b8976b
b8976b
	static std::string to_string(const Matrix3 &x, int w = 0, const std::string &prefix = std::string()) {
b8976b
		std::stringstream s;
b8976b
		for(int i = 0; i < 3; ++i)
b8976b
			s << prefix << to_string(x[i], w) << std::endl;
b8976b
		return s.str();
b8976b
	}
b8976b
};
b8976b
b8976b
#endif