mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-21 09:37:13 +02:00
Initial commit.
This commit is contained in:
source
Base
AABB.cppAABB.hppCircle.cppCircle.hppColor3.cppColor3.hppColor4.cppColor4.hppQuaternion.cppQuaternion.hppShared.cppShared.hppSphere.cppSphere.hppVector2f.cppVector2f.hppVector2i.cppVector2i.hppVector2u.cppVector2u.hppVector3.cppVector3.hppVector4.cppVector4.hpp
Common.cppCommon.hppConfig.hppCore.cppCore.hppEntity.cppEntity.hppEntity
Blip.cppBlip.hppCheckpoint.cppCheckpoint.hppKeybind.cppKeybind.hppObject.cppObject.hppPickup.cppPickup.hppPlayer.cppPlayer.hppSphere.cppSphere.hppSprite.cppSprite.hppTextdraw.cppTextdraw.hppVehicle.cppVehicle.hpp
Iterators.cppIterators.hppLibrary
CFG.cppCFG.hppDatetime.cppDatetime.hppFileIO.cppFileIO.hppFormat.cppFormat.hppINI.cppINI.hppJSON.cppJSON.hppLongInt.cppLongInt.hppMath.cppMath.hppNumeric.cppNumeric.hppShared.cppShared.hppString.cppString.hppSysPath.cppSysPath.hppSystem.cppSystem.hppTimer.cppTimer.hppUtils.cppUtils.hppXML.cppXML.hpp
Logger.cppLogger.hppMisc
Automobile.cppAutomobile.hppConstants.cppConstants.hppFunctions.cppFunctions.hppModel.cppModel.hppPlayerImmunity.cppPlayerImmunity.hppRadio.cppRadio.hppShared.cppShared.hppSkin.cppSkin.hppSound.cppSound.hppVehicleImmunity.cppVehicleImmunity.hppWastedSettings.cppWastedSettings.hppWeapon.cppWeapon.hppWorldBounds.cppWorldBounds.hpp
Register.cppRegister.hppSignal.hppUtility
13
source/Library/CFG.cpp
Normal file
13
source/Library/CFG.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Library/CFG.hpp"
|
||||
#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_CFG(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
16
source/Library/CFG.hpp
Normal file
16
source/Library/CFG.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LIBRARY_CFG_HPP_
|
||||
#define _LIBRARY_CFG_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Config.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_CFG_HPP_
|
13
source/Library/Datetime.cpp
Normal file
13
source/Library/Datetime.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Library/Datetime.hpp"
|
||||
#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_Datetime(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
16
source/Library/Datetime.hpp
Normal file
16
source/Library/Datetime.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LIBRARY_DATETIME_HPP_
|
||||
#define _LIBRARY_DATETIME_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Config.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_DATETIME_HPP_
|
13
source/Library/FileIO.cpp
Normal file
13
source/Library/FileIO.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Library/FileIO.hpp"
|
||||
#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_FileIO(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
16
source/Library/FileIO.hpp
Normal file
16
source/Library/FileIO.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LIBRARY_FILEIO_HPP_
|
||||
#define _LIBRARY_FILEIO_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Config.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_FILEIO_HPP_
|
166
source/Library/Format.cpp
Normal file
166
source/Library/Format.cpp
Normal file
@ -0,0 +1,166 @@
|
||||
#include "Library/Format.hpp"
|
||||
#include "Register.hpp"
|
||||
#include "Logger.hpp"
|
||||
#include "Core.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <format.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const SQChar * GetTypeName(SQObjectType type_id) noexcept
|
||||
{
|
||||
switch (type_id)
|
||||
{
|
||||
case OT_INTEGER:
|
||||
return _SC("integer");
|
||||
case OT_FLOAT:
|
||||
return _SC("float");
|
||||
case OT_STRING:
|
||||
return _SC("string");
|
||||
case OT_BOOL:
|
||||
return _SC("boolean");
|
||||
case OT_USERPOINTER:
|
||||
return _SC("user pointer");
|
||||
case OT_NULL:
|
||||
return _SC("null");
|
||||
case OT_TABLE:
|
||||
return _SC("table");
|
||||
case OT_ARRAY:
|
||||
return _SC("array");
|
||||
case OT_CLOSURE:
|
||||
return _SC("closure");
|
||||
case OT_NATIVECLOSURE:
|
||||
return _SC("native closure");
|
||||
case OT_GENERATOR:
|
||||
return _SC("generator");
|
||||
case OT_USERDATA:
|
||||
return _SC("user data");
|
||||
case OT_THREAD:
|
||||
return _SC("thread");
|
||||
case OT_CLASS:
|
||||
return _SC("class");
|
||||
case OT_INSTANCE:
|
||||
return _SC("instance");
|
||||
case OT_WEAKREF:
|
||||
return _SC("weak reference");
|
||||
default:
|
||||
return _SC("unknown");
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
String GetFormatStr(HSQUIRRELVM vm, SQInteger arg, SQInteger args) noexcept
|
||||
{
|
||||
if (sq_gettype(vm, arg) == OT_STRING)
|
||||
{
|
||||
const SQChar * str = 0;
|
||||
sq_getstring(vm, arg, &str);
|
||||
return GetFormatStr(vm, (str == NULL ? "" : str), ++arg, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogErr("Expecting format string but got: %s", GetTypeName(sq_gettype(vm, arg)));
|
||||
}
|
||||
return String();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
String GetFormatStr(HSQUIRRELVM vm, const String & fstr, SQInteger arg, SQInteger args) noexcept
|
||||
{
|
||||
using namespace fmt::internal;
|
||||
|
||||
String str;
|
||||
|
||||
if (args-arg > 15)
|
||||
{
|
||||
LogErr("Too many arguments to format");
|
||||
return str;
|
||||
}
|
||||
else if (fstr.empty())
|
||||
{
|
||||
return str;
|
||||
}
|
||||
else if (arg == args)
|
||||
{
|
||||
// Unnecessary but should throw an error when trying to format something without arguments
|
||||
try
|
||||
{
|
||||
str = fmt::format(fstr);
|
||||
}
|
||||
catch (const fmt::SystemError & e)
|
||||
{
|
||||
LogErr(e.what());
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
const SQChar * sval = 0;
|
||||
SQInteger ival;
|
||||
SQFloat fval;
|
||||
SQUserPointer pval;
|
||||
|
||||
std::vector< MakeValue< SQChar > > vlist;
|
||||
vlist.reserve(args-arg);
|
||||
std::uint64_t vtype = 0x0;
|
||||
|
||||
for (unsigned sh = 0;arg <= args; arg++, sh += 4)
|
||||
{
|
||||
switch(sq_gettype(vm, arg))
|
||||
{
|
||||
case OT_INTEGER:
|
||||
sq_getinteger(vm, arg, &ival);
|
||||
vlist.emplace_back(ival);
|
||||
vtype |= (MakeValue< SQChar >::type(ival) << sh);
|
||||
break;
|
||||
case OT_FLOAT:
|
||||
sq_getfloat(vm, arg, &fval);
|
||||
vlist.emplace_back(fval);
|
||||
vtype |= (MakeValue< SQChar >::type(fval) << sh);
|
||||
break;
|
||||
case OT_STRING:
|
||||
sq_getstring(vm, arg, &sval);
|
||||
vlist.emplace_back(sval);
|
||||
vtype |= (MakeValue< SQChar >::type(sval) << sh);
|
||||
break;
|
||||
case OT_BOOL:
|
||||
sq_getinteger(vm, arg, &ival);
|
||||
vlist.emplace_back(static_cast<unsigned char>(ival));
|
||||
vtype |= (MakeValue< SQChar >::type(static_cast<unsigned char>(ival)) << sh);
|
||||
break;
|
||||
case OT_USERPOINTER:
|
||||
sq_getuserpointer(vm, arg, &pval);
|
||||
vlist.emplace_back(static_cast<void *>(pval));
|
||||
vtype |= (MakeValue< SQChar >::type(static_cast<void *>(pval)) << sh);
|
||||
break;
|
||||
default:
|
||||
LogErr("Cannot format (%s) data type", GetTypeName(sq_gettype(vm, arg)));
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
vlist.shrink_to_fit();
|
||||
|
||||
try
|
||||
{
|
||||
fmt::BasicMemoryWriter<SQChar> w;
|
||||
w.write(fstr, fmt::ArgList(vtype, vlist.data()));
|
||||
str = w.c_str();
|
||||
}
|
||||
catch (const fmt::SystemError & e)
|
||||
{
|
||||
LogErr("%s", e.what());
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_Format(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
16
source/Library/Format.hpp
Normal file
16
source/Library/Format.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LIBRARY_FORMAT_HPP_
|
||||
#define _LIBRARY_FORMAT_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Common.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
String GetFormatStr(HSQUIRRELVM vm, SQInteger arg, SQInteger args) noexcept;
|
||||
String GetFormatStr(HSQUIRRELVM vm, const String & fstr, SQInteger arg, SQInteger args) noexcept;
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_FORMAT_HPP_
|
13
source/Library/INI.cpp
Normal file
13
source/Library/INI.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Library/INI.hpp"
|
||||
#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_INI(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
16
source/Library/INI.hpp
Normal file
16
source/Library/INI.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LIBRARY_INI_HPP_
|
||||
#define _LIBRARY_INI_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Config.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_INI_HPP_
|
13
source/Library/JSON.cpp
Normal file
13
source/Library/JSON.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Library/JSON.hpp"
|
||||
#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_JSON(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
16
source/Library/JSON.hpp
Normal file
16
source/Library/JSON.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LIBRARY_JSON_HPP_
|
||||
#define _LIBRARY_JSON_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Config.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_JSON_HPP_
|
60
source/Library/LongInt.cpp
Normal file
60
source/Library/LongInt.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include "Library/LongInt.hpp"
|
||||
//#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_LongInt(HSQUIRRELVM vm)
|
||||
{
|
||||
/*
|
||||
Sqrat::RootTable(vm).Bind(_SC("SLongInt"), Sqrat::Class<SLongInt>(vm, _SC("SLongInt"))
|
||||
.Ctor()
|
||||
.Ctor(SLongInt::Value)
|
||||
.Ctor(const SQChar *, SQInteger)
|
||||
|
||||
.Prop(_SC("str"), &SLongInt::GetCStr, &SLongInt::SetStr)
|
||||
.Prop(_SC("num"), &SLongInt::GetSNum, &SLongInt::SetNum)
|
||||
|
||||
.Func(_SC("_tostring"), &SLongInt::ToString)
|
||||
.Func(_SC("_cmp"), &SLongInt::Cmp)
|
||||
|
||||
.Func<SLongInt (SLongInt::*)(const SLongInt &) const>(_SC("_add"), &SLongInt::operator +)
|
||||
.Func<SLongInt (SLongInt::*)(const SLongInt &) const>(_SC("_sub"), &SLongInt::operator -)
|
||||
.Func<SLongInt (SLongInt::*)(const SLongInt &) const>(_SC("_mul"), &SLongInt::operator *)
|
||||
.Func<SLongInt (SLongInt::*)(const SLongInt &) const>(_SC("_div"), &SLongInt::operator /)
|
||||
.Func<SLongInt (SLongInt::*)(const SLongInt &) const>(_SC("_modulo"), &SLongInt::operator %)
|
||||
|
||||
.Func<SLongInt (SLongInt::*)(void) const>(_SC("_unm"), &SLongInt::operator -)
|
||||
|
||||
.Overload<void (SLongInt::*)(void)>(_SC("random"), &SLongInt::Random)
|
||||
.Overload<void (SLongInt::*)(SLongInt::Value, SLongInt::Value)>(_SC("random"), &SLongInt::Random)
|
||||
);
|
||||
|
||||
Sqrat::RootTable(vm).Bind(_SC("ULongInt"), Sqrat::Class<ULongInt>(vm, _SC("ULongInt"))
|
||||
.Ctor()
|
||||
.Ctor(ULongInt::Value)
|
||||
.Ctor(const SQChar *, SQInteger)
|
||||
|
||||
.Prop(_SC("str"), &ULongInt::GetCStr, &ULongInt::SetStr)
|
||||
.Prop(_SC("num"), &ULongInt::GetSNum, &ULongInt::SetNum)
|
||||
|
||||
.Func(_SC("_tostring"), &ULongInt::ToString)
|
||||
.Func(_SC("_cmp"), &ULongInt::Cmp)
|
||||
|
||||
.Func<ULongInt (ULongInt::*)(const ULongInt &) const>(_SC("_add"), &ULongInt::operator +)
|
||||
.Func<ULongInt (ULongInt::*)(const ULongInt &) const>(_SC("_sub"), &ULongInt::operator -)
|
||||
.Func<ULongInt (ULongInt::*)(const ULongInt &) const>(_SC("_mul"), &ULongInt::operator *)
|
||||
.Func<ULongInt (ULongInt::*)(const ULongInt &) const>(_SC("_div"), &ULongInt::operator /)
|
||||
.Func<ULongInt (ULongInt::*)(const ULongInt &) const>(_SC("_modulo"), &ULongInt::operator %)
|
||||
|
||||
.Func<ULongInt (ULongInt::*)(void) const>(_SC("_unm"), &ULongInt::operator -)
|
||||
|
||||
.Overload<void (ULongInt::*)(void)>(_SC("random"), &ULongInt::Random)
|
||||
.Overload<void (ULongInt::*)(ULongInt::Value, ULongInt::Value)>(_SC("random"), &ULongInt::Random)
|
||||
);
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
243
source/Library/LongInt.hpp
Normal file
243
source/Library/LongInt.hpp
Normal file
@ -0,0 +1,243 @@
|
||||
#ifndef _LIBRARY_LONGINT_HPP_
|
||||
#define _LIBRARY_LONGINT_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Common.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <stdexcept>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename T> class LongInt
|
||||
{
|
||||
public:
|
||||
// --------------------------------------------------------------------------------------------
|
||||
static_assert(std::is_integral<T>::value, "LongInt type is not an integral type");
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef T Value;
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
LongInt() noexcept
|
||||
: m_Data(0), m_Text()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
LongInt(U data) noexcept
|
||||
{
|
||||
*this = data;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
LongInt(const SQChar * text) noexcept
|
||||
{
|
||||
*this = text;
|
||||
}
|
||||
|
||||
LongInt(const SQChar * text, SQInteger overload = 0) noexcept
|
||||
{
|
||||
*this = text;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
LongInt(const LongInt<T> & i) noexcept
|
||||
: m_Data(i.m_Data), m_Text(i.m_Text)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LongInt(LongInt<T> && i) noexcept
|
||||
: m_Data(i.m_Data), m_Text(std::move(i.m_Text))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
~LongInt()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
LongInt & operator = (const LongInt<T> & i) noexcept
|
||||
{
|
||||
m_Data = i.m_Data;
|
||||
m_Text = i.m_Text;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
LongInt & operator = (LongInt<T> && i) noexcept
|
||||
{
|
||||
m_Data = i.m_Data;
|
||||
m_Text = std::move(i.m_Text);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
template <typename U, typename std::enable_if<std::is_integral<U>::value>::type* = nullptr>
|
||||
LongInt & operator = (U data) noexcept
|
||||
{
|
||||
m_Data = static_cast<Value>(data);
|
||||
m_Text = std::to_string(m_Data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
LongInt & operator = (const SQChar * text) noexcept
|
||||
{
|
||||
m_Text = text;
|
||||
try
|
||||
{
|
||||
m_Data = SToI<T>(text, 0, 10);
|
||||
}
|
||||
catch (const std::invalid_argument & e)
|
||||
{
|
||||
LogErr("Unable to extract number: %s", e.what());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
bool operator == (const LongInt<T> & x) const noexcept
|
||||
{
|
||||
return (m_Data == x.m_Data);
|
||||
}
|
||||
|
||||
bool operator != (const LongInt<T> & x) const noexcept
|
||||
{
|
||||
return (m_Data != x.m_Data);
|
||||
}
|
||||
|
||||
bool operator < (const LongInt<T> & x) const noexcept
|
||||
{
|
||||
return (m_Data < x.m_Data);
|
||||
}
|
||||
|
||||
bool operator > (const LongInt<T> & x) const noexcept
|
||||
{
|
||||
return (m_Data > x.m_Data);
|
||||
}
|
||||
|
||||
bool operator <= (const LongInt<T> & x) const noexcept
|
||||
{
|
||||
return (m_Data <= x.m_Data);
|
||||
}
|
||||
|
||||
bool operator >= (const LongInt<T> & x) const noexcept
|
||||
{
|
||||
return (m_Data >= x.m_Data);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
inline operator T () const noexcept
|
||||
{
|
||||
return m_Data;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
LongInt<T> operator + (const LongInt<T> & x) const noexcept
|
||||
{
|
||||
return LongInt<T>(m_Data + x.m_Data);
|
||||
}
|
||||
|
||||
LongInt<T> operator - (const LongInt<T> & x) const noexcept
|
||||
{
|
||||
return LongInt<T>(m_Data - x.m_Data);
|
||||
}
|
||||
|
||||
LongInt<T> operator * (const LongInt<T> & x) const noexcept
|
||||
{
|
||||
return LongInt<T>(m_Data * x.m_Data);
|
||||
}
|
||||
|
||||
LongInt<T> operator / (const LongInt<T> & x) const noexcept
|
||||
{
|
||||
return LongInt<T>(m_Data / x.m_Data);
|
||||
}
|
||||
|
||||
LongInt<T> operator % (const LongInt<T> & x) const noexcept
|
||||
{
|
||||
return LongInt<T>(m_Data % x.m_Data);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
LongInt<T> operator - () const noexcept
|
||||
{
|
||||
return LongInt<T>(-m_Data);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
SQInteger Cmp(const LongInt<T> & x) const noexcept
|
||||
{
|
||||
return m_Data == x.m_Data ? 0 : (m_Data > x.m_Data ? 1 : -1);
|
||||
}
|
||||
|
||||
const SQChar * ToString() const noexcept
|
||||
{
|
||||
return m_Text.c_str();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
void SetNum(T data) noexcept
|
||||
{
|
||||
*this = data;
|
||||
}
|
||||
|
||||
T GetNum() const noexcept
|
||||
{
|
||||
return m_Data;
|
||||
}
|
||||
|
||||
SQInteger GetSNum() const noexcept
|
||||
{
|
||||
return static_cast<SQInteger>(m_Data);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
void SetStr(const SQChar * text) noexcept
|
||||
{
|
||||
*this = text;
|
||||
}
|
||||
|
||||
const String & GetStr() const noexcept
|
||||
{
|
||||
return m_Text;
|
||||
}
|
||||
|
||||
const SQChar * GetCStr() const noexcept
|
||||
{
|
||||
return m_Text.c_str();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
void Random() noexcept
|
||||
{
|
||||
m_Data = RandomVal<T>::Get();
|
||||
m_Text = std::to_string(m_Data);
|
||||
}
|
||||
|
||||
void Random(T min, T max) noexcept
|
||||
{
|
||||
m_Data = RandomVal<T>::Get(min, max);
|
||||
m_Text = std::to_string(m_Data);
|
||||
}
|
||||
|
||||
private:
|
||||
// --------------------------------------------------------------------------------------------
|
||||
T m_Data;
|
||||
String m_Text;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
typedef LongInt<Int64> SLongInt;
|
||||
typedef LongInt<Uint64> ULongInt;
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_LONGINT_HPP_
|
13
source/Library/Math.cpp
Normal file
13
source/Library/Math.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Library/Math.hpp"
|
||||
#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_Math(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
16
source/Library/Math.hpp
Normal file
16
source/Library/Math.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LIBRARY_MATH_HPP_
|
||||
#define _LIBRARY_MATH_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Config.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_MATH_HPP_
|
13
source/Library/Numeric.cpp
Normal file
13
source/Library/Numeric.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Library/Numeric.hpp"
|
||||
#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_Numeric(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
16
source/Library/Numeric.hpp
Normal file
16
source/Library/Numeric.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LIBRARY_NUMERIC_HPP_
|
||||
#define _LIBRARY_NUMERIC_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Config.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_NUMERIC_HPP_
|
14
source/Library/Shared.cpp
Normal file
14
source/Library/Shared.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include "Library/Shared.hpp"
|
||||
#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_Library(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // Namespace:: SqMod
|
12
source/Library/Shared.hpp
Normal file
12
source/Library/Shared.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef _LIBRARY_SHARED_HPP_
|
||||
#define _LIBRARY_SHARED_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_SHARED_HPP_
|
13
source/Library/String.cpp
Normal file
13
source/Library/String.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Library/String.hpp"
|
||||
#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_String(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
16
source/Library/String.hpp
Normal file
16
source/Library/String.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LIBRARY_STRING_HPP_
|
||||
#define _LIBRARY_STRING_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Config.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_STRING_HPP_
|
13
source/Library/SysPath.cpp
Normal file
13
source/Library/SysPath.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Library/SysPath.hpp"
|
||||
#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_SysPath(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
16
source/Library/SysPath.hpp
Normal file
16
source/Library/SysPath.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LIBRARY_SYSPATH_HPP_
|
||||
#define _LIBRARY_SYSPATH_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Config.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_SYSPATH_HPP_
|
13
source/Library/System.cpp
Normal file
13
source/Library/System.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Library/System.hpp"
|
||||
#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_System(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
16
source/Library/System.hpp
Normal file
16
source/Library/System.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LIBRARY_SYSTEM_HPP_
|
||||
#define _LIBRARY_SYSTEM_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Config.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_SYSTEM_HPP_
|
13
source/Library/Timer.cpp
Normal file
13
source/Library/Timer.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Library/Timer.hpp"
|
||||
#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_Timer(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
16
source/Library/Timer.hpp
Normal file
16
source/Library/Timer.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LIBRARY_TIMER_HPP_
|
||||
#define _LIBRARY_TIMER_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Config.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_TIMER_HPP_
|
13
source/Library/Utils.cpp
Normal file
13
source/Library/Utils.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Library/Utils.hpp"
|
||||
#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_Utils(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
16
source/Library/Utils.hpp
Normal file
16
source/Library/Utils.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LIBRARY_UTILS_HPP_
|
||||
#define _LIBRARY_UTILS_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Config.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_UTILS_HPP_
|
13
source/Library/XML.cpp
Normal file
13
source/Library/XML.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Library/XML.hpp"
|
||||
#include "Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Register_XML(HSQUIRRELVM vm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
16
source/Library/XML.hpp
Normal file
16
source/Library/XML.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _LIBRARY_XML_HPP_
|
||||
#define _LIBRARY_XML_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Config.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_XML_HPP_
|
Reference in New Issue
Block a user