1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Minor changes to the LongInt type.

This commit is contained in:
Sandu Liviu Catalin 2016-05-23 18:45:21 +03:00
parent c135d4293e
commit 250407feda
2 changed files with 24 additions and 11 deletions

View File

@ -3,8 +3,9 @@
#include "Library/Random.hpp"
// ------------------------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <cerrno>
#include <cstdlib>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
@ -12,8 +13,14 @@ namespace SqMod {
// ------------------------------------------------------------------------------------------------
LongInt< Int64 >::LongInt(CSStr text) : m_Data(0), m_Text()
{ m_Data = strtoll(text, NULL, 10); }
LongInt< Int64 >::LongInt(CSStr text, Object & /* null */) : m_Data(0), m_Text()
{ m_Data = strtoll(text, NULL, 10); }
LongInt< Int64 >::LongInt(CSStr text, SQInteger fall) : m_Data(0), m_Text()
{
m_Data = strtoll(text, NULL, 10);
if (errno == ERANGE)
{
m_Data = ConvTo< Type >::From(fall);
}
}
// ------------------------------------------------------------------------------------------------
LongInt< Int64 > & LongInt< Int64 >::operator = (CSStr text)
@ -41,13 +48,19 @@ void LongInt< Int64 >::Random(Type m, Type n) { m_Data = GetRandomInt64(m, n); }
// ------------------------------------------------------------------------------------------------
LongInt< Uint64 >::LongInt(CSStr text) : m_Data(0), m_Text()
{ m_Data = strtoll(text, NULL, 10); }
LongInt< Uint64 >::LongInt(CSStr text, Object & /* null */) : m_Data(0), m_Text()
{ m_Data = strtoll(text, NULL, 10); }
LongInt< Uint64 >::LongInt(CSStr text, SQInteger fall) : m_Data(0), m_Text()
{
m_Data = strtoull(text, NULL, 10);
if (errno == ERANGE)
{
m_Data = ConvTo< Type >::From(fall);
}
}
// ------------------------------------------------------------------------------------------------
LongInt< Uint64 > & LongInt< Uint64 >::operator = (CSStr text)
{
m_Data = strtoll(text, NULL, 10);
m_Data = strtoull(text, NULL, 10);
return *this;
}
@ -74,7 +87,7 @@ void Register_Numeric(HSQUIRRELVM vm)
/* Constructors */
.Ctor()
.Ctor< SLongInt::Type >()
.template Ctor< CCStr, Object & >()
.template Ctor< CCStr, SQInteger >()
/* Properties */
.Prop(_SC("Str"), &SLongInt::GetCStr, &SLongInt::SetStr)
.Prop(_SC("Num"), &SLongInt::GetSNum, &SLongInt::SetNum)
@ -110,7 +123,7 @@ void Register_Numeric(HSQUIRRELVM vm)
/* Constructors */
.Ctor()
.Ctor< ULongInt::Type >()
.Ctor< CCStr, Object & >()
.Ctor< CCStr, SQInteger >()
/* Properties */
.Prop(_SC("Str"), &ULongInt::GetCStr, &ULongInt::SetStr)
.Prop(_SC("Num"), &ULongInt::GetSNum, &ULongInt::SetNum)

View File

@ -37,7 +37,7 @@ public:
*
*/
LongInt(CSStr text);
LongInt(CSStr text, Object & /* null */);
LongInt(CSStr text, SQInteger fall);
/* --------------------------------------------------------------------------------------------
*
@ -296,7 +296,7 @@ public:
*
*/
LongInt(CSStr text);
LongInt(CSStr text, Object & /* null */);
LongInt(CSStr text, SQInteger fall);
/* --------------------------------------------------------------------------------------------
*