Add SQLite again (still heavy WIP)
This commit is contained in:
+54
-29
@@ -1,5 +1,5 @@
|
||||
// Blitz - Steam wrapper for Blitz.
|
||||
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
@@ -17,43 +17,68 @@
|
||||
#include "Double.h"
|
||||
#include <list>
|
||||
|
||||
// Templates
|
||||
template< typename T >
|
||||
std::string int_to_hex(T i) {
|
||||
std::stringstream stream;
|
||||
stream
|
||||
<< std::setfill('0')
|
||||
<< std::setw(sizeof(T) * 2)
|
||||
<< std::hex
|
||||
<< i;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
T hex_to_int(std::string t) {
|
||||
T x;
|
||||
std::stringstream stream;
|
||||
stream
|
||||
<< std::hex
|
||||
<< t;
|
||||
stream
|
||||
>> x;
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
std::list<double_t*> BU_DoubleTemporary;
|
||||
|
||||
DLL_METHOD double_t* DLL_CALL BU_Double_Create() {
|
||||
DLL_FUNCTION(double_t*) BU_Double_Create() {
|
||||
return new double_t;
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_Double_Destroy(double_t* pthis) {
|
||||
DLL_FUNCTION(void) BU_Double_Destroy(double_t* pthis) {
|
||||
delete pthis;
|
||||
}
|
||||
|
||||
DLL_METHOD double_t* DLL_CALL BU_Double_Copy(double_t* other) {
|
||||
DLL_FUNCTION(double_t*) BU_Double_Copy(double_t* other) {
|
||||
double_t* pthis = new double_t;
|
||||
*pthis = *other;
|
||||
return pthis;
|
||||
}
|
||||
|
||||
DLL_METHOD double_t* DLL_CALL BU_Double_TempCreate() {
|
||||
DLL_FUNCTION(double_t*) BU_Double_TempCreate() {
|
||||
double_t* val = new double_t;
|
||||
BU_DoubleTemporary.push_back(val);
|
||||
return val;
|
||||
}
|
||||
|
||||
DLL_METHOD double_t* DLL_CALL BU_Double_TempCopy(double_t* other) {
|
||||
DLL_FUNCTION(double_t*) BU_Double_TempCopy(double_t* other) {
|
||||
double_t* val = new double_t(*other);
|
||||
BU_DoubleTemporary.push_back(val);
|
||||
return val;
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_Double_SetTemp(double_t* pthis) {
|
||||
DLL_FUNCTION(void) BU_Double_SetTemp(double_t* pthis) {
|
||||
BU_DoubleTemporary.push_back(pthis);
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_Double_UnsetTemp(double_t* pthis) {
|
||||
DLL_FUNCTION(void) BU_Double_UnsetTemp(double_t* pthis) {
|
||||
BU_DoubleTemporary.remove(pthis);
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_Double_TempCleanup() {
|
||||
DLL_FUNCTION(void) BU_Double_TempCleanup() {
|
||||
auto iterEnd = BU_DoubleTemporary.end();
|
||||
for (auto iter = BU_DoubleTemporary.begin(); iter != iterEnd; ++iter) {
|
||||
delete *iter;
|
||||
@@ -61,90 +86,90 @@ DLL_METHOD void DLL_CALL BU_Double_TempCleanup() {
|
||||
BU_DoubleTemporary.clear();
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_Double_Set(double_t* pthis, double_t* other) {
|
||||
DLL_FUNCTION(void) BU_Double_Set(double_t* pthis, double_t* other) {
|
||||
*pthis = *other;
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_Double_SetF(double_t* pthis, float_t other) {
|
||||
DLL_FUNCTION(void) BU_Double_SetF(double_t* pthis, float_t other) {
|
||||
*pthis = other;
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_Double_Add(double_t* pthis, double_t* other) {
|
||||
DLL_FUNCTION(void) BU_Double_Add(double_t* pthis, double_t* other) {
|
||||
*pthis += *other;
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_Double_AddF(double_t* pthis, float_t other) {
|
||||
DLL_FUNCTION(void) BU_Double_AddF(double_t* pthis, float_t other) {
|
||||
*pthis += other;
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_Double_Sub(double_t* pthis, double_t* other) {
|
||||
DLL_FUNCTION(void) BU_Double_Sub(double_t* pthis, double_t* other) {
|
||||
*pthis -= *other;
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_Double_SubF(double_t* pthis, float_t other) {
|
||||
DLL_FUNCTION(void) BU_Double_SubF(double_t* pthis, float_t other) {
|
||||
*pthis -= other;
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_Double_Mul(double_t* pthis, double_t* other) {
|
||||
DLL_FUNCTION(void) BU_Double_Mul(double_t* pthis, double_t* other) {
|
||||
*pthis *= *other;
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_Double_MulF(double_t* pthis, float_t other) {
|
||||
DLL_FUNCTION(void) BU_Double_MulF(double_t* pthis, float_t other) {
|
||||
*pthis *= other;
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_Double_Div(double_t* pthis, double_t* other) {
|
||||
DLL_FUNCTION(void) BU_Double_Div(double_t* pthis, double_t* other) {
|
||||
*pthis /= *other;
|
||||
}
|
||||
|
||||
DLL_METHOD void DLL_CALL BU_Double_DivF(double_t* pthis, float_t other) {
|
||||
DLL_FUNCTION(void) BU_Double_DivF(double_t* pthis, float_t other) {
|
||||
*pthis /= other;
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_Double_Compare(double_t* pthis, double_t* other) {
|
||||
DLL_FUNCTION(uint32_t) BU_Double_Compare(double_t* pthis, double_t* other) {
|
||||
return (*pthis == *other ? 1 : 0) + (*pthis < *other ? 2 : 0) + (*pthis > *other ? 4 : 0);
|
||||
}
|
||||
|
||||
DLL_METHOD uint32_t DLL_CALL BU_Double_CompareF(double_t* pthis, float_t other) {
|
||||
DLL_FUNCTION(uint32_t) BU_Double_CompareF(double_t* pthis, float_t other) {
|
||||
return ((float_t)*pthis == other ? 1 : 0) + ((float_t)*pthis < other ? 2 : 0) + ((float_t)*pthis > other ? 4 : 0);
|
||||
}
|
||||
|
||||
DLL_METHOD const char* DLL_CALL BU_Double_ToString(double_t* pthis) {
|
||||
DLL_FUNCTION(const char*) BU_Double_ToString(double_t* pthis) {
|
||||
std::stringstream stream;
|
||||
stream << *pthis;
|
||||
return stream.str().c_str();
|
||||
}
|
||||
|
||||
DLL_METHOD double_t* DLL_CALL BU_Double_FromString(const char* text) {
|
||||
DLL_FUNCTION(double_t*) BU_Double_FromString(const char* text) {
|
||||
std::stringstream stream = std::stringstream(text);
|
||||
double_t* doublePtr = new double_t;
|
||||
stream >> *doublePtr;
|
||||
return doublePtr;
|
||||
}
|
||||
|
||||
DLL_METHOD float_t DLL_CALL BU_Double_ToFloat(double_t* pthis) {
|
||||
DLL_FUNCTION(float_t) BU_Double_ToFloat(double_t* pthis) {
|
||||
return (float_t)*pthis;
|
||||
}
|
||||
|
||||
DLL_METHOD double_t* DLL_CALL BU_Double_FromFloat(float_t other) {
|
||||
DLL_FUNCTION(double_t*) BU_Double_FromFloat(float_t other) {
|
||||
double_t* val = new double_t;
|
||||
*val = (double_t)other;
|
||||
return val;
|
||||
}
|
||||
|
||||
DLL_METHOD int64_t* DLL_CALL BU_Double_ToLongLong(double_t* pthis) {
|
||||
DLL_FUNCTION(int64_t*) BU_Double_ToLongLong(double_t* pthis) {
|
||||
int64_t* val = new int64_t;
|
||||
*val = (int64_t)*pthis;
|
||||
return val;
|
||||
}
|
||||
|
||||
DLL_METHOD double_t* DLL_CALL BU_Double_FromLongLong(int64_t* other) {
|
||||
DLL_FUNCTION(double_t*) BU_Double_FromLongLong(int64_t* other) {
|
||||
double_t* val = new double_t;
|
||||
*val = (double_t)*other;
|
||||
return val;
|
||||
}
|
||||
|
||||
DLL_METHOD const char* DLL_CALL BU_Double_Serialize(double_t* pthis) {
|
||||
DLL_FUNCTION(const char*) BU_Double_Serialize(double_t* pthis) {
|
||||
union {
|
||||
double_t real;
|
||||
int64_t integer;
|
||||
@@ -153,7 +178,7 @@ DLL_METHOD const char* DLL_CALL BU_Double_Serialize(double_t* pthis) {
|
||||
return int_to_hex<int64_t>(myval.integer).c_str();
|
||||
}
|
||||
|
||||
DLL_METHOD double_t* DLL_CALL BU_Double_Deserialize(const char* text) {
|
||||
DLL_FUNCTION(double_t*) BU_Double_Deserialize(const char* text) {
|
||||
union {
|
||||
double_t real;
|
||||
int64_t integer;
|
||||
|
||||
Reference in New Issue
Block a user