mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-01-19 03:57:14 +01:00
Compare commits
15 Commits
4090b558ad
...
151077c799
Author | SHA1 | Date | |
---|---|---|---|
|
151077c799 | ||
|
a99e926088 | ||
|
490f80d1e9 | ||
|
1d2a78c91e | ||
|
f23a8bc8f5 | ||
|
11f3c52319 | ||
|
2b1c76a05d | ||
|
a36e85d9b7 | ||
|
2fb0f851c0 | ||
|
7655c1cb98 | ||
|
9d62233cfc | ||
|
503b61c3df | ||
|
181b0f4377 | ||
|
cb359ed61e | ||
|
ec01a80486 |
@ -264,7 +264,12 @@ struct AABB
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD int32_t Cmp(SQFloat s) const
|
SQMOD_NODISCARD int32_t Cmp(SQFloat s) const
|
||||||
{
|
{
|
||||||
|
#ifdef SQUSEDOUBLE
|
||||||
|
auto f = static_cast< Value >(s);
|
||||||
|
return Cmp(AABB(f, f, f, f, f, f));
|
||||||
|
#else
|
||||||
return Cmp(AABB(s, s, s, s, s, s));
|
return Cmp(AABB(s, s, s, s, s, s));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
@ -476,16 +476,16 @@ Array Circle::ToPointsArray(SQInteger num_segments) const
|
|||||||
if (i >= num_segments) return false;
|
if (i >= num_segments) return false;
|
||||||
// Get the current angle
|
// Get the current angle
|
||||||
#ifdef SQUSEDOUBLE
|
#ifdef SQUSEDOUBLE
|
||||||
SQFloat theta = 2.0d * SQMOD_PI64 * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
SQFloat theta = 2.0 * SQMOD_PI64 * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
||||||
#else
|
#else
|
||||||
SQFloat theta = 2.0f * SQMOD_PI * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
SQFloat theta = 2.0f * SQMOD_PI * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
||||||
#endif // SQUSEDOUBLE
|
#endif // SQUSEDOUBLE
|
||||||
// Calculate the x component
|
// Calculate the x component
|
||||||
SQFloat x = (rad * cosf(theta)) + pos.x;
|
SQFloat x = (rad * std::cos(theta)) + pos.x;
|
||||||
// Calculate the y component
|
// Calculate the y component
|
||||||
SQFloat y = (rad * sinf(theta)) + pos.y;
|
SQFloat y = (rad * std::sin(theta)) + pos.y;
|
||||||
// Push the Vector2 instance on the stack
|
// Push the Vector2 instance on the stack
|
||||||
Var< Vector2 >::push(vm, Vector2{x, y});
|
Var< Vector2 >::push(vm, Vector2{static_cast< Vector2::Value >(x), static_cast< Vector2::Value >(y)});
|
||||||
// Insert the element on the stack into the array
|
// Insert the element on the stack into the array
|
||||||
return true;
|
return true;
|
||||||
}, num_segments);
|
}, num_segments);
|
||||||
|
@ -807,7 +807,7 @@ static SQInteger SqPackARGB(SQInteger r, SQInteger g, SQInteger b, SQInteger a)
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SQInteger SqNameFilterCheck(HSQUIRRELVM vm)
|
static SQInteger SqNameFilterCheck(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
const int32_t top = sq_gettop(vm);
|
SQInteger top = sq_gettop(vm);
|
||||||
// Was the filter string specified?
|
// Was the filter string specified?
|
||||||
if (top <= 1)
|
if (top <= 1)
|
||||||
{
|
{
|
||||||
@ -1031,7 +1031,7 @@ const String CmpGE::FSTRV("Assertion failed. Value mismatch: {0} >= {1}"); // NO
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SQInteger SqNameFilterCheckInsensitive(HSQUIRRELVM vm)
|
static SQInteger SqNameFilterCheckInsensitive(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
const int32_t top = sq_gettop(vm);
|
SQInteger top = sq_gettop(vm);
|
||||||
// Was the filter string specified?
|
// Was the filter string specified?
|
||||||
if (top <= 1)
|
if (top <= 1)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ void Area::AddCircleEx(SQFloat cx, SQFloat cy, SQFloat cr, SQInteger num_segment
|
|||||||
CheckLock();
|
CheckLock();
|
||||||
// Get the current angle
|
// Get the current angle
|
||||||
#ifdef SQUSEDOUBLE
|
#ifdef SQUSEDOUBLE
|
||||||
SQFloat theta = 2.0d * SQMOD_PI64 * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
SQFloat theta = 2.0 * SQMOD_PI64 * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
||||||
#else
|
#else
|
||||||
SQFloat theta = 2.0f * SQMOD_PI * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
SQFloat theta = 2.0f * SQMOD_PI * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
||||||
#endif // SQUSEDOUBLE
|
#endif // SQUSEDOUBLE
|
||||||
@ -62,9 +62,9 @@ void Area::AddCircleEx(SQFloat cx, SQFloat cy, SQFloat cr, SQInteger num_segment
|
|||||||
// Calculate the y component
|
// Calculate the y component
|
||||||
SQFloat y = (cr * std::sin(theta)) + cy;
|
SQFloat y = (cr * std::sin(theta)) + cy;
|
||||||
// Insert the point into the list
|
// Insert the point into the list
|
||||||
mPoints.emplace_back(x, y);
|
mPoints.emplace_back(static_cast< Vector2::Value >(x), static_cast< Vector2::Value >(y));
|
||||||
// Update the bounding box
|
// Update the bounding box
|
||||||
Expand(x, y);
|
Expand(static_cast< Vector2::Value >(x), static_cast< Vector2::Value >(y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ void OutputMessage(const char * msg, ...);
|
|||||||
void OutputError(const char * msg, ...);
|
void OutputError(const char * msg, ...);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Generate a formatted string and throw it as a sqrat exception.
|
* Generate a formatted string and throw it as a Sqrat exception.
|
||||||
*/
|
*/
|
||||||
template < class... Args > void SqThrowF(Args &&... args)
|
template < class... Args > void SqThrowF(Args &&... args)
|
||||||
{
|
{
|
||||||
|
@ -1743,7 +1743,7 @@ void Core::EmitEntityPool(vcmpEntityPool entity_type, int32_t entity_id, bool is
|
|||||||
break;
|
break;
|
||||||
case vcmpEntityPoolRadio:
|
case vcmpEntityPoolRadio:
|
||||||
// @TODO Implement...
|
// @TODO Implement...
|
||||||
//break;
|
break;
|
||||||
#if SQMOD_SDK_LEAST(2, 1)
|
#if SQMOD_SDK_LEAST(2, 1)
|
||||||
case vcmpEntityPoolPlayer:
|
case vcmpEntityPoolPlayer:
|
||||||
// @TODO Implement...
|
// @TODO Implement...
|
||||||
|
@ -31,6 +31,8 @@ template < class Key, class T, class Pred = std::equal_to< Key > > struct VecMap
|
|||||||
using difference_type = typename storage_type::difference_type;
|
using difference_type = typename storage_type::difference_type;
|
||||||
using iterator = typename storage_type::iterator;
|
using iterator = typename storage_type::iterator;
|
||||||
using const_iterator = typename storage_type::const_iterator;
|
using const_iterator = typename storage_type::const_iterator;
|
||||||
|
using reverse_iterator = typename storage_type::reverse_iterator;
|
||||||
|
using const_reverse_iterator = typename storage_type::const_reverse_iterator;
|
||||||
using insert_return_type = std::pair< iterator, pointer >;
|
using insert_return_type = std::pair< iterator, pointer >;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -100,12 +102,12 @@ template < class Key, class T, class Pred = std::equal_to< Key > > struct VecMap
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve a reverse iterator to the beginning (const). See: std::vector::[c]rbegin()
|
* Retrieve a reverse iterator to the beginning (const). See: std::vector::[c]rbegin()
|
||||||
*/
|
*/
|
||||||
const_iterator rbegin() const noexcept { return m_Storage.rbegin(); }
|
reverse_iterator rbegin() const noexcept { return m_Storage.rbegin(); }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve a reverse iterator to the beginning (const). See: std::vector::crbegin()
|
* Retrieve a reverse iterator to the beginning (const). See: std::vector::crbegin()
|
||||||
*/
|
*/
|
||||||
const_iterator crbegin() const noexcept { return m_Storage.crbegin(); }
|
const_reverse_iterator crbegin() const noexcept { return m_Storage.crbegin(); }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve a reverse iterator to the beginning. See: std::vector::rend()
|
* Retrieve a reverse iterator to the beginning. See: std::vector::rend()
|
||||||
@ -115,12 +117,12 @@ template < class Key, class T, class Pred = std::equal_to< Key > > struct VecMap
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve a reverse iterator to the beginning (const). See: std::vector::[c]rend()
|
* Retrieve a reverse iterator to the beginning (const). See: std::vector::[c]rend()
|
||||||
*/
|
*/
|
||||||
const_iterator rend() const noexcept { return m_Storage.rend(); }
|
reverse_iterator rend() const noexcept { return m_Storage.rend(); }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve a reverse iterator to the beginning (const). See: std::vector::crend()
|
* Retrieve a reverse iterator to the beginning (const). See: std::vector::crend()
|
||||||
*/
|
*/
|
||||||
const_iterator crend() const noexcept { return m_Storage.crend(); }
|
const_reverse_iterator crend() const noexcept { return m_Storage.crend(); }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Check if elements are stored in the container.
|
* Check if elements are stored in the container.
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Core/Common.hpp"
|
#include "Core/Common.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
|
@ -12,6 +12,19 @@ SQMOD_DECL_TYPENAME(Typename, _SC("SqDate"))
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQChar Date::Delimiter = '-';
|
SQChar Date::Delimiter = '-';
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Date::Date(int64_t ts)
|
||||||
|
: Date()
|
||||||
|
{
|
||||||
|
const auto y = static_cast< uint16_t >(std::lround(std::floor(ts / 3.17098e-14)));
|
||||||
|
ts -= int64_t{y} * 3.17098e-14;
|
||||||
|
const auto m = static_cast< uint8_t >(std::lround(std::floor(ts / 2.628e+12)));
|
||||||
|
ts -= int64_t{m} * 2.628e+12;
|
||||||
|
const auto d = static_cast< uint8_t >(std::lround(std::floor(ts / 8.64e+10)));
|
||||||
|
// Set the specified date
|
||||||
|
Set(y, m, d);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t Date::Compare(const Date & o) const
|
int32_t Date::Compare(const Date & o) const
|
||||||
{
|
{
|
||||||
@ -363,6 +376,12 @@ Timestamp Date::GetTimestamp() const
|
|||||||
return Timestamp(static_cast< int64_t >(days * 86400000000LL));
|
return Timestamp(static_cast< int64_t >(days * 86400000000LL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
std::time_t Date::ToTimeT() const
|
||||||
|
{
|
||||||
|
return GetTimestamp().ToTimeT();
|
||||||
|
}
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_ChronoDate(HSQUIRRELVM vm, Table & /*cns*/)
|
void Register_ChronoDate(HSQUIRRELVM vm, Table & /*cns*/)
|
||||||
{
|
{
|
||||||
|
@ -83,6 +83,11 @@ public:
|
|||||||
SetStr(str);
|
SetStr(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Time-stamp constructor.
|
||||||
|
*/
|
||||||
|
explicit Date(int64_t ts);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Copy constructor.
|
* Copy constructor.
|
||||||
*/
|
*/
|
||||||
@ -349,6 +354,11 @@ public:
|
|||||||
* Convert this date instance to a time-stamp.
|
* Convert this date instance to a time-stamp.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Timestamp GetTimestamp() const;
|
SQMOD_NODISCARD Timestamp GetTimestamp() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
std::time_t ToTimeT() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
@ -16,6 +16,26 @@ SQChar Datetime::Delimiter = ' ';
|
|||||||
SQChar Datetime::DateDelim = '-';
|
SQChar Datetime::DateDelim = '-';
|
||||||
SQChar Datetime::TimeDelim = ':';
|
SQChar Datetime::TimeDelim = ':';
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Datetime::Datetime(int64_t ts)
|
||||||
|
: Datetime()
|
||||||
|
{
|
||||||
|
const auto y = static_cast< uint16_t >(std::lround(std::floor(ts / 3.17098e-14)));
|
||||||
|
ts -= int64_t{y} * 3.17098e-14;
|
||||||
|
const auto mo = static_cast< uint8_t >(std::lround(std::floor(ts / 2.628e+12)));
|
||||||
|
ts -= int64_t{mo} * 2.628e+12;
|
||||||
|
const auto d = static_cast< uint8_t >(std::lround(std::floor(ts / 8.64e+10)));
|
||||||
|
ts -= int64_t{d} * 8.64e+10;
|
||||||
|
const auto h = static_cast< uint8_t >(std::lround(std::floor(ts / 3.6e+9)));
|
||||||
|
ts -= int64_t{h} * 3.6e+9;
|
||||||
|
const auto mi = static_cast< uint8_t >(std::lround(std::floor(ts / 6e+7)));
|
||||||
|
ts -= int64_t{mi} * 6e+7;
|
||||||
|
const auto s = static_cast< uint8_t >(std::lround(std::floor(ts / 1e+6)));
|
||||||
|
ts -= int64_t{s} * 1e+6;
|
||||||
|
// Set the specified date-time
|
||||||
|
Set(y, mo, d, h, mi, s, static_cast< uint16_t >(ts / 1000LL));
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t Datetime::Compare(const Datetime & o) const
|
int32_t Datetime::Compare(const Datetime & o) const
|
||||||
{
|
{
|
||||||
@ -745,6 +765,12 @@ Timestamp Datetime::GetTimestamp() const
|
|||||||
return Timestamp(ms);
|
return Timestamp(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
std::time_t Datetime::ToTimeT() const
|
||||||
|
{
|
||||||
|
return GetTimestamp().ToTimeT();
|
||||||
|
}
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_ChronoDatetime(HSQUIRRELVM vm, Table & /*cns*/)
|
void Register_ChronoDatetime(HSQUIRRELVM vm, Table & /*cns*/)
|
||||||
{
|
{
|
||||||
|
@ -140,6 +140,11 @@ public:
|
|||||||
Set(year, month, day, hour, minute, second, millisecond);
|
Set(year, month, day, hour, minute, second, millisecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Time-stamp constructor.
|
||||||
|
*/
|
||||||
|
explicit Datetime(int64_t ts);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy constructor.
|
* Copy constructor.
|
||||||
*/
|
*/
|
||||||
@ -572,6 +577,11 @@ public:
|
|||||||
* Convert this date-time instance to a time-stamp.
|
* Convert this date-time instance to a time-stamp.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Timestamp GetTimestamp() const;
|
SQMOD_NODISCARD Timestamp GetTimestamp() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
std::time_t ToTimeT() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
@ -12,6 +12,20 @@ SQMOD_DECL_TYPENAME(Typename, _SC("SqTime"))
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQChar Time::Delimiter = ':';
|
SQChar Time::Delimiter = ':';
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Time::Time(int64_t ts)
|
||||||
|
: Time()
|
||||||
|
{
|
||||||
|
const auto h = static_cast< uint8_t >(std::lround(std::floor(ts / 3.6e+9)));
|
||||||
|
ts -= int64_t{h} * 3.6e+9;
|
||||||
|
const auto m = static_cast< uint8_t >(std::lround(std::floor(ts / 6e+7)));
|
||||||
|
ts -= int64_t{m} * 6e+7;
|
||||||
|
const auto s = static_cast< uint8_t >(std::lround(std::floor(ts / 1e+6)));
|
||||||
|
ts -= int64_t{s} * 1e+6;
|
||||||
|
// Set the specified time
|
||||||
|
Set(h, m, s, static_cast< uint16_t >(ts / 1000LL));
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t Time::Compare(const Time & o) const
|
int32_t Time::Compare(const Time & o) const
|
||||||
{
|
{
|
||||||
@ -410,6 +424,12 @@ Timestamp Time::GetTimestamp() const
|
|||||||
return Timestamp(ms);
|
return Timestamp(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
std::time_t Time::ToTimeT() const
|
||||||
|
{
|
||||||
|
return GetTimestamp().ToTimeT();
|
||||||
|
}
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_ChronoTime(HSQUIRRELVM vm, Table & /*cns*/)
|
void Register_ChronoTime(HSQUIRRELVM vm, Table & /*cns*/)
|
||||||
{
|
{
|
||||||
|
@ -26,10 +26,10 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
uint8_t m_Hour{}; // Hour
|
uint8_t m_Hour{0}; // Hour
|
||||||
uint8_t m_Minute{}; // Minute
|
uint8_t m_Minute{0}; // Minute
|
||||||
uint8_t m_Second{}; // Second
|
uint8_t m_Second{0}; // Second
|
||||||
uint16_t m_Millisecond{}; // Millisecond
|
uint16_t m_Millisecond{0}; // Millisecond
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQChar m_Delimiter; // Component delimiter when generating strings.
|
SQChar m_Delimiter; // Component delimiter when generating strings.
|
||||||
@ -94,6 +94,11 @@ public:
|
|||||||
SetStr(str);
|
SetStr(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Time-stamp constructor.
|
||||||
|
*/
|
||||||
|
explicit Time(int64_t ts);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Copy constructor.
|
* Copy constructor.
|
||||||
*/
|
*/
|
||||||
@ -354,6 +359,11 @@ public:
|
|||||||
* Convert this time instance to a time-stamp.
|
* Convert this time instance to a time-stamp.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Timestamp GetTimestamp() const;
|
SQMOD_NODISCARD Timestamp GetTimestamp() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
std::time_t ToTimeT() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/Chrono/Timestamp.hpp"
|
#include "Library/Chrono/Timestamp.hpp"
|
||||||
#include "Library/Chrono/Timer.hpp"
|
#include "Library/Chrono/Timer.hpp"
|
||||||
|
#include "Library/Chrono/Time.hpp"
|
||||||
#include "Library/Chrono/Date.hpp"
|
#include "Library/Chrono/Date.hpp"
|
||||||
|
#include "Library/Chrono/Datetime.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
#include "Library/Numeric/Long.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
@ -58,6 +63,10 @@ void Timestamp::SetMicroseconds(const SLongInt & amount)
|
|||||||
m_Timestamp = amount.GetNum();
|
m_Timestamp = amount.GetNum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::AddMicroseconds(const SLongInt & amount) { m_Timestamp += amount.GetNum(); return *this; }
|
||||||
|
Timestamp & Timestamp::SubMicroseconds(const SLongInt & amount) { m_Timestamp -= amount.GetNum(); return *this; }
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SLongInt Timestamp::GetMilliseconds() const
|
SLongInt Timestamp::GetMilliseconds() const
|
||||||
{
|
{
|
||||||
@ -70,6 +79,127 @@ void Timestamp::SetMilliseconds(const SLongInt & amount)
|
|||||||
m_Timestamp = (amount.GetNum() * 1000L);
|
m_Timestamp = (amount.GetNum() * 1000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::AddMilliseconds(const SLongInt & amount) { m_Timestamp += (amount.GetNum() * 1000L); return *this; }
|
||||||
|
Timestamp & Timestamp::SubMilliseconds(const SLongInt & amount) { m_Timestamp -= (amount.GetNum() * 1000L); return *this; }
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Time Timestamp::GetTime() const
|
||||||
|
{
|
||||||
|
return Time(m_Timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Timestamp::SetTime(const Time & t)
|
||||||
|
{
|
||||||
|
SetHoursI(t.GetHour());
|
||||||
|
AddMinutesI(t.GetMinute());
|
||||||
|
AddSecondsI(t.GetSecond());
|
||||||
|
AddMillisecondsRaw(t.GetMillisecond());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::AddTime(const Time & t)
|
||||||
|
{
|
||||||
|
AddHoursI(t.GetHour());
|
||||||
|
AddMinutesI(t.GetMinute());
|
||||||
|
AddSecondsI(t.GetSecond());
|
||||||
|
AddMillisecondsRaw(t.GetMillisecond());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::SubTime(const Time & t)
|
||||||
|
{
|
||||||
|
SubMillisecondsRaw(t.GetMillisecond());
|
||||||
|
SubSecondsI(t.GetSecond());
|
||||||
|
SubMinutesI(t.GetMinute());
|
||||||
|
SubHoursI(t.GetHour());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Date Timestamp::GetDate() const
|
||||||
|
{
|
||||||
|
return Date(m_Timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Timestamp::SetDate(const Date & d)
|
||||||
|
{
|
||||||
|
SetYearsI(d.GetYear());
|
||||||
|
AddDaysF(d.GetMonth() * 30.4167);
|
||||||
|
AddDaysI(d.GetDay());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::AddDate(const Date & d)
|
||||||
|
{
|
||||||
|
AddYearsI(d.GetYear());
|
||||||
|
AddDaysF(d.GetMonth() * 30.4167);
|
||||||
|
AddDaysI(d.GetDay());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::SubDate(const Date & d)
|
||||||
|
{
|
||||||
|
SubDaysI(d.GetDay());
|
||||||
|
SubDaysF(d.GetMonth() * 30.4167);
|
||||||
|
SubYearsI(d.GetYear());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Datetime Timestamp::GetDatetime() const
|
||||||
|
{
|
||||||
|
return Datetime(m_Timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Timestamp::SetDatetime(const Datetime & dt)
|
||||||
|
{
|
||||||
|
SetYearsI(dt.GetYear());
|
||||||
|
AddDaysF(dt.GetMonth() * 30.4167);
|
||||||
|
AddDaysI(dt.GetDay());
|
||||||
|
AddHoursI(dt.GetHour());
|
||||||
|
AddMinutesI(dt.GetMinute());
|
||||||
|
AddSecondsI(dt.GetSecond());
|
||||||
|
AddMillisecondsRaw(dt.GetMillisecond());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::AddDatetime(const Datetime & dt)
|
||||||
|
{
|
||||||
|
AddYearsI(dt.GetYear());
|
||||||
|
AddDaysF(dt.GetMonth() * 30.4167);
|
||||||
|
AddDaysI(dt.GetDay());
|
||||||
|
AddHoursI(dt.GetHour());
|
||||||
|
AddMinutesI(dt.GetMinute());
|
||||||
|
AddSecondsI(dt.GetSecond());
|
||||||
|
AddMillisecondsRaw(dt.GetMillisecond());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::SubDatetime(const Datetime & dt)
|
||||||
|
{
|
||||||
|
SubMillisecondsRaw(dt.GetMillisecond());
|
||||||
|
SubSecondsI(dt.GetSecond());
|
||||||
|
SubMinutesI(dt.GetMinute());
|
||||||
|
SubHoursI(dt.GetHour());
|
||||||
|
SubDaysI(dt.GetDay());
|
||||||
|
SubDaysF(dt.GetMonth() * 30.4167);
|
||||||
|
SubYearsI(dt.GetYear());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
std::time_t Timestamp::ToTimeT() const
|
||||||
|
{
|
||||||
|
return std::chrono::system_clock::to_time_t(std::chrono::time_point< std::chrono::system_clock >{std::chrono::microseconds{m_Timestamp}});
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static Timestamp SqGetEpochTimeNow()
|
static Timestamp SqGetEpochTimeNow()
|
||||||
{
|
{
|
||||||
@ -156,8 +286,46 @@ void Register_ChronoTimestamp(HSQUIRRELVM vm, Table & /*cns*/)
|
|||||||
.Prop(_SC("DaysI"), &Timestamp::GetDaysI, &Timestamp::SetDaysI)
|
.Prop(_SC("DaysI"), &Timestamp::GetDaysI, &Timestamp::SetDaysI)
|
||||||
.Prop(_SC("YearsF"), &Timestamp::GetYearsF, &Timestamp::SetYearsF)
|
.Prop(_SC("YearsF"), &Timestamp::GetYearsF, &Timestamp::SetYearsF)
|
||||||
.Prop(_SC("YearsI"), &Timestamp::GetYearsI, &Timestamp::SetYearsI)
|
.Prop(_SC("YearsI"), &Timestamp::GetYearsI, &Timestamp::SetYearsI)
|
||||||
|
.Prop(_SC("Time"), &Timestamp::GetTime, &Timestamp::SetTime)
|
||||||
|
.Prop(_SC("Date"), &Timestamp::GetDate, &Timestamp::SetDate)
|
||||||
|
.Prop(_SC("Datetime"), &Timestamp::GetDatetime, &Timestamp::SetDatetime)
|
||||||
// Member Methods
|
// Member Methods
|
||||||
.Func(_SC("SetNow"), &Timestamp::SetNow)
|
.Func(_SC("SetNow"), &Timestamp::SetNow)
|
||||||
|
// Properties
|
||||||
|
.Func(_SC("AddMicroseconds"), &Timestamp::AddMicroseconds)
|
||||||
|
.Func(_SC("SubMicroseconds"), &Timestamp::SubMicroseconds)
|
||||||
|
.Func(_SC("AddMicrosecondsRaw"), &Timestamp::AddMicrosecondsRaw)
|
||||||
|
.Func(_SC("SubMicrosecondsRaw"), &Timestamp::SubMicrosecondsRaw)
|
||||||
|
.Func(_SC("AddMilliseconds"), &Timestamp::AddMilliseconds)
|
||||||
|
.Func(_SC("SubMilliseconds"), &Timestamp::SubMilliseconds)
|
||||||
|
.Func(_SC("AddMillisecondsRaw"), &Timestamp::AddMillisecondsRaw)
|
||||||
|
.Func(_SC("SubMillisecondsRaw"), &Timestamp::SubMillisecondsRaw)
|
||||||
|
.Func(_SC("AddSecondsF"), &Timestamp::AddSecondsF)
|
||||||
|
.Func(_SC("SubSecondsF"), &Timestamp::SubSecondsF)
|
||||||
|
.Func(_SC("AddSecondsI"), &Timestamp::AddSecondsI)
|
||||||
|
.Func(_SC("SubSecondsI"), &Timestamp::SubSecondsI)
|
||||||
|
.Func(_SC("AddMinutesF"), &Timestamp::AddMinutesF)
|
||||||
|
.Func(_SC("SubMinutesF"), &Timestamp::SubMinutesF)
|
||||||
|
.Func(_SC("AddMinutesI"), &Timestamp::AddMinutesI)
|
||||||
|
.Func(_SC("SubMinutesI"), &Timestamp::SubMinutesI)
|
||||||
|
.Func(_SC("AddHoursF"), &Timestamp::AddHoursF)
|
||||||
|
.Func(_SC("SubHoursF"), &Timestamp::SubHoursF)
|
||||||
|
.Func(_SC("AddHoursI"), &Timestamp::AddHoursI)
|
||||||
|
.Func(_SC("SubHoursI"), &Timestamp::SubHoursI)
|
||||||
|
.Func(_SC("AddDaysF"), &Timestamp::AddDaysF)
|
||||||
|
.Func(_SC("SubDaysF"), &Timestamp::SubDaysF)
|
||||||
|
.Func(_SC("AddDaysI"), &Timestamp::AddDaysI)
|
||||||
|
.Func(_SC("SubDaysI"), &Timestamp::SubDaysI)
|
||||||
|
.Func(_SC("AddYearsF"), &Timestamp::AddYearsF)
|
||||||
|
.Func(_SC("SubYearsF"), &Timestamp::SubYearsF)
|
||||||
|
.Func(_SC("AddYearsI"), &Timestamp::AddYearsI)
|
||||||
|
.Func(_SC("SubYearsI"), &Timestamp::SubYearsI)
|
||||||
|
.Func(_SC("AddTime"), &Timestamp::AddTime)
|
||||||
|
.Func(_SC("SubTime"), &Timestamp::SubTime)
|
||||||
|
.Func(_SC("AddDate"), &Timestamp::AddDate)
|
||||||
|
.Func(_SC("SubDate"), &Timestamp::SubDate)
|
||||||
|
.Func(_SC("AddDatetime"), &Timestamp::AddDatetime)
|
||||||
|
.Func(_SC("SubDatetime"), &Timestamp::SubDatetime)
|
||||||
// Static Functions
|
// Static Functions
|
||||||
.StaticFunc(_SC("GetNow"), &SqGetEpochTimeNow)
|
.StaticFunc(_SC("GetNow"), &SqGetEpochTimeNow)
|
||||||
.StaticFunc(_SC("GetMicrosRaw"), &SqGetMicrosecondsRaw)
|
.StaticFunc(_SC("GetMicrosRaw"), &SqGetMicrosecondsRaw)
|
||||||
|
@ -7,7 +7,10 @@
|
|||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
class Date;
|
||||||
|
class Time;
|
||||||
class Timer;
|
class Timer;
|
||||||
|
class Datetime;
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
@ -126,6 +129,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetMicroseconds(const SLongInt & amount);
|
void SetMicroseconds(const SLongInt & amount);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddMicroseconds(const SLongInt & amount);
|
||||||
|
Timestamp & SubMicroseconds(const SLongInt & amount);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -142,6 +151,12 @@ public:
|
|||||||
m_Timestamp = amount;
|
m_Timestamp = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddMicrosecondsRaw(SQInteger amount) { m_Timestamp += amount; return *this; }
|
||||||
|
Timestamp & SubMicrosecondsRaw(SQInteger amount) { m_Timestamp -= amount; return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -152,6 +167,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetMilliseconds(const SLongInt & amount);
|
void SetMilliseconds(const SLongInt & amount);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddMilliseconds(const SLongInt & amount);
|
||||||
|
Timestamp & SubMilliseconds(const SLongInt & amount);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -168,6 +189,12 @@ public:
|
|||||||
m_Timestamp = int64_t(int64_t(amount) * 1000L);
|
m_Timestamp = int64_t(int64_t(amount) * 1000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddMillisecondsRaw(SQInteger amount) { m_Timestamp += int64_t(int64_t(amount) * 1000L); return *this; }
|
||||||
|
Timestamp & SubMillisecondsRaw(SQInteger amount) { m_Timestamp -= int64_t(int64_t(amount) * 1000L); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -184,6 +211,12 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 1000000L);
|
m_Timestamp = int64_t(double(amount) * 1000000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddSecondsF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 1000000L); return *this; }
|
||||||
|
Timestamp & SubSecondsF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 1000000L); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -200,6 +233,12 @@ public:
|
|||||||
m_Timestamp = int64_t(int64_t(amount) * 1000000L);
|
m_Timestamp = int64_t(int64_t(amount) * 1000000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddSecondsI(SQInteger amount) { m_Timestamp += int64_t(int64_t(amount) * 1000000L); return *this; }
|
||||||
|
Timestamp & SubSecondsI(SQInteger amount) { m_Timestamp -= int64_t(int64_t(amount) * 1000000L); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -216,6 +255,12 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 60000000L);
|
m_Timestamp = int64_t(double(amount) * 60000000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddMinutesF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 60000000L); return *this; }
|
||||||
|
Timestamp & SubMinutesF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 60000000L); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -232,6 +277,12 @@ public:
|
|||||||
m_Timestamp = int64_t(int64_t(amount) * 60000000L);
|
m_Timestamp = int64_t(int64_t(amount) * 60000000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddMinutesI(SQInteger amount) { m_Timestamp += int64_t(int64_t(amount) * 60000000L); return *this; }
|
||||||
|
Timestamp & SubMinutesI(SQInteger amount) { m_Timestamp -= int64_t(int64_t(amount) * 60000000L); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -248,6 +299,12 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 3600000000LL);
|
m_Timestamp = int64_t(double(amount) * 3600000000LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddHoursF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 3600000000LL); return *this; }
|
||||||
|
Timestamp & SubHoursF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 3600000000LL); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -264,6 +321,12 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 3600000000LL);
|
m_Timestamp = int64_t(double(amount) * 3600000000LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddHoursI(SQInteger amount) { m_Timestamp += int64_t(double(amount) * 3600000000LL); return *this; }
|
||||||
|
Timestamp & SubHoursI(SQInteger amount) { m_Timestamp -= int64_t(double(amount) * 3600000000LL); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -280,6 +343,12 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 86400000000LL);
|
m_Timestamp = int64_t(double(amount) * 86400000000LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddDaysF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 86400000000LL); return *this; }
|
||||||
|
Timestamp & SubDaysF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 86400000000LL); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -296,6 +365,12 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 86400000000LL);
|
m_Timestamp = int64_t(double(amount) * 86400000000LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddDaysI(SQInteger amount) { m_Timestamp += int64_t(double(amount) * 86400000000LL); return *this; }
|
||||||
|
Timestamp & SubDaysI(SQInteger amount) { m_Timestamp -= int64_t(double(amount) * 86400000000LL); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -312,6 +387,12 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 31557600000000LL);
|
m_Timestamp = int64_t(double(amount) * 31557600000000LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddYearsF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 31557600000000LL); return *this; }
|
||||||
|
Timestamp & SubYearsF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 31557600000000LL); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -328,6 +409,65 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 31557600000000LL);
|
m_Timestamp = int64_t(double(amount) * 31557600000000LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddYearsI(SQInteger amount) { m_Timestamp += int64_t(double(amount) * 31557600000000LL); return *this; }
|
||||||
|
Timestamp & SubYearsI(SQInteger amount) { m_Timestamp -= int64_t(double(amount) * 31557600000000LL); return *this; }
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Time GetTime() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void SetTime(const Time & t);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddTime(const Time & t);
|
||||||
|
Timestamp & SubTime(const Time & t);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Date GetDate() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void SetDate(const Date & d);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddDate(const Date & d);
|
||||||
|
Timestamp & SubDate(const Date & d);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Datetime GetDatetime() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void SetDatetime(const Datetime & dt);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddDatetime(const Datetime & dt);
|
||||||
|
Timestamp & SubDatetime(const Datetime & dt);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
std::time_t ToTimeT() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
|
@ -444,7 +444,7 @@ void SockAddr::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid sockaddr structure handle =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid sockaddr structure handle =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -551,7 +551,7 @@ void Database::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind database reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind database reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -687,7 +687,7 @@ void Description::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind database reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind database reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -708,7 +708,7 @@ Description::Pointer Description::GetValid(const SQChar * file, int32_t line) co
|
|||||||
// Validate the referenced description
|
// Validate the referenced description
|
||||||
if (!m_Description)
|
if (!m_Description)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind meta-data description reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind meta-data description reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Return the description pointer
|
// Return the description pointer
|
||||||
return m_Description;
|
return m_Description;
|
||||||
@ -747,7 +747,7 @@ void EntryData::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind database reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind database reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -768,7 +768,7 @@ EntryData::ConstRef EntryData::GetValid(const SQChar * file, int32_t line) const
|
|||||||
// See if the entry has any data
|
// See if the entry has any data
|
||||||
if (!m_Entry.has_data)
|
if (!m_Entry.has_data)
|
||||||
{
|
{
|
||||||
SqThrowF("The referenced entry has no data =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("The referenced entry has no data =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Return the entry
|
// Return the entry
|
||||||
return m_Entry;
|
return m_Entry;
|
||||||
@ -821,7 +821,7 @@ void EntryDataList::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind database reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind database reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -842,7 +842,7 @@ EntryDataList::Pointer EntryDataList::GetValid(const SQChar * file, int32_t line
|
|||||||
// Validate the managed list
|
// Validate the managed list
|
||||||
if (!m_List)
|
if (!m_List)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind entry data list reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind entry data list reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// return the list
|
// return the list
|
||||||
return m_List;
|
return m_List;
|
||||||
@ -869,7 +869,7 @@ EntryDataList::Pointer EntryDataList::GetValidElem(const SQChar * file, int32_t
|
|||||||
// Validate the current element
|
// Validate the current element
|
||||||
if (!m_List)
|
if (!m_List)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind entry data element reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind entry data element reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// return the element
|
// return the element
|
||||||
return m_Elem;
|
return m_Elem;
|
||||||
@ -979,7 +979,7 @@ void LookupResult::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind database reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind database reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -1139,7 +1139,7 @@ void Metadata::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind database reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind database reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -1160,7 +1160,7 @@ Metadata::Pointer Metadata::GetValid(const SQChar * file, int32_t line) const
|
|||||||
// Validate the referenced meta-data
|
// Validate the referenced meta-data
|
||||||
if (!m_Metadata)
|
if (!m_Metadata)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind meta-data reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind meta-data reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Return the meta-data pointer
|
// Return the meta-data pointer
|
||||||
return m_Metadata;
|
return m_Metadata;
|
||||||
@ -1211,7 +1211,7 @@ void SearchNode::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind database reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind database reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -1623,7 +1623,7 @@ void Connection::Validate(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL connection reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL connection reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -1642,11 +1642,11 @@ void Connection::ValidateCreated(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL connection reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL connection reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
else if (m_Handle->mPtr == nullptr)
|
else if (m_Handle->mPtr == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL connection =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL connection =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -1962,12 +1962,12 @@ void Field::Validate(const char * file, int32_t line) const
|
|||||||
// Do we have a valid result-set handle?
|
// Do we have a valid result-set handle?
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Are we pointing to a valid index?
|
// Are we pointing to a valid index?
|
||||||
else if (m_Index >= m_Handle->mFieldCount)
|
else if (m_Index >= m_Handle->mFieldCount)
|
||||||
{
|
{
|
||||||
SqThrowF("Field index is out of range: {} >= {} =>[{}:{}]", m_Index, m_Handle->mFieldCount, file, line);
|
SqThrowF(SQMOD_RTFMT("Field index is out of range: {} >= {} =>[{}:{}]"), m_Index, m_Handle->mFieldCount, file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -1993,7 +1993,7 @@ void Field::ValidateCreated(const char * file, int32_t line) const
|
|||||||
// Do we have a valid result-set handle?
|
// Do we have a valid result-set handle?
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Are we pointing to a valid index?
|
// Are we pointing to a valid index?
|
||||||
m_Handle->ValidateField(m_Index, file, line);
|
m_Handle->ValidateField(m_Index, file, line);
|
||||||
@ -2018,12 +2018,12 @@ void Field::ValidateStepped(const char * file, int32_t line) const
|
|||||||
// Do we have a valid result-set handle?
|
// Do we have a valid result-set handle?
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Do we have a valid row available?
|
// Do we have a valid row available?
|
||||||
else if (m_Handle->mRow == nullptr)
|
else if (m_Handle->mRow == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("No row available in MySQL result-set =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("No row available in MySQL result-set =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Are we pointing to a valid index?
|
// Are we pointing to a valid index?
|
||||||
m_Handle->ValidateField(m_Index, file, line);
|
m_Handle->ValidateField(m_Index, file, line);
|
||||||
@ -2098,7 +2098,7 @@ void Field::ValidateField(uint32_t idx, const char * file, int32_t line) const
|
|||||||
// Do we have a valid result-set handle?
|
// Do we have a valid result-set handle?
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Validate the specified field index
|
// Validate the specified field index
|
||||||
m_Handle->ValidateField(idx, file, line);
|
m_Handle->ValidateField(idx, file, line);
|
||||||
@ -2471,7 +2471,7 @@ void ResultSet::Validate(const char * file, int32_t line) const
|
|||||||
// Do we have a valid result-set handle?
|
// Do we have a valid result-set handle?
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -2492,11 +2492,11 @@ void ResultSet::ValidateCreated(const char * file, int32_t line) const
|
|||||||
// Do we have a valid result-set handle?
|
// Do we have a valid result-set handle?
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
else if (m_Handle->mPtr == nullptr)
|
else if (m_Handle->mPtr == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -2521,12 +2521,12 @@ void ResultSet::ValidateStepped(const char * file, int32_t line) const
|
|||||||
// Do we have a valid result-set handle?
|
// Do we have a valid result-set handle?
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Do we have a valid row available?
|
// Do we have a valid row available?
|
||||||
else if (m_Handle->mRow == nullptr)
|
else if (m_Handle->mRow == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("No row available in MySQL result-set =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("No row available in MySQL result-set =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -2753,7 +2753,7 @@ void Statement::Validate(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -2772,11 +2772,11 @@ void Statement::ValidateCreated(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
else if (m_Handle->mPtr == nullptr)
|
else if (m_Handle->mPtr == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL statement =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL statement =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -650,7 +650,7 @@ public:
|
|||||||
* Grab the current error in the associated statement or connection handle and throw it.
|
* Grab the current error in the associated statement or connection handle and throw it.
|
||||||
*/
|
*/
|
||||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||||
void ThrowCurrent(const char * act, const char * file, int32_t line);
|
void ThrowCurrent(const char * act, const char * file, int32_t line) const;
|
||||||
#else
|
#else
|
||||||
void ThrowCurrent(const char * act) const;
|
void ThrowCurrent(const char * act) const;
|
||||||
#endif // _DEBUG
|
#endif // _DEBUG
|
||||||
|
@ -895,7 +895,7 @@ void SQLiteConnection::Validate(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite connection reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite connection reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -914,11 +914,11 @@ void SQLiteConnection::ValidateCreated(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite connection reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite connection reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
else if (m_Handle->mPtr == nullptr)
|
else if (m_Handle->mPtr == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite connection =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite connection =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -1227,12 +1227,12 @@ void SQLiteParameter::Validate(const char * file, int32_t line) const
|
|||||||
// Are we pointing to a valid index?
|
// Are we pointing to a valid index?
|
||||||
if (m_Index < 0)
|
if (m_Index < 0)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid column index: {} < 0 =>[{}:{}]", m_Index, file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid column index: {} < 0 =>[{}:{}]"), m_Index, file, line);
|
||||||
}
|
}
|
||||||
// Do we have a valid statement handle?
|
// Do we have a valid statement handle?
|
||||||
else if (!m_Handle)
|
else if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -1258,15 +1258,15 @@ void SQLiteParameter::ValidateCreated(const char * file, int32_t line) const
|
|||||||
// Are we pointing to a valid index?
|
// Are we pointing to a valid index?
|
||||||
if (m_Index < 0)
|
if (m_Index < 0)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid column index: {} < 0 =>[{}:{}]", m_Index, file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid column index: {} < 0 =>[{}:{}]"), m_Index, file, line);
|
||||||
}
|
}
|
||||||
else if (!m_Handle)
|
else if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
else if (m_Handle->mPtr == nullptr)
|
else if (m_Handle->mPtr == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -1326,7 +1326,7 @@ void SQLiteParameter::ValidateParam(int32_t idx, const char * file, int32_t line
|
|||||||
// Is the specified index in range?
|
// Is the specified index in range?
|
||||||
if (!m_Handle->CheckParameter(idx))
|
if (!m_Handle->CheckParameter(idx))
|
||||||
{
|
{
|
||||||
SqThrowF("Parameter index is out of range ({}:{}) =>[{}:{}]", idx, m_Handle->mParameters,
|
SqThrowF(SQMOD_RTFMT("Parameter index is out of range ({}:{}) =>[{}:{}]"), idx, m_Handle->mParameters,
|
||||||
file, line);
|
file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1933,12 +1933,12 @@ void SQLiteColumn::Validate(const char * file, int32_t line) const
|
|||||||
// Are we pointing to a valid index?
|
// Are we pointing to a valid index?
|
||||||
if (m_Index < 0)
|
if (m_Index < 0)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid column index: {} < 0 =>[{}:{}]", m_Index, file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid column index: {} < 0 =>[{}:{}]"), m_Index, file, line);
|
||||||
}
|
}
|
||||||
// Do we have a valid statement handle?
|
// Do we have a valid statement handle?
|
||||||
else if (!m_Handle)
|
else if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -1964,15 +1964,15 @@ void SQLiteColumn::ValidateCreated(const char * file, int32_t line) const
|
|||||||
// Are we pointing to a valid index?
|
// Are we pointing to a valid index?
|
||||||
if (m_Index < 0)
|
if (m_Index < 0)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid column index: {} < 0 =>[{}:{}]", m_Index, file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid column index: {} < 0 =>[{}:{}]"), m_Index, file, line);
|
||||||
}
|
}
|
||||||
else if (!m_Handle)
|
else if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
else if (m_Handle->mPtr == nullptr)
|
else if (m_Handle->mPtr == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -2032,7 +2032,7 @@ void SQLiteColumn::ValidateColumn(int32_t idx, const char * file, int32_t line)
|
|||||||
// Is the specified index in range?
|
// Is the specified index in range?
|
||||||
if (!m_Handle->CheckColumn(idx))
|
if (!m_Handle->CheckColumn(idx))
|
||||||
{
|
{
|
||||||
SqThrowF("Column index is out of range: {}:{} =>[{}:{}]", idx, m_Handle->mColumns,
|
SqThrowF(SQMOD_RTFMT("Column index is out of range: {}:{} =>[{}:{}]"), idx, m_Handle->mColumns,
|
||||||
file, line);
|
file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2407,7 +2407,7 @@ void SQLiteStatement::Validate(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -2426,11 +2426,11 @@ void SQLiteStatement::ValidateCreated(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
else if (m_Handle->mPtr == nullptr)
|
else if (m_Handle->mPtr == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -2485,7 +2485,7 @@ void SQLiteStatement::ValidateColumn(int32_t idx, const char * file, int32_t lin
|
|||||||
// Is the specified index in range?
|
// Is the specified index in range?
|
||||||
if (!m_Handle->CheckColumn(idx))
|
if (!m_Handle->CheckColumn(idx))
|
||||||
{
|
{
|
||||||
SqThrowF("Column index is out of range: {}:{} =>[{}:{}]", idx, m_Handle->mColumns, file, line);
|
SqThrowF(SQMOD_RTFMT("Column index is out of range: {}:{} =>[{}:{}]"), idx, m_Handle->mColumns, file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -2508,7 +2508,7 @@ void SQLiteStatement::ValidateParam(int32_t idx, const char * file, int32_t line
|
|||||||
// Is the specified index in range?
|
// Is the specified index in range?
|
||||||
if (!m_Handle->CheckParameter(idx))
|
if (!m_Handle->CheckParameter(idx))
|
||||||
{
|
{
|
||||||
SqThrowF("Parameter index is out of range: {}:{} =>[{}:{}]", idx, m_Handle->mParameters, file, line);
|
SqThrowF(SQMOD_RTFMT("Parameter index is out of range: {}:{} =>[{}:{}]"), idx, m_Handle->mParameters, file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -2531,7 +2531,7 @@ void SQLiteStatement::ValidateRow(const char * file, int32_t line) const
|
|||||||
// Do we have any rows available?
|
// Do we have any rows available?
|
||||||
if (!m_Handle->mGood)
|
if (!m_Handle->mGood)
|
||||||
{
|
{
|
||||||
SqThrowF("No row available =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("No row available =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -506,6 +506,44 @@ enum EntityType
|
|||||||
#define SQMOD_NODISCARD
|
#define SQMOD_NODISCARD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* FLOAT SELECTION
|
||||||
|
*/
|
||||||
|
#ifdef SQUSEDOUBLE
|
||||||
|
#define SQMOD_DOUBLE_ONLY(X) X
|
||||||
|
#define SQMOD_EXCEPT_DOUBLE(X)
|
||||||
|
#define SQMOD_FLOAT_ONLY(X)
|
||||||
|
#define SQMOD_EXCEPT_FLOAT(X) X
|
||||||
|
#else
|
||||||
|
#define SQMOD_DOUBLE_ONLY(X) X
|
||||||
|
#define SQMOD_EXCEPT_DOUBLE(X)
|
||||||
|
#define SQMOD_FLOAT_ONLY(X)
|
||||||
|
#define SQMOD_EXCEPT_FLOAT(X) X
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SQMOD_DOUBLE_OR(D, F) SQMOD_DOUBLE_ONLY(D) SQMOD_EXCEPT_DOUBLE(F)
|
||||||
|
#define SQMOD_FLOAT_OR(F, D) SQMOD_FLOAT_ONLY(F) SQMOD_EXCEPT_FLOAT(D)
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* DEBUG SELECTION
|
||||||
|
*/
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#define SQMOD_DEBUG_ONLY(X) X
|
||||||
|
#define SQMOD_EXCEPT_DEBUG(X)
|
||||||
|
#define SQMOD_RELEASE_ONLY(X)
|
||||||
|
#define SQMOD_EXCEPT_RELEASE(X) X
|
||||||
|
#define SQMOD_RTFMT(X) fmt::runtime(X)
|
||||||
|
#else
|
||||||
|
#define SQMOD_DEBUG_ONLY(X)
|
||||||
|
#define SQMOD_EXCEPT_DEBUG(X) X
|
||||||
|
#define SQMOD_RELEASE_ONLY(X) X
|
||||||
|
#define SQMOD_EXCEPT_RELEASE(X)
|
||||||
|
#define SQMOD_RTFMT(X) X
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SQMOD_DEBUG_OR(D, R) SQMOD_DEBUG_ONLY(D) SQMOD_EXCEPT_DEBUG(R)
|
||||||
|
#define SQMOD_RELEASE_OR(R, D) SQMOD_RELEASE_ONLY(R) SQMOD_EXCEPT_RELEASE(D)
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* LOGGING LOCATION
|
* LOGGING LOCATION
|
||||||
*/
|
*/
|
||||||
@ -525,7 +563,7 @@ enum EntityType
|
|||||||
|
|
||||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||||
#define STHROW(e, m, ...) throw e(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
|
#define STHROW(e, m, ...) throw e(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
|
||||||
#define STHROWF(m, ...) SqThrowF(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
|
#define STHROWF(m, ...) SqThrowF(fmt::runtime(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] "), ##__VA_ARGS__)
|
||||||
#define STHROWLASTF(m, ...) SqThrowLastF(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
|
#define STHROWLASTF(m, ...) SqThrowLastF(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define STHROW(e, m, ...) throw e(m, ##__VA_ARGS__)
|
#define STHROW(e, m, ...) throw e(m, ##__VA_ARGS__)
|
||||||
|
6
vendor/CMakeLists.txt
vendored
6
vendor/CMakeLists.txt
vendored
@ -35,16 +35,16 @@ set(POCO_UNBUNDLED OFF CACHE INTERNAL "" FORCE)
|
|||||||
add_subdirectory(POCO)
|
add_subdirectory(POCO)
|
||||||
# Windows gets stupid sometimes
|
# Windows gets stupid sometimes
|
||||||
if (WIN32 AND MINGW)
|
if (WIN32 AND MINGW)
|
||||||
target_compile_definitions(Foundation PUBLIC POCO_NO_FPENVIRONMENT=1)
|
target_compile_definitions(Foundation PUBLIC POCO_NO_FPENVIRONMENT=1)
|
||||||
endif()
|
endif()
|
||||||
# We have these on GCC
|
# We have these on GCC
|
||||||
if(MINGW OR GCC)
|
if(MINGW OR GCC)
|
||||||
set(ENABLE_INTRINSICS ON CACHE INTERNAL "" FORCE)
|
set(ENABLE_INTRINSICS ON CACHE INTERNAL "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
set(BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
|
set(BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
|
||||||
set(BUILD_SHARED OFF CACHE INTERNAL "" FORCE)
|
set(BUILD_SHARED OFF CACHE INTERNAL "" FORCE)
|
||||||
set(BUILD_STATIC ON CACHE INTERNAL "" FORCE)
|
set(BUILD_STATIC ON CACHE INTERNAL "" FORCE)
|
||||||
if (WIN32 OR MINGW)
|
if (WIN32 OR MINGW)
|
||||||
set(ZMQ_HAVE_IPC OFF CACHE INTERNAL "" FORCE)
|
set(ZMQ_HAVE_IPC OFF CACHE INTERNAL "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
add_subdirectory(ZMQ)
|
add_subdirectory(ZMQ)
|
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
// Check debug/release settings consistency
|
// Check debug/release settings consistency
|
||||||
#if defined(NDEBUG) && defined(_DEBUG)
|
#if defined(NDEBUG) && defined(_DEBUG)
|
||||||
#error Inconsistent build settings (check for /MD[d])
|
//#error Inconsistent build settings (check for /MD[d])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
2
vendor/Squirrel/CMakeLists.txt
vendored
2
vendor/Squirrel/CMakeLists.txt
vendored
@ -48,7 +48,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
# Make sure Squirrel knows this is 64 bit
|
# Make sure Squirrel knows this is 64 bit
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
target_compile_definitions(Squirrel PUBLIC _SQ64)
|
target_compile_definitions(Squirrel PUBLIC _SQ64=1 SQUSEDOUBLE=1)
|
||||||
endif()
|
endif()
|
||||||
# Set specific compiler options
|
# Set specific compiler options
|
||||||
if (GCC OR MINGW)
|
if (GCC OR MINGW)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user