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

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