--- a/src/misc.h Mon Jun 01 17:06:13 2015 +0300 +++ b/src/misc.h Fri Jun 05 18:33:51 2015 +0300 @@ -1,6 +1,6 @@ /* * ZCinema: Zandronum demo launcher - * Copyright (C) 2013 Santeri Piippo + * Copyright (C) 2013-2015 Teemu Piippo * * 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 @@ -16,38 +16,51 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef ZCINEMA_MISC_H -#define ZCINEMA_MISC_H - +#pragma once #include "types.h" uint32 makeByteID (uint8 a, uint8 b, uint8 c, uint8 d); -str binaryConfigName (str ver); -str basename (str path); -void addVersion (str name, bool isRelease, str binaryPath); -bool confirm (str text); - +QString basename (const QString& path); +void addVersion (const ZandronumVersion& version); +bool confirm (const QString& text); QList<QVariant> getVersions(); +// // ----------------------------------------------------------------------------- -// Templated clamp -template<class T> static inline T clamp (T a, T min, T max) { +// + +template<typename T> +T clamp (T a, T min, T max) +{ return (a > max) ? max : (a < min) ? min : a; } -// Templated minimum -template<class T> static inline T min (T a, T b) { +// +// ----------------------------------------------------------------------------- +// + +template<typename T> +T min (T a, T b) +{ return (a < b) ? a : b; } -// Templated maximum -template<class T> static inline T max (T a, T b) { +// +// ----------------------------------------------------------------------------- +// + +template<typename T> +T max (T a, T b) +{ return (a > b) ? a : b; } -// Templated absolute value -template<class T> static inline T abs (T a) { - return (a >= 0) ? a : -a; -} +// +// ----------------------------------------------------------------------------- +// -#endif // ZCINEMA_MISC_H \ No newline at end of file +template<typename T> +T abs (T a) +{ + return (a < 0) ? -a : a; +} \ No newline at end of file