From 0f9ec2061c4ad6157c3186f1cab9c4d8558980b5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 29 May 2015 14:30:20 +0300 Subject: Add strong typed int type BeingId. --- src/enums/simpletypes/beingid.h | 34 ++++++++++++++++++++++++++++++++++ src/enums/simpletypes/intdefines.h | 7 ++++++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/enums/simpletypes/beingid.h (limited to 'src/enums/simpletypes') diff --git a/src/enums/simpletypes/beingid.h b/src/enums/simpletypes/beingid.h new file mode 100644 index 000000000..dddd83932 --- /dev/null +++ b/src/enums/simpletypes/beingid.h @@ -0,0 +1,34 @@ +/* + * 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_BEINGID_H +#define ENUMS_SIMPLETYPES_BEINGID_H + +#include "enums/simpletypes/intdefines.h" + +defIntEnum(BeingId, int); + +#ifdef ADVGCC +const BeingId BeingId_negOne = static_cast(-1); +#else +const BeingId BeingId_negOne = -1; +#endif + +#endif // ENUMS_SIMPLETYPES_BEINGID_H diff --git a/src/enums/simpletypes/intdefines.h b/src/enums/simpletypes/intdefines.h index 56e052ce3..765318cdc 100644 --- a/src/enums/simpletypes/intdefines.h +++ b/src/enums/simpletypes/intdefines.h @@ -29,13 +29,18 @@ enum class name : type \ { \ }; \ + const name name##_zero = static_cast(0) + #define fromInt(val, name) static_cast(val) +#define toInt(val, name) static_cast(val) #else // ADVGCC #define defIntEnum(name, type) \ - typedef type name + typedef type name; \ + const name name##_zero = 0 #define fromInt(val, name) (val) +#define toInt(val, name) (val) #endif // ADVGCC -- cgit v1.2.3-60-g2f50