summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-06-29 20:13:40 +0300
committerAndrei Karas <akaras@inbox.ru>2017-06-29 20:53:57 +0300
commit36c45ae7d8d2577a900ec266b64448d4b488013d (patch)
tree419024ce46e507c2abb0578d15d787093556b246 /src/utils
parent864e023e0faeca5aa662023a54af7e4f9797fafa (diff)
downloadplus-36c45ae7d8d2577a900ec266b64448d4b488013d.tar.gz
plus-36c45ae7d8d2577a900ec266b64448d4b488013d.tar.bz2
plus-36c45ae7d8d2577a900ec266b64448d4b488013d.tar.xz
plus-36c45ae7d8d2577a900ec266b64448d4b488013d.zip
Move cast macroses into separate file.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/base64.cpp2
-rw-r--r--src/utils/buildhex.h2
-rw-r--r--src/utils/cast.h33
-rw-r--r--src/utils/mathutils.h2
-rw-r--r--src/utils/mathutils_unittest.cc1
-rw-r--r--src/utils/sdlpixel.h2
-rw-r--r--src/utils/stringutils.cpp1
-rw-r--r--src/utils/stringutils_unittest.cc1
8 files changed, 44 insertions, 0 deletions
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
index 9f1c2a1d4..62ba76f21 100644
--- a/src/utils/base64.cpp
+++ b/src/utils/base64.cpp
@@ -29,6 +29,8 @@
#include "utils/base64.h"
+#include "utils/cast.h"
+
#include "debug.h"
static char base64_table[] =
diff --git a/src/utils/buildhex.h b/src/utils/buildhex.h
index 0a4349bac..777d19784 100644
--- a/src/utils/buildhex.h
+++ b/src/utils/buildhex.h
@@ -21,6 +21,8 @@
#ifndef UTILS_BUILDHEX_H
#define UTILS_BUILDHEX_H
+#include "utils/cast.h"
+
#include "localconsts.h"
PRAGMA48(GCC diagnostic push)
diff --git a/src/utils/cast.h b/src/utils/cast.h
new file mode 100644
index 000000000..9b6289ebc
--- /dev/null
+++ b/src/utils/cast.h
@@ -0,0 +1,33 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2017 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * 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; either version 2 of the License, or
+ * any later version.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef UTILS_CAST_H
+#define UTILS_CAST_H
+
+#define CAST_8 static_cast<char>
+#define CAST_S8 static_cast<int8_t>
+#define CAST_U8 static_cast<uint8_t>
+#define CAST_S16 static_cast<int16_t>
+#define CAST_U16 static_cast<uint16_t>
+#define CAST_S32 static_cast<int32_t>
+#define CAST_U32 static_cast<uint32_t>
+#define CAST_SIZE static_cast<size_t>
+
+#endif // UTILS_CAST_H
diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h
index b82ad3065..045feb10a 100644
--- a/src/utils/mathutils.h
+++ b/src/utils/mathutils.h
@@ -23,6 +23,8 @@
#ifndef UTILS_MATHUTILS_H
#define UTILS_MATHUTILS_H
+#include "utils/cast.h"
+
#include <string>
#ifndef USE_SDL2
diff --git a/src/utils/mathutils_unittest.cc b/src/utils/mathutils_unittest.cc
index 187accf74..c7a545f87 100644
--- a/src/utils/mathutils_unittest.cc
+++ b/src/utils/mathutils_unittest.cc
@@ -20,6 +20,7 @@
#include "test/unittests.h"
+#include "utils/cast.h"
#include "utils/mathutils.h"
#include "debug.h"
diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h
index 920ad4164..54e7e0b41 100644
--- a/src/utils/sdlpixel.h
+++ b/src/utils/sdlpixel.h
@@ -66,6 +66,8 @@
#include "gui/color.h"
+#include "utils/cast.h"
+
PRAGMA48(GCC diagnostic push)
PRAGMA48(GCC diagnostic ignored "-Wshadow")
#include <SDL.h>
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 201ffc0c4..71a82f16f 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -30,6 +30,7 @@
#include "resources/db/itemdb.h"
#endif // DYECMD
+#include "utils/cast.h"
#include "utils/gettext.h"
#include "utils/foreach.h"
diff --git a/src/utils/stringutils_unittest.cc b/src/utils/stringutils_unittest.cc
index 354232965..19670db99 100644
--- a/src/utils/stringutils_unittest.cc
+++ b/src/utils/stringutils_unittest.cc
@@ -27,6 +27,7 @@
#include "fs/virtfs/fs.h"
+#include "utils/cast.h"
#include "utils/delete2.h"
#include "utils/dtor.h"