/** * Triangles * Copyright (C) 2016 POSITIVE MENTAL ATTITUDE * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include /** * @class Rect * @author POSITIVE MENTAL ATTITUDE * @date 06/09/16 * @file Utility.hpp * @brief Helper class for box collision. */ struct Rect { float left, right, top, bottom; }; /** * @class Echo * @author POSITIVE MENTAL ATTITUDE * @date 06/09/16 * @file Utility.hpp * @brief Helper class for stdout/stderr output. */ class Echo { public: enum { Empty, Info, Load, Debug, Error }; Echo() = default; template static void out(int prefix, Type out, Args... args); template static void debug(Type out, Args... args); template static void info(Type out, Args... args); template static void load(Type out, Args... args); template static void error(Type out, Args... args); static void out(std::string debug); static void out(float debug); static void setLogLevel(int loglevel); private: static void helper(bool err, std::wstring out); template static void helper(bool err, T out); template static void helper(bool err, const Type out, Args... args); static bool printType(int order); static int _loglevel; }; template void Echo::helper(bool err, Type out) { if(err) std::cerr << out; else std::cout << out; } template void Echo::helper(bool err, const Type out, Args... args) { if(err) std::cerr << out; else std::cout << out; helper(err, args...); } template void Echo::out(int order, Type out, Args... args) { if(!printType(order)) return; if(order == Error) { helper(true, out, args...); std::cerr << std::endl; } else { helper(false, out, args...); std::cout << std::endl; } } template void Echo::debug(Type out, Args... args) { if(!printType(Debug)) return; helper(false, out, args...); std::cout << std::endl; } template void Echo::info(Type out, Args... args) { if(!printType(Info)) return; helper(false, out, args...); std::cout << std::endl; } template void Echo::load(Type out, Args... args) { if(!printType(Load)) return; helper(false, out, args...); std::cout << std::endl; } template void Echo::error(Type out, Args... args) { if(!printType(Error)) return; helper(true, out, args...); std::cerr << std::endl; }