From 41cc92f73e39cec5dfea6b1164176610cccc7df4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Aug 2015 13:58:32 +0300 Subject: Add strong typed int for item color. --- src/enums/simpletypes/intdefines.h | 6 ++++-- src/enums/simpletypes/itemcolor.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/enums/simpletypes/itemcolor.h (limited to 'src/enums') diff --git a/src/enums/simpletypes/intdefines.h b/src/enums/simpletypes/intdefines.h index 984e9d411..975c63c3f 100644 --- a/src/enums/simpletypes/intdefines.h +++ b/src/enums/simpletypes/intdefines.h @@ -29,7 +29,8 @@ enum class name : type \ { \ }; \ - const name name##_zero = static_cast(0) + const name name##_zero = static_cast(0); \ + const name name##_one = static_cast(1) #define fromInt(val, name) static_cast(val) #define toInt(val, name) static_cast(val) @@ -39,7 +40,8 @@ #define defIntEnum(name, type) \ typedef type name; \ - const name name##_zero = 0 + const name name##_zero = 0; \ + const name name##_one = 1 #define fromInt(val, name) (val) #define toInt(val, name) (val) #define defIntEnumNeg(name) const name name##_negOne = -1 diff --git a/src/enums/simpletypes/itemcolor.h b/src/enums/simpletypes/itemcolor.h new file mode 100644 index 000000000..55966596e --- /dev/null +++ b/src/enums/simpletypes/itemcolor.h @@ -0,0 +1,29 @@ +/* + * The ManaPlus Client + * Copyright (C) 2015 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 . + */ + +#ifndef ENUMS_SIMPLETYPES_ITEMCOLOR_H +#define ENUMS_SIMPLETYPES_ITEMCOLOR_H + +#include "enums/simpletypes/intdefines.h" + +defIntEnum(ItemColor, uint16_t); +defIntEnumNeg(ItemColor); + +#endif // ENUMS_SIMPLETYPES_ITEMCOLOR_H -- cgit v1.2.3-70-g09d2