| 1 |
/** |
| 2 |
* Furnace Tracker - multi-system chiptune tracker |
| 3 |
* Copyright (C) 2021-2025 tildearrow and contributors |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 2 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License along |
| 16 |
* with this program; if not, write to the Free Software Foundation, Inc., |
| 17 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#ifndef _TA_UTILS_H |
| 21 |
#define _TA_UTILS_H |
| 22 |
#include <stdio.h> |
| 23 |
#include <string.h> |
| 24 |
#include <assert.h> |
| 25 |
#include "pch.h" |
| 26 |
|
| 27 |
#ifdef _MSC_VER |
| 28 |
#include <BaseTsd.h> |
| 29 |
typedef SSIZE_T ssize_t; |
| 30 |
#endif |
| 31 |
|
| 32 |
#ifdef _WIN32 |
| 33 |
#define DIR_SEPARATOR '\\' |
| 34 |
#define DIR_SEPARATOR_STR "\\" |
| 35 |
#else |
| 36 |
#define DIR_SEPARATOR '/' |
| 37 |
#define DIR_SEPARATOR_STR "/" |
| 38 |
#endif |
| 39 |
|
| 40 |
typedef std::string String; |
| 41 |
|
| 42 |
#define MIN(a,b) (((a)<(b))?(a):(b)) |
| 43 |
#define MAX(a,b) (((a)>(b))?(a):(b)) |
| 44 |
#define CLAMP(x,xMin,xMax) (MIN(MAX((x),(xMin)),(xMax))) |
| 45 |
|
| 46 |
#ifdef HAVE_LOCALE |
| 47 |
#ifdef HAVE_MOMO |
| 48 |
#include <momo.h> |
| 49 |
#define _(_str) momo_gettext(_str) |
| 50 |
#else |
| 51 |
#include <libintl.h> |
| 52 |
#define _(_str) gettext(_str) |
| 53 |
#endif |
| 54 |
#else |
| 55 |
#define _(_str) _str |
| 56 |
#endif |
| 57 |
|
| 58 |
#define _GN(_strS,_strP,_cond) (((_cond)==1)?(_strS):(_strP)) |
| 59 |
#define _N(_str) _str |
| 60 |
|
| 61 |
typedef std::wstring WString; |
| 62 |
|
| 63 |
enum TAParamResult { |
| 64 |
TA_PARAM_ERROR=0, |
| 65 |
TA_PARAM_SUCCESS, |
| 66 |
TA_PARAM_QUIT |
| 67 |
}; |
| 68 |
|
| 69 |
struct TAParam { |
| 70 |
String shortName; |
| 71 |
String name; |
| 72 |
String valName; |
| 73 |
String desc; |
| 74 |
bool value; |
| 75 |
TAParamResult (*func)(String); |
| 76 |
TAParam(const String& sn, const String& n, bool v, TAParamResult (*f)(String), const String& vn, const String& d): |
| 77 |
shortName(sn), |
| 78 |
name(n), |
| 79 |
valName(vn), |
| 80 |
desc(d), |
| 81 |
value(v), |
| 82 |
func(f) {} |
| 83 |
}; |
| 84 |
|
| 85 |
void reportError(String what); |
| 86 |
|
| 87 |
#endif |