From 3c75ecd381001624908fcef682fdc1ee973e3143 Mon Sep 17 00:00:00 2001 From: RobQuistNL Date: Sat, 11 Jul 2020 13:22:54 +0200 Subject: [PATCH 1/4] Fix for UE4.25.1 --- Source/CISQLite3/CISQLite3.Build.cs | 6 +++--- Source/CISQLite3/Private/CISQLite3.cpp | 1 + .../Private/SQLiteBlueprintFunctionLibrary.cpp | 6 +++--- Source/CISQLite3/Private/SQLiteDatabase.cpp | 10 +++++----- Source/CISQLite3/Public/CISQLite3.h | 2 +- Source/CISQLite3/Public/SQLiteDatabase.h | 2 +- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Source/CISQLite3/CISQLite3.Build.cs b/Source/CISQLite3/CISQLite3.Build.cs index 46fec0f..ddce8a4 100644 --- a/Source/CISQLite3/CISQLite3.Build.cs +++ b/Source/CISQLite3/CISQLite3.Build.cs @@ -11,9 +11,9 @@ public CISQLite3(ReadOnlyTargetRules Target) : base(Target) PublicIncludePaths.AddRange(new string[] { Path.Combine(ModuleDirectory, "Public") }); PrivateIncludePaths.AddRange(new string[] { Path.Combine(ModuleDirectory, "Private") }); - PrivatePCHHeaderFile = "Private/CISQLite3PrivatePCH.h"; - - PublicDependencyModuleNames.AddRange( + PrivatePCHHeaderFile = "Private/CISQLite3PrivatePCH.h"; + + PublicDependencyModuleNames.AddRange( new string[] { "Engine", "Core", diff --git a/Source/CISQLite3/Private/CISQLite3.cpp b/Source/CISQLite3/Private/CISQLite3.cpp index bd3293e..60deba1 100644 --- a/Source/CISQLite3/Private/CISQLite3.cpp +++ b/Source/CISQLite3/Private/CISQLite3.cpp @@ -1,5 +1,6 @@ // Copyright (c) 2016 conflict.industries MIT License (MIT) +#include "CISQLite3.h" #include "CISQLite3PrivatePCH.h" DEFINE_LOG_CATEGORY(LogDatabase) diff --git a/Source/CISQLite3/Private/SQLiteBlueprintFunctionLibrary.cpp b/Source/CISQLite3/Private/SQLiteBlueprintFunctionLibrary.cpp index 0fbde01..ee8cd42 100644 --- a/Source/CISQLite3/Private/SQLiteBlueprintFunctionLibrary.cpp +++ b/Source/CISQLite3/Private/SQLiteBlueprintFunctionLibrary.cpp @@ -1,8 +1,8 @@ -#include "CISQLite3PrivatePCH.h" -#include "Engine.h" -#include "CString.h" #include "SQLiteBlueprintFunctionLibrary.h" +#include "CISQLite3PrivatePCH.h" +#include "Engine.h" +#include "Misc/CString.h" diff --git a/Source/CISQLite3/Private/SQLiteDatabase.cpp b/Source/CISQLite3/Private/SQLiteDatabase.cpp index 7070d92..80e557d 100644 --- a/Source/CISQLite3/Private/SQLiteDatabase.cpp +++ b/Source/CISQLite3/Private/SQLiteDatabase.cpp @@ -1,5 +1,5 @@ -#include "CISQLite3PrivatePCH.h" #include "SQLiteDatabase.h" +#include "CISQLite3PrivatePCH.h" #define LOGSQLITE(verbosity, text) UE_LOG(LogDatabase, verbosity, TEXT("SQLite: %s"), text) @@ -273,12 +273,12 @@ bool USQLiteDatabase::GetDataIntoObjectBP(const FSQLiteDatabaseReference& DataSo //-------------------------------------------------------------------------------------------------------------- -TMap USQLiteDatabase::CollectProperties(UObject* SourceObject) +TMap USQLiteDatabase::CollectProperties(UObject* SourceObject) { UClass* SourceObjectClass = SourceObject->GetClass(); - TMap Props; - for (TFieldIterator PropIt(SourceObjectClass, EFieldIteratorFlags::SuperClassFlags::IncludeSuper); + TMap Props; + for (TFieldIterator PropIt(SourceObjectClass, EFieldIteratorFlags::SuperClassFlags::IncludeSuper); PropIt; ++PropIt) { Props.Add(*PropIt->GetNameCPP(), *PropIt); @@ -797,7 +797,7 @@ void USQLiteDatabase::AssignResultsToObjectProperties(const SQLiteResultValue& R { if (propertyMap.Contains(field.Name)) { - UProperty* targetProperty = propertyMap[field.Name]; + FProperty* targetProperty = propertyMap[field.Name]; if (field.Type == SQLiteResultValueTypes::Integer) { diff --git a/Source/CISQLite3/Public/CISQLite3.h b/Source/CISQLite3/Public/CISQLite3.h index 0ba53e2..25f0bd7 100644 --- a/Source/CISQLite3/Public/CISQLite3.h +++ b/Source/CISQLite3/Public/CISQLite3.h @@ -2,7 +2,7 @@ #pragma once -#include "ModuleManager.h" +#include "Modules/ModuleManager.h" class FCISQLite3 : public IModuleInterface { diff --git a/Source/CISQLite3/Public/SQLiteDatabase.h b/Source/CISQLite3/Public/SQLiteDatabase.h index 648f428..04af4f0 100644 --- a/Source/CISQLite3/Public/SQLiteDatabase.h +++ b/Source/CISQLite3/Public/SQLiteDatabase.h @@ -214,7 +214,7 @@ class CISQLITE3_API USQLiteDatabase : public UObject /** Tries to open a database. */ static bool CanOpenDatabase(const FString& DatabaseFilename); /** Collects all properties from an UObject and maps them by the property name. */ - static TMap CollectProperties(UObject* SourceObject); + static TMap CollectProperties(UObject* SourceObject); /** Constructs an SQL query from the blueprint fed data. */ static FString ConstructQuery(TArray Tables, TArray Fields, FSQLiteQueryFinalizedQuery QueryObject, int32 MaxResults = -1, int32 ResultOffset = 0); /** Assigns a result row's fields' values to an UObject, ie. assigns them to the properties that have the same name. */ From 64c7b581ecd0a6bdd6ecff68f48c661ace4e04da Mon Sep 17 00:00:00 2001 From: RobQuistNL Date: Sat, 11 Jul 2020 19:19:45 +0200 Subject: [PATCH 2/4] Fix paths to be parsed instead of always relative --- Source/CISQLite3/Private/SQLiteDatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CISQLite3/Private/SQLiteDatabase.cpp b/Source/CISQLite3/Private/SQLiteDatabase.cpp index 80e557d..190db64 100644 --- a/Source/CISQLite3/Private/SQLiteDatabase.cpp +++ b/Source/CISQLite3/Private/SQLiteDatabase.cpp @@ -17,7 +17,7 @@ USQLiteDatabase::USQLiteDatabase(const FObjectInitializer& ObjectInitializer) bool USQLiteDatabase::CreateDatabase(const FString& Filename, bool RelativeToProjectContentDirectory) { - const FString actualFilename = RelativeToProjectContentDirectory ? FPaths::ProjectContentDir() + Filename : Filename; + const FString actualFilename = RelativeToProjectContentDirectory ? FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir()) + Filename : Filename; sqlite3* db; int res = sqlite3_open(TCHAR_TO_ANSI(*actualFilename), &db); From e7eeb8e39656e6fafedae2c67f0d802d37b5870a Mon Sep 17 00:00:00 2001 From: RobQuistNL Date: Mon, 17 Aug 2020 00:57:03 +0200 Subject: [PATCH 3/4] More fixes --- Source/CISQLite3/CISQLite3.Build.cs | 64 +++++++++---------- .../SQLiteBlueprintFunctionLibrary.cpp | 5 -- Source/CISQLite3/Private/SQLiteDatabase.cpp | 35 +++++----- Source/CISQLite3/Public/SQLiteDatabase.h | 1 + 4 files changed, 51 insertions(+), 54 deletions(-) diff --git a/Source/CISQLite3/CISQLite3.Build.cs b/Source/CISQLite3/CISQLite3.Build.cs index ddce8a4..42099cb 100644 --- a/Source/CISQLite3/CISQLite3.Build.cs +++ b/Source/CISQLite3/CISQLite3.Build.cs @@ -1,34 +1,34 @@ -// Copyright (c) 2015 Jussi Saarivirta 2016 conflict.industries MIT License (MIT) - -using UnrealBuildTool; -using System.IO; - -public class CISQLite3 : ModuleRules -{ - public CISQLite3(ReadOnlyTargetRules Target) : base(Target) - { - - PublicIncludePaths.AddRange(new string[] { Path.Combine(ModuleDirectory, "Public") }); - PrivateIncludePaths.AddRange(new string[] { Path.Combine(ModuleDirectory, "Private") }); - +// Copyright (c) 2015 Jussi Saarivirta 2016 conflict.industries MIT License (MIT) + +using UnrealBuildTool; +using System.IO; + +public class CISQLite3 : ModuleRules +{ + public CISQLite3(ReadOnlyTargetRules Target) : base(Target) + { + + PublicIncludePaths.AddRange(new string[] { Path.Combine(ModuleDirectory, "Public") }); + PrivateIncludePaths.AddRange(new string[] { Path.Combine(ModuleDirectory, "Private") }); + PrivatePCHHeaderFile = "Private/CISQLite3PrivatePCH.h"; - PublicDependencyModuleNames.AddRange( - new string[] { - "Engine", - "Core", - "CoreUObject" - } - ); - - PrivateDefinitions.Add("SQLITE_ENABLE_DESERIALIZE=1"); - - PrivateDependencyModuleNames.AddRange( - new string[] {} - ); - - DynamicallyLoadedModuleNames.AddRange( - new string[] {} - ); - } -} + PublicDependencyModuleNames.AddRange( + new string[] { + "Engine", + "Core", + "CoreUObject" + } + ); + + PrivateDefinitions.Add("SQLITE_ENABLE_DESERIALIZE=1"); + + PrivateDependencyModuleNames.AddRange( + new string[] {} + ); + + DynamicallyLoadedModuleNames.AddRange( + new string[] {} + ); + } +} diff --git a/Source/CISQLite3/Private/SQLiteBlueprintFunctionLibrary.cpp b/Source/CISQLite3/Private/SQLiteBlueprintFunctionLibrary.cpp index ee8cd42..de89ac8 100644 --- a/Source/CISQLite3/Private/SQLiteBlueprintFunctionLibrary.cpp +++ b/Source/CISQLite3/Private/SQLiteBlueprintFunctionLibrary.cpp @@ -1,18 +1,13 @@ - #include "SQLiteBlueprintFunctionLibrary.h" #include "CISQLite3PrivatePCH.h" #include "Engine.h" #include "Misc/CString.h" - - - int32 USQLiteBlueprintFunctionLibrary::CastToInt(FString SQLiteResultValue) { return FCString::Atoi(*SQLiteResultValue); } - bool USQLiteBlueprintFunctionLibrary::CastToBoolean(FString SQLiteResultValue) { return FCString::Atoi(*SQLiteResultValue) > 0; diff --git a/Source/CISQLite3/Private/SQLiteDatabase.cpp b/Source/CISQLite3/Private/SQLiteDatabase.cpp index 190db64..d429a99 100644 --- a/Source/CISQLite3/Private/SQLiteDatabase.cpp +++ b/Source/CISQLite3/Private/SQLiteDatabase.cpp @@ -37,7 +37,7 @@ bool USQLiteDatabase::CreateDatabase(const FString& Filename, bool RelativeToPro bool USQLiteDatabase::RegisterDatabase(const FString& Name, const FString& Filename, bool RelativeToProjectContentDirectory, bool KeepOpen) { - const FString actualFilename = RelativeToProjectContentDirectory ? FPaths::ProjectContentDir() + Filename : Filename; + const FString actualFilename = RelativeToProjectContentDirectory ? FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir()) + Filename : Filename; if (!IsValidDatabase(actualFilename, true)) { @@ -782,6 +782,7 @@ TUniquePtr USQLiteDatabase::RunQueryAndGetResults(const FStri sqlite3_finalize(preparedStatement); if (!keepOpen) sqlite3_close(db); + result.InsertedId = sqlite3_last_insert_rowid(db); result.Results = resultRows; result.Success = true; return MakeUnique(MoveTemp(result)); @@ -801,33 +802,33 @@ void USQLiteDatabase::AssignResultsToObjectProperties(const SQLiteResultValue& R if (field.Type == SQLiteResultValueTypes::Integer) { - UInt64Property* int64prop = NULL; - UIntProperty* int32prop = NULL; - UInt16Property* int16prop = NULL; - UInt8Property* int8prop = NULL; - UBoolProperty* boolProp = NULL; + FInt64Property* int64prop = NULL; + FIntProperty* int32prop = NULL; + FInt16Property* int16prop = NULL; + FInt8Property* int8prop = NULL; + FBoolProperty* boolProp = NULL; - if ((int64prop = Cast(targetProperty)) != NULL) + if ((int64prop = CastField(targetProperty)) != NULL) { int64prop->SetPropertyValue_InContainer(ObjectToPopulate, field.IntValue); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue)); } - else if ((int32prop = Cast(targetProperty)) != NULL) + else if ((int32prop = CastField(targetProperty)) != NULL) { int32prop->SetPropertyValue_InContainer(ObjectToPopulate, (int32)field.IntValue); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue)); } - else if ((int16prop = Cast(targetProperty)) != NULL) + else if ((int16prop = CastField(targetProperty)) != NULL) { int16prop->SetPropertyValue_InContainer(ObjectToPopulate, (int16)field.IntValue); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue)); } - else if ((int8prop = Cast(targetProperty)) != NULL) + else if ((int8prop = CastField(targetProperty)) != NULL) { int8prop->SetPropertyValue_InContainer(ObjectToPopulate, (int8)field.IntValue); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue)); } - else if ((boolProp = Cast(targetProperty)) != NULL) + else if ((boolProp = CastField(targetProperty)) != NULL) { boolProp->SetPropertyValue_InContainer(ObjectToPopulate, field.IntValue > 0); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue)); @@ -836,14 +837,14 @@ void USQLiteDatabase::AssignResultsToObjectProperties(const SQLiteResultValue& R else if (field.Type == SQLiteResultValueTypes::Float) { - UDoubleProperty* doubleProp = NULL; - UFloatProperty* floatProp = NULL; - if ((doubleProp = Cast(targetProperty)) != NULL) + FDoubleProperty* doubleProp = NULL; + FFloatProperty* floatProp = NULL; + if ((doubleProp = CastField(targetProperty)) != NULL) { doubleProp->SetPropertyValue_InContainer(ObjectToPopulate, field.DoubleValue); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%f'"), *field.Name, field.DoubleValue)); } - else if ((floatProp = Cast(targetProperty)) != NULL) + else if ((floatProp = CastField(targetProperty)) != NULL) { floatProp->SetPropertyValue_InContainer(ObjectToPopulate, (float)field.DoubleValue); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%f'"), *field.Name, field.DoubleValue)); @@ -852,8 +853,8 @@ void USQLiteDatabase::AssignResultsToObjectProperties(const SQLiteResultValue& R else if (field.Type == SQLiteResultValueTypes::Text) { - UStrProperty* strProp = NULL; - if ((strProp = Cast(targetProperty)) != NULL) + FStrProperty* strProp = NULL; + if ((strProp = CastField(targetProperty)) != NULL) { strProp->SetPropertyValue_InContainer(ObjectToPopulate, field.StringValue); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%s'"), *field.Name, *field.StringValue.Mid(0, 64))); diff --git a/Source/CISQLite3/Public/SQLiteDatabase.h b/Source/CISQLite3/Public/SQLiteDatabase.h index 04af4f0..b79768f 100644 --- a/Source/CISQLite3/Public/SQLiteDatabase.h +++ b/Source/CISQLite3/Public/SQLiteDatabase.h @@ -111,6 +111,7 @@ struct SQLiteQueryResult bool Success; FString ErrorMessage; TArray Results; + int InsertedId = 0; }; From 048f76cbbad47cc814d30f10a6755a5fc9b6d579 Mon Sep 17 00:00:00 2001 From: RobQuistNL Date: Mon, 17 Aug 2020 00:58:35 +0200 Subject: [PATCH 4/4] Revert linefeed issues --- Source/CISQLite3/CISQLite3.Build.cs | 68 ++++++++++++++--------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/Source/CISQLite3/CISQLite3.Build.cs b/Source/CISQLite3/CISQLite3.Build.cs index 42099cb..46fec0f 100644 --- a/Source/CISQLite3/CISQLite3.Build.cs +++ b/Source/CISQLite3/CISQLite3.Build.cs @@ -1,34 +1,34 @@ -// Copyright (c) 2015 Jussi Saarivirta 2016 conflict.industries MIT License (MIT) - -using UnrealBuildTool; -using System.IO; - -public class CISQLite3 : ModuleRules -{ - public CISQLite3(ReadOnlyTargetRules Target) : base(Target) - { - - PublicIncludePaths.AddRange(new string[] { Path.Combine(ModuleDirectory, "Public") }); - PrivateIncludePaths.AddRange(new string[] { Path.Combine(ModuleDirectory, "Private") }); - - PrivatePCHHeaderFile = "Private/CISQLite3PrivatePCH.h"; - - PublicDependencyModuleNames.AddRange( - new string[] { - "Engine", - "Core", - "CoreUObject" - } - ); - - PrivateDefinitions.Add("SQLITE_ENABLE_DESERIALIZE=1"); - - PrivateDependencyModuleNames.AddRange( - new string[] {} - ); - - DynamicallyLoadedModuleNames.AddRange( - new string[] {} - ); - } -} +// Copyright (c) 2015 Jussi Saarivirta 2016 conflict.industries MIT License (MIT) + +using UnrealBuildTool; +using System.IO; + +public class CISQLite3 : ModuleRules +{ + public CISQLite3(ReadOnlyTargetRules Target) : base(Target) + { + + PublicIncludePaths.AddRange(new string[] { Path.Combine(ModuleDirectory, "Public") }); + PrivateIncludePaths.AddRange(new string[] { Path.Combine(ModuleDirectory, "Private") }); + + PrivatePCHHeaderFile = "Private/CISQLite3PrivatePCH.h"; + + PublicDependencyModuleNames.AddRange( + new string[] { + "Engine", + "Core", + "CoreUObject" + } + ); + + PrivateDefinitions.Add("SQLITE_ENABLE_DESERIALIZE=1"); + + PrivateDependencyModuleNames.AddRange( + new string[] {} + ); + + DynamicallyLoadedModuleNames.AddRange( + new string[] {} + ); + } +}