mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core: "Initial support for C++11 compilers"
This commit is contained in:
119
src/server/shared/Dynamic/HashNamespace.h
Normal file
119
src/server/shared/Dynamic/HashNamespace.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* 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 (at your
|
||||
* option) 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 TRINITY_HASH_NAMESPACE_H
|
||||
#define TRINITY_HASH_NAMESPACE_H
|
||||
|
||||
#include "Define.h"
|
||||
|
||||
#if COMPILER_HAS_CPP11_SUPPORT
|
||||
# define HASH_NAMESPACE_START namespace std {
|
||||
# define HASH_NAMESPACE_END }
|
||||
#elif defined(_STLPORT_VERSION)
|
||||
# define HASH_NAMESPACE_START namespace std {
|
||||
# define HASH_NAMESPACE_END }
|
||||
#elif COMPILER == COMPILER_MICROSOFT && _MSC_VER >= 1600 // VS100
|
||||
# define HASH_NAMESPACE_START namespace std {
|
||||
# define HASH_NAMESPACE_END }
|
||||
#elif COMPILER == COMPILER_MICROSOFT && _MSC_VER >= 1500 && _HAS_TR1
|
||||
# define HASH_NAMESPACE_START namespace std { namespace tr1 {
|
||||
# define HASH_NAMESPACE_END } }
|
||||
#elif COMPILER == COMPILER_MICROSOFT && _MSC_VER >= 1300
|
||||
# define HASH_NAMESPACE_START namespace stdext {
|
||||
# define HASH_NAMESPACE_END }
|
||||
|
||||
#if !_HAS_TRADITIONAL_STL
|
||||
#ifndef HASH_NAMESPACE
|
||||
#define HASH_NAMESPACE
|
||||
#else
|
||||
|
||||
// can be not used by some platforms, so provide fake forward
|
||||
HASH_NAMESPACE_START
|
||||
|
||||
template<class K>
|
||||
class hash
|
||||
{
|
||||
public:
|
||||
size_t operator() (K const&);
|
||||
};
|
||||
|
||||
HASH_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#elif COMPILER == COMPILER_INTEL
|
||||
# define HASH_NAMESPACE_START namespace std {
|
||||
# define HASH_NAMESPACE_END }
|
||||
#elif COMPILER == COMPILER_GNU && defined(__clang__) && defined(_LIBCPP_VERSION)
|
||||
# define HASH_NAMESPACE_START namespace std {
|
||||
# define HASH_NAMESPACE_END }
|
||||
#elif COMPILER == COMPILER_GNU && GCC_VERSION > 40200
|
||||
# define HASH_NAMESPACE_START namespace std { namespace tr1 {
|
||||
# define HASH_NAMESPACE_END } }
|
||||
#elif COMPILER == COMPILER_GNU && GCC_VERSION >= 30000
|
||||
# define HASH_NAMESPACE_START namespace __gnu_cxx {
|
||||
# define HASH_NAMESPACE_END }
|
||||
|
||||
#include <ext/hash_fun.h>
|
||||
#include <string>
|
||||
|
||||
HASH_NAMESPACE_START
|
||||
|
||||
template<>
|
||||
class hash<unsigned long long>
|
||||
{
|
||||
public:
|
||||
size_t operator()(const unsigned long long &__x) const { return (size_t)__x; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class hash<T *>
|
||||
{
|
||||
public:
|
||||
size_t operator()(T * const &__x) const { return (size_t)__x; }
|
||||
};
|
||||
|
||||
template<> struct hash<std::string>
|
||||
{
|
||||
size_t operator()(const std::string &__x) const
|
||||
{
|
||||
return hash<char const *>()(__x.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
HASH_NAMESPACE_END
|
||||
|
||||
#else
|
||||
# define HASH_NAMESPACE_START namespace std {
|
||||
# define HASH_NAMESPACE_END }
|
||||
#endif
|
||||
|
||||
#if COMPILER != COMPILER_MICROSOFT
|
||||
|
||||
// Visual Studio use non standard hash calculation function, so provide fake forward for other
|
||||
HASH_NAMESPACE_START
|
||||
|
||||
template<class K>
|
||||
size_t hash_value(K const&);
|
||||
|
||||
HASH_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -19,7 +19,8 @@
|
||||
#ifndef _LINKEDLIST
|
||||
#define _LINKEDLIST
|
||||
|
||||
#include "Common.h"
|
||||
#include "Define.h"
|
||||
#include <iterator>
|
||||
|
||||
//============================================
|
||||
class LinkedListHead;
|
||||
@@ -32,7 +33,7 @@ class LinkedListElement
|
||||
LinkedListElement* iNext;
|
||||
LinkedListElement* iPrev;
|
||||
public:
|
||||
LinkedListElement() { iNext = NULL; iPrev = NULL; }
|
||||
LinkedListElement(): iNext(NULL), iPrev(NULL) {}
|
||||
~LinkedListElement() { delink(); }
|
||||
|
||||
bool hasNext() const { return(iNext && iNext->iNext != NULL); }
|
||||
@@ -83,13 +84,12 @@ class LinkedListHead
|
||||
LinkedListElement iLast;
|
||||
uint32 iSize;
|
||||
public:
|
||||
LinkedListHead()
|
||||
LinkedListHead(): iSize(0)
|
||||
{
|
||||
// create empty list
|
||||
|
||||
iFirst.iNext = &iLast;
|
||||
iLast.iPrev = &iFirst;
|
||||
iSize = 0;
|
||||
}
|
||||
|
||||
bool isEmpty() const { return(!iFirst.iNext->isInList()); }
|
||||
@@ -153,13 +153,14 @@ class LinkedListHead
|
||||
|
||||
Iterator& operator=(Iterator const &_Right)
|
||||
{
|
||||
return (*this) = _Right._Ptr;
|
||||
_Ptr = _Right._Ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Iterator& operator=(const_pointer const &_Right)
|
||||
{
|
||||
_Ptr = (pointer)_Right;
|
||||
return (*this);
|
||||
_Ptr = pointer(_Right);
|
||||
return *this;
|
||||
}
|
||||
|
||||
reference operator*()
|
||||
@@ -242,4 +243,3 @@ class LinkedListHead
|
||||
|
||||
//============================================
|
||||
#endif
|
||||
|
||||
|
||||
@@ -57,13 +57,21 @@ template <class TO, class FROM> class Reference : public LinkedListElement
|
||||
|
||||
// We don't need the reference anymore. Call comes from the refFrom object
|
||||
// Tell our refTo object, that the link is cut
|
||||
void unlink() { targetObjectDestroyLink(); delink(); iRefTo = NULL; iRefFrom = NULL; }
|
||||
void unlink()
|
||||
{
|
||||
targetObjectDestroyLink();
|
||||
delink();
|
||||
iRefTo = NULL;
|
||||
iRefFrom = NULL;
|
||||
}
|
||||
|
||||
// Link is invalid due to destruction of referenced target object. Call comes from the refTo object
|
||||
// Tell our refFrom object, that the link is cut
|
||||
void invalidate() // the iRefFrom MUST remain!!
|
||||
{
|
||||
sourceObjectDestroyLink(); delink(); iRefTo = NULL;
|
||||
sourceObjectDestroyLink();
|
||||
delink();
|
||||
iRefTo = NULL;
|
||||
}
|
||||
|
||||
bool isValid() const // Only check the iRefTo
|
||||
@@ -89,4 +97,3 @@ template <class TO, class FROM> class Reference : public LinkedListElement
|
||||
|
||||
//=====================================================
|
||||
#endif
|
||||
|
||||
|
||||
@@ -101,7 +101,6 @@ class ObjectRegistry
|
||||
}
|
||||
private:
|
||||
RegistryMapType i_registeredObjects;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,55 +19,54 @@
|
||||
#ifndef TRINITY_UNORDERED_MAP_H
|
||||
#define TRINITY_UNORDERED_MAP_H
|
||||
|
||||
#include "CompilerDefs.h"
|
||||
#include "Define.h"
|
||||
#include "HashNamespace.h"
|
||||
|
||||
#if COMPILER == COMPILER_INTEL
|
||||
#include <ext/hash_map>
|
||||
#elif COMPILER == COMPILER_GNU && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||
#include <tr1/unordered_map>
|
||||
#elif COMPILER == COMPILER_GNU && __GNUC__ >= 3
|
||||
#include <ext/hash_map>
|
||||
#elif COMPILER == COMPILER_MICROSOFT && _MSC_VER >= 1500 && _HAS_TR1 // VC9.0 and later
|
||||
#include <unordered_map>
|
||||
#if COMPILER_HAS_CPP11_SUPPORT
|
||||
# include <unordered_map>
|
||||
#elif COMPILER == COMPILER_INTEL
|
||||
# include <ext/hash_map>
|
||||
#elif COMPILER == COMPILER_GNU && defined(__clang__) && defined(_LIBCPP_VERSION)
|
||||
# include <unordered_map>
|
||||
#elif COMPILER == COMPILER_GNU && GCC_VERSION > 40200
|
||||
# include <tr1/unordered_map>
|
||||
#elif COMPILER == COMPILER_GNU && GCC_VERSION >= 30000
|
||||
# include <ext/hash_map>
|
||||
#elif COMPILER == COMPILER_MICROSOFT && ((_MSC_VER >= 1500 && _HAS_TR1) || _MSC_VER >= 1700) // VC9.0 SP1 and later
|
||||
# include <unordered_map>
|
||||
#else
|
||||
#include <hash_map>
|
||||
# include <hash_map>
|
||||
#endif
|
||||
|
||||
#ifdef _STLPORT_VERSION
|
||||
#define UNORDERED_MAP std::hash_map
|
||||
using std::hash_map;
|
||||
# define UNORDERED_MAP std::hash_map
|
||||
# define UNORDERED_MULTIMAP std::hash_multimap
|
||||
#elif COMPILER_HAS_CPP11_SUPPORT
|
||||
# define UNORDERED_MAP std::unordered_map
|
||||
# define UNORDERED_MULTIMAP std::unordered_multimap
|
||||
#elif COMPILER == COMPILER_MICROSOFT && _MSC_VER >= 1600 // VS100
|
||||
# define UNORDERED_MAP std::tr1::unordered_map
|
||||
# define UNORDERED_MULTIMAP std::tr1::unordered_multimap
|
||||
#elif COMPILER == COMPILER_MICROSOFT && _MSC_VER >= 1500 && _HAS_TR1
|
||||
#define UNORDERED_MAP std::tr1::unordered_map
|
||||
# define UNORDERED_MAP std::tr1::unordered_map
|
||||
# define UNORDERED_MULTIMAP std::tr1::unordered_multimap
|
||||
#elif COMPILER == COMPILER_MICROSOFT && _MSC_VER >= 1300
|
||||
#define UNORDERED_MAP stdext::hash_map
|
||||
using stdext::hash_map;
|
||||
#elif COMPILER == COMPILER_GNU && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||
#define UNORDERED_MAP std::tr1::unordered_map
|
||||
#elif (COMPILER == COMPILER_GNU && __GNUC__ >= 3) || COMPILER == COMPILER_INTEL
|
||||
#define UNORDERED_MAP __gnu_cxx::hash_map
|
||||
|
||||
namespace __gnu_cxx
|
||||
{
|
||||
template<> struct hash<unsigned long long>
|
||||
{
|
||||
size_t operator()(const unsigned long long &__x) const { return (size_t)__x; }
|
||||
};
|
||||
template<typename T> struct hash<T *>
|
||||
{
|
||||
size_t operator()(T * const &__x) const { return (size_t)__x; }
|
||||
};
|
||||
template<> struct hash<std::string>
|
||||
{
|
||||
size_t operator()(const std::string &__x) const
|
||||
{
|
||||
return hash<const char *>()(__x.c_str());
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
# define UNORDERED_MAP stdext::hash_map
|
||||
# define UNORDERED_MULTIMAP stdext::hash_multimap
|
||||
#elif COMPILER == COMPILER_INTEL
|
||||
# define UNORDERED_MAP std::hash_map
|
||||
# define UNORDERED_MULTIMAP std::hash_multimap
|
||||
#elif COMPILER == COMPILER_GNU && defined(__clang__) && defined(_LIBCPP_VERSION)
|
||||
# define UNORDERED_MAP std::unordered_map
|
||||
# define UNORDERED_MULTIMAP std::unordered_multimap
|
||||
#elif COMPILER == COMPILER_GNU && GCC_VERSION > 40200
|
||||
# define UNORDERED_MAP std::tr1::unordered_map
|
||||
# define UNORDERED_MULTIMAP std::tr1::unordered_multimap
|
||||
#elif COMPILER == COMPILER_GNU && GCC_VERSION >= 30000
|
||||
# define UNORDERED_MAP __gnu_cxx::hash_map
|
||||
# define UNORDERED_MULTIMAP __gnu_cxx::hash_multimap
|
||||
#else
|
||||
#define UNORDERED_MAP std::hash_map
|
||||
using std::hash_map;
|
||||
# define UNORDERED_MAP std::hash_map
|
||||
# define UNORDERED_MULTIMAP std::hash_multimap
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
66
src/server/shared/Dynamic/UnorderedSet.h
Normal file
66
src/server/shared/Dynamic/UnorderedSet.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* 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 (at your
|
||||
* option) 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 TRINITY_UNORDERED_SET_H
|
||||
#define TRINITY_UNORDERED_SET_H
|
||||
|
||||
#include "HashNamespace.h"
|
||||
|
||||
#if COMPILER_HAS_CPP11_SUPPORT
|
||||
# include <unordered_set>
|
||||
#elif COMPILER == COMPILER_INTEL
|
||||
# include <ext/hash_set>
|
||||
#elif COMPILER == COMPILER_GNU && defined(__clang__) && defined(_LIBCPP_VERSION)
|
||||
# include <unordered_set>
|
||||
#elif COMPILER == COMPILER_GNU && GCC_VERSION > 40200
|
||||
# include <tr1/unordered_set>
|
||||
#elif COMPILER == COMPILER_GNU && GCC_VERSION >= 30000
|
||||
# include <ext/hash_set>
|
||||
#elif COMPILER == COMPILER_MICROSOFT && ((_MSC_VER >= 1500 && _HAS_TR1) || _MSC_VER >= 1700) // VC9.0 SP1 and later
|
||||
# include <unordered_set>
|
||||
#else
|
||||
# include <hash_set>
|
||||
#endif
|
||||
|
||||
#ifdef _STLPORT_VERSION
|
||||
# define UNORDERED_SET std::hash_set
|
||||
using std::hash_set;
|
||||
#elif COMPILER_HAS_CPP11_SUPPORT
|
||||
# define UNORDERED_SET std::unordered_set
|
||||
#elif COMPILER == COMPILER_MICROSOFT && _MSC_VER >= 1600 // VS100
|
||||
# define UNORDERED_SET std::tr1::unordered_set
|
||||
#elif COMPILER == COMPILER_MICROSOFT && _MSC_VER >= 1500 && _HAS_TR1
|
||||
# define UNORDERED_SET std::tr1::unordered_set
|
||||
#elif COMPILER == COMPILER_MICROSOFT && _MSC_VER >= 1300
|
||||
# define UNORDERED_SET stdext::hash_set
|
||||
using stdext::hash_set;
|
||||
#elif COMPILER == COMPILER_INTEL
|
||||
# define UNORDERED_SET std::hash_set
|
||||
using std::hash_set;
|
||||
#elif COMPILER == COMPILER_GNU && defined(__clang__) && defined(_LIBCPP_VERSION)
|
||||
# define UNORDERED_SET std::unordered_set
|
||||
#elif COMPILER == COMPILER_GNU && GCC_VERSION > 40200
|
||||
# define UNORDERED_SET std::tr1::unordered_set
|
||||
#elif COMPILER == COMPILER_GNU && GCC_VERSION >= 30000
|
||||
# define UNORDERED_SET __gnu_cxx::hash_set
|
||||
#else
|
||||
# define UNORDERED_SET std::hash_set
|
||||
using std::hash_set;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user