#ifndef __SELLA_NMS_WRAPPER_HASH_MAP__
#define __SELLA_NMS_WRAPPER_HASH_MAP__

#include "defaults.h"

#ifdef HAVE_STLPORT
	#include <utility>
	#include <hash_map>
	/* Hash function for pair<u_int32_t, int> */
	_STLP_BEGIN_NAMESPACE
	_STLP_TEMPLATE_NULL struct hash<pair<u_int32_t, int> > {
		size_t operator()(const pair<u_int32_t, int>& p) const {
			char	key[9];
			memcpy(&(key[0]), &(p.first), sizeof(u_int32_t));
			memcpy(&(key[4]), &(p.second), sizeof(int));
			key[8] = 0;

			return hash<char const*>()(key);
		}
	};
	_STLP_END_NAMESPACE
	namespace sella_nms { using stlport::hash_map; };
#else
	#ifdef __GNUC__
		#if __GNUC__ < 3
			#include <string>
			#include <hash_map>
			/* Hash function for string */
			template<> struct hash<std::string> {
				std::size_t operator()(const std::string& s) const { return hash<char const*>()(s.c_str()); }
			};
			/* Hash function for pair<u_int32_t, int> */
			template<> struct hash<std::pair<u_int32_t, int> > {
				std::size_t operator()(const std::pair<u_int32_t, int>& p) const {
					char	key[9];
					memcpy(&(key[0]), &(p.first), sizeof(u_int32_t));
					memcpy(&(key[4]), &(p.second), sizeof(int));
					key[8] = 0;

					return hash<char const*>()(key);
				}
			};
			namespace sella_nms { using ::hash_map; };
		#else
			#include <string>
			#include <ext/hash_map>
			#if __GNUC_MINOR__ == 0 // gcc 3.0
				namespace std {
					/* Hash function for string */
					template<> struct hash<std::string> {
						std::size_t operator()(const std::string& s) const { return hash<char const*>()(s.c_str()); }
					};
					/* Hash function for pair<u_int32_t, int> */
					template<> struct hash<std::pair<u_int32_t, int> > {
						std::size_t operator()(const std::pair<u_int32_t, int>& p) const {
							char	key[9];
							memcpy(&(key[0]), &(p.first), sizeof(u_int32_t));
							memcpy(&(key[4]), &(p.second), sizeof(int));
							key[8] = 0;

							return hash<char const*>()(key);
						}
					};
				}
				namespace sella_nms { using std::hash_map; }
			#else // gcc 3.1+
				namespace __gnu_cxx {
					/* Hash function for string */
					template<> struct hash<std::string> {
						std::size_t operator()(const std::string& s) const { return hash<char const*>()(s.c_str()); }
					};
					/* Hash function for pair<u_int32_t, int> */
					template<> struct hash<std::pair<u_int32_t, int> > {
						std::size_t operator()(const std::pair<u_int32_t, int>& p) const {
							char	key[9];
							memcpy(&(key[0]), &(p.first), sizeof(u_int32_t));
							memcpy(&(key[4]), &(p.second), sizeof(int));
							key[8] = 0;

							return hash<char const*>()(key);
						}
					};
				}
				namespace sella_nms { using namespace __gnu_cxx; }
			#endif
		#endif
	#else // non-gcc compiler
		#include <hash_map>
		namespace sella_nms { using namespace std; }
	#endif
#endif

#endif
