mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-17 04:51:52 +00:00
Visual Studio 2013 compilation support for NLMISC
--HG-- branch : develop
This commit is contained in:
parent
cb986cba6f
commit
f5335f068d
7 changed files with 41 additions and 29 deletions
|
@ -264,6 +264,40 @@ inline bool fromString(const std::string &str, bool &val)
|
|||
return true;
|
||||
}
|
||||
|
||||
inline bool fromString(const char *str, uint32 &val) { if (strstr(str, "-") != NULL) { val = 0; return false; } char *end; unsigned long v; errno = 0; v = strtoul(str, &end, 10); if (errno || v > UINT_MAX || end == str) { val = 0; return false; } else { val = (uint32)v; return true; } }
|
||||
inline bool fromString(const char *str, sint32 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > INT_MAX || v < INT_MIN || end == str) { val = 0; return false; } else { val = (sint32)v; return true; } }
|
||||
inline bool fromString(const char *str, uint8 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > UCHAR_MAX || v < 0 || end == str) { val = 0; return false; } else { val = (uint8)v; return true; } }
|
||||
inline bool fromString(const char *str, sint8 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > SCHAR_MAX || v < SCHAR_MIN || end == str) { val = 0; return false; } else { val = (sint8)v; return true; } }
|
||||
inline bool fromString(const char *str, uint16 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > USHRT_MAX || v < 0 || end == str) { val = 0; return false; } else { val = (uint16)v; return true; } }
|
||||
inline bool fromString(const char *str, sint16 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > SHRT_MAX || v < SHRT_MIN || end == str) { val = 0; return false; } else { val = (sint16)v; return true; } }
|
||||
inline bool fromString(const char *str, uint64 &val) { bool ret = sscanf(str, "%"NL_I64"u", &val) == 1; if (!ret) val = 0; return ret; }
|
||||
inline bool fromString(const char *str, sint64 &val) { bool ret = sscanf(str, "%"NL_I64"d", &val) == 1; if (!ret) val = 0; return ret; }
|
||||
inline bool fromString(const char *str, float &val) { bool ret = sscanf(str, "%f", &val) == 1; if (!ret) val = 0.0f; return ret; }
|
||||
inline bool fromString(const char *str, double &val) { bool ret = sscanf(str, "%lf", &val) == 1; if (!ret) val = 0.0; return ret; }
|
||||
|
||||
inline bool fromString(const char *str, bool &val)
|
||||
{
|
||||
switch (str[0])
|
||||
{
|
||||
case '1':
|
||||
case 't':
|
||||
case 'y':
|
||||
case 'T':
|
||||
case 'Y':
|
||||
val = true;
|
||||
return true;
|
||||
case '0':
|
||||
case 'f':
|
||||
case 'n':
|
||||
case 'F':
|
||||
case 'N':
|
||||
val = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool fromString(const std::string &str, std::string &val) { val = str; return true; }
|
||||
|
||||
// stl vectors of bool use bit reference and not real bools, so define the operator for bit reference
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
~CXMLAutoPtr() { destroy(); }
|
||||
operator const char *() const { return _Value; }
|
||||
operator bool() const { return _Value != NULL; }
|
||||
operator std::string() const { return std::string(_Value); }
|
||||
inline std::string str() const { return _Value; }
|
||||
bool operator ! () const { return _Value == NULL; }
|
||||
operator const unsigned char *() const { return (const unsigned char *) _Value; }
|
||||
char operator * () const { nlassert(_Value); return *_Value; }
|
||||
|
|
|
@ -19,12 +19,6 @@
|
|||
#include "nel/misc/types_nl.h"
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
# define _WIN32_WINDOWS 0x0410
|
||||
# ifndef NL_COMP_MINGW
|
||||
# define WINVER 0x0400
|
||||
# define NOMINMAX
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# include <direct.h>
|
||||
# include <tchar.h>
|
||||
# include <imagehlp.h>
|
||||
|
|
|
@ -18,16 +18,7 @@
|
|||
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
// these defines is for IsDebuggerPresent(). it'll not compile on windows 95
|
||||
// just comment this and the IsDebuggerPresent to compile on windows 95
|
||||
# define _WIN32_WINDOWS 0x0410
|
||||
# ifndef NL_COMP_MINGW
|
||||
# define WINVER 0x0400
|
||||
# define NOMINMAX
|
||||
# endif
|
||||
# include <windows.h>
|
||||
#else
|
||||
#ifndef NL_OS_WINDOWS
|
||||
# define IsDebuggerPresent() false
|
||||
#endif
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ static string getFuncInfo (DWORD_TYPE funcAddr, DWORD_TYPE stackAddr)
|
|||
if (stop==0 && (parse[i] == ',' || parse[i] == ')'))
|
||||
{
|
||||
char tmp[32];
|
||||
sprintf (tmp, "=0x%p", *((ULONG*)(stackAddr) + 2 + pos++));
|
||||
sprintf(tmp, "=0x%p", *((DWORD_TYPE*)(stackAddr) + 2 + pos++));
|
||||
str += tmp;
|
||||
}
|
||||
str += parse[i];
|
||||
|
|
|
@ -41,15 +41,6 @@ using namespace std;
|
|||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
|
||||
// these defines are for IsDebuggerPresent(). It'll not compile on windows 95
|
||||
// just comment this and the IsDebuggerPresent to compile on windows 95
|
||||
#define _WIN32_WINDOWS 0x0410
|
||||
#ifndef NL_COMP_MINGW
|
||||
# define WINVER 0x0400
|
||||
# define NOMINMAX
|
||||
#endif
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef DEBUG_NEW
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
|
|
@ -43,8 +43,10 @@
|
|||
#include <vector>
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef __MINGW32__
|
||||
#define NOMINMAX
|
||||
# define _WIN32_WINDOWS 0x0410
|
||||
# ifndef NL_COMP_MINGW
|
||||
# define WINVER 0x0400
|
||||
# define NOMINMAX
|
||||
# endif
|
||||
# include <WinSock2.h>
|
||||
# include <windows.h>
|
||||
|
|
Loading…
Reference in a new issue