我正在尝试将SQLite3集成到UE4中的测试项目中,但是遇到了一些问题,没有很多问题。
首先做一些家务。链接到GitHub上的仓库,Square提供了该插件,该插件是旧CISQLite3插件的分支和更新版本:
https://github.com/Squareys/unreal-sqlite3
接下来,我正在使用的项目是一个蓝图项目,其中包含在编辑器中创建的自定义类。
安装步骤: 我按照回购自述文件中的安装指南进行操作,其中指出以下内容:
下载插件zip并将其解压缩到项目的Plugins文件夹中。打开编辑器,然后转到插件管理器并启用插件。重新启动并允许编辑器编译插件。
在4.20.x中,这显然是所需要的。由于4.21.2中的任何原因,此过程都被中断。我遇到了与生成的文件有关的各种问题。
所以对于我尝试过的: 我尝试在插件中间文件夹中给出生成文件的绝对路径-这仅允许编译器从地狱吐出错误,就像老忠实信徒。
我试图开始一个新的项目;三次。我总是碰到一个点,由于出现错误,我无法再进一步了。
我已尝试在删除.vs,二进制文件,中间文件和保存的文件夹后重新生成项目文件。有时,重建可以重新创建文件(无法解决问题),但在某些时候它会开始失败,而当我打开项目时,它将无法编译项目dll / lib并要求手动编译。
好的,以此类推。我将逐步引导您,并在调试的每个步骤中显示错误。
首先,即使在没有自定义代码的新项目中,我也会收到以下两个警告:
MiningTechDemo5 \ Plugins \ CISQLite3 \ Source \ CISQLite3 \ CISQLite3.Build.cs:警告:模块必须从UE 4.21开始指定显式的预编译头(例如PrivatePCHHeaderFile =“ Private / CISQLite3PrivatePCH.h”)。
MiningTechDemo5 \ Plugins \ CISQLite3 \ Source \ CISQLite3 \ CISQLite3.Build.cs:警告:引用目录'F:\ UE4 \ Epic Games \ UE_4.21 \ Engine \ Source \ CISQLite3 \ Public'不存在。>
要解决此问题,我将插件构建文件更改为此:
// Copyright (c) 2015 Jussi Saarivirta 2016 conflict.industries MIT License (MIT)
using UnrealBuildTool;
public class CISQLite3 : ModuleRules
{
public CISQLite3(ReadOnlyTargetRules Target) : base(Target)
{
PublicIncludePaths.AddRange(
new string[] {
"F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Source/CISQLite3/Public"
}
);
PrivateIncludePaths.AddRange(
new string[] {
"F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Source/CISQLite3/Private"
}
);
PublicDependencyModuleNames.AddRange(
new string[] {
"Engine",
"Core",
"CoreUObject"
}
);
PrivateDependencyModuleNames.AddRange(
new string[] {}
);
DynamicallyLoadedModuleNames.AddRange(
new string[] {}
);
}
}
我必须使用绝对路径,因为出于某种原因,ModuleDirectory仅指向我的F:\驱动器,而不是project / plugin文件夹。因此,这些错误现在消失了。在我将SQLiteDatabase.h包含到我的DatabaseHandler自定义类(在编辑器中创建)之前,一切似乎都还不错。
我得到的第一个错误是找不到DatabaseHandler.genic.h,但这是由于第二个错误导致找不到SQLiteDatabase.h。所以我认为,也许这与CISQLite3构建文件存在相同的问题,并且我将项目构建文件从默认生成的代码更改为:
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
public class MiningTechDemo5 : ModuleRules
{
public MiningTechDemo5(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
PrivateDependencyModuleNames.AddRange(new string[] { });
PrivateIncludePaths.Add("F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Source/CISQLite3/Private");
PublicIncludePaths.Add("F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Source/CISQLite3/Public");
PublicLibraryPaths.Add("F:/UE4/Projects/MiningTechDemo5/Binaries/Win64");
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}
再次,完整路径是因为ModuleDirectory不起作用,并且Path.Combine也不起作用;至少不具有返回路径部分作为辅助成员的字符串属性,因此键入的文本更少。
所以我重建了,同样的错误。我继续将include更改为绝对路径:
包括“ SQLiteDatabase.h”
对此:
包括“ F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Source/CISQLite3/Public/SQLiteDatabase.h”
重新编译。 Huzzah,对此没有错误。废话,因为现在有一个新的错误。此文件用于SQLiteBlueprintNodes.h文件:
无法打开包含文件:“ SQLiteBlueprintNodes.generated.h”:没有此类文件或目录
好吧,所以我绝对将其指向此路径:
包括“ F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Intermediate/Build/Win64/UE4Editor/Inc/CISQLite3/SQLiteBlueprintNodes.generation.h”
此时,编译器将生成的文件取走,并用一堆编译器barf和一个新的未找到的新生成文件将其剔除,这是SQLiteDatabaseStructs.genic.h的错误:
'FSQLiteQueryLogicExpectedNode' uses undefined struct 'CISQLITE3_API' 8
'friend': not allowed outside of a class definition 9
type 'Z_Construct_UScriptStruct_FSQLiteQueryLogicExpectedNode_Statics' unexpected 9
missing type specifier - int assumed. Note: C++ does not support default-int 14
'FSQLiteQueryLogicExpectedNode': redefinition; previous definition was 'data variable' 14
missing type specifier - int assumed. Note: C++ does not support default-int 15
'FSQLiteQueryLogicExpectedNode': redefinition; previous definition was 'data variable' 15
'FSQLiteQueryLogicExpectedNode': constructor initializer lists are only allowed on constructor definitions 16
syntax error: '}' 19
syntax error: missing ';' before '}' 19
'FSQLiteQueryTermExpectedNode' uses undefined struct 'CISQLITE3_API' 23
'friend': not allowed outside of a class definition 24
type 'Z_Construct_UScriptStruct_FSQLiteQueryTermExpectedNode_Statics' unexpected 24
'FString Query': redefinition 27
'void __cdecl `dynamic initializer for 'Query''(void)': constructor initializer lists are only allowed on constructor definitions 27
missing type specifier - int assumed. Note: C++ does not support default-int 29
'FSQLiteQueryTermExpectedNode': redefinition; previous definition was 'data variable' 29
missing type specifier - int assumed. Note: C++ does not support default-int 30
'FSQLiteQueryTermExpectedNode': redefinition; previous definition was 'data variable' 30
'FSQLiteQueryTermExpectedNode': constructor initializer lists are only allowed on constructor definitions 31
syntax error: '}' 34
syntax error: missing ';' before '}' 34
'FSQLiteQueryFinalizedQuery' uses undefined struct 'CISQLITE3_API' 38
'friend': not allowed outside of a class definition 39
type 'Z_Construct_UScriptStruct_FSQLiteQueryFinalizedQuery_Statics' unexpected 39
'FString Query': redefinition 42
'void __cdecl `dynamic initializer for 'Query''(void)': constructor initializer lists are only allowed on constructor definitions 42
missing type specifier - int assumed. Note: C++ does not support default-int 44
'FSQLiteQueryFinalizedQuery': redefinition; previous definition was 'data variable' 44
missing type specifier - int assumed. Note: C++ does not support default-int 45
'FSQLiteQueryFinalizedQuery': redefinition; previous definition was 'data variable' 45
'FSQLiteQueryFinalizedQuery': constructor initializer lists are only allowed on constructor definitions 45
syntax error: '}' 46
syntax error: missing ';' before '}' 46
Cannot open include file: 'SQLiteDatabaseStructs.generated.h': No such file or directory 2
对于我绝对路径生成的每个文件,我都会得到所有这些相同的错误,以及一个附加的生成文件错误,直到返回到SQLiteDatabase.h。当我绝对路径生成的文件时,这是我得到的新错误:
在标题顶部包含一个期望的内容:'#include“ SQLiteDatabase.genic.h”'
为简便起见,下面将包括上面提到的所有文件及其生成的文件(如果它们引发错误):
SQLiteBlueprintNotes.h:
#pragma once
#include "F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Intermediate/Build/Win64/UE4Editor/Inc/CISQLite3/SQLiteBlueprintNodes.generated.h"
USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteQueryLogicExpectedNode
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Database Query")
FString Query;
FSQLiteQueryLogicExpectedNode(){}
FSQLiteQueryLogicExpectedNode(FString LHSQuery, FString Append) : Query(LHSQuery)
{
Query += Append;
}
};
USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteQueryTermExpectedNode
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Database Query")
FString Query;
FSQLiteQueryTermExpectedNode(){}
FSQLiteQueryTermExpectedNode(FString LHSQuery, FString Append) : Query(LHSQuery)
{
Query += Append;
}
};
USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteQueryFinalizedQuery
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Database Query")
FString Query;
FSQLiteQueryFinalizedQuery(){}
FSQLiteQueryFinalizedQuery(FString Query) : Query(Query){}
};
SQLiteBlueprintNodes.genic.h:
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
/*===========================================================================
Generated code exported from UnrealHeaderTool.
DO NOT modify this manually! Edit the corresponding .h files instead!
===========================================================================*/
#include "UObject/ObjectMacros.h"
#include "UObject/ScriptMacros.h"
PRAGMA_DISABLE_DEPRECATION_WARNINGS
#ifdef CISQLITE3_SQLiteBlueprintNodes_generated_h
#error "SQLiteBlueprintNodes.generated.h already included, missing '#pragma once' in SQLiteBlueprintNodes.h"
#endif
#define CISQLITE3_SQLiteBlueprintNodes_generated_h
#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteBlueprintNodes_h_39_GENERATED_BODY \
friend struct Z_Construct_UScriptStruct_FSQLiteQueryFinalizedQuery_Statics; \
static class UScriptStruct* StaticStruct();
#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteBlueprintNodes_h_24_GENERATED_BODY \
friend struct Z_Construct_UScriptStruct_FSQLiteQueryTermExpectedNode_Statics; \
static class UScriptStruct* StaticStruct();
#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteBlueprintNodes_h_9_GENERATED_BODY \
friend struct Z_Construct_UScriptStruct_FSQLiteQueryLogicExpectedNode_Statics; \
static class UScriptStruct* StaticStruct();
#undef CURRENT_FILE_ID
#define CURRENT_FILE_ID MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteBlueprintNodes_h
PRAGMA_ENABLE_DEPRECATION_WARNINGS
SQLiteDatabaseStructs.h:
#pragma once
#include "F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Intermediate/Build/Win64/UE4Editor/Inc/CISQLite3/SQLiteDatabaseStructs.generated.h"
USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteIndex
{
GENERATED_USTRUCT_BODY()
/** String with piece if SQL script*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Index")
FString ResultStr = "";
/** Index name*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Index")
FString IndexName = "";
};
USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLitePrimaryKey
{
GENERATED_USTRUCT_BODY()
/** String with piece if SQL script*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Primary Key")
FString ResultStr = "";
};
USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteTableField
{
GENERATED_USTRUCT_BODY()
/** String with piece if SQL script*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table Field")
FString ResultStr = "";
/** Field name*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table Field")
FString FieldName = "";
/** Field type*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table Field")
FString FieldType = "";
/** Field value*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table Field")
FString FieldValue = "";
};
USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteTableRowSimulator
{
GENERATED_USTRUCT_BODY()
/** Index name*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Index")
TArray<FSQLiteTableField> rowsOfFields;
};
USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteTable
{
GENERATED_USTRUCT_BODY()
/** Database name*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table")
FString DatabaseName = "";
/** Table name*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table")
FString TableName = "";
/** Array with Fields*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table")
TArray<FSQLiteTableField> Fields;
/** Primary Key */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table")
FSQLitePrimaryKey PK;
/** Created Key */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table")
bool Created = false;
};
SQLiteDatabaseStructs.genic.h:
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
/*===========================================================================
Generated code exported from UnrealHeaderTool.
DO NOT modify this manually! Edit the corresponding .h files instead!
===========================================================================*/
#include "UObject/ObjectMacros.h"
#include "UObject/ScriptMacros.h"
PRAGMA_DISABLE_DEPRECATION_WARNINGS
#ifdef CISQLITE3_SQLiteDatabaseStructs_generated_h
#error "SQLiteDatabaseStructs.generated.h already included, missing '#pragma once' in SQLiteDatabaseStructs.h"
#endif
#define CISQLITE3_SQLiteDatabaseStructs_generated_h
#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteDatabaseStructs_h_66_GENERATED_BODY \
friend struct Z_Construct_UScriptStruct_FSQLiteTable_Statics; \
static class UScriptStruct* StaticStruct();
#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteDatabaseStructs_h_55_GENERATED_BODY \
friend struct Z_Construct_UScriptStruct_FSQLiteTableRowSimulator_Statics; \
static class UScriptStruct* StaticStruct();
#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteDatabaseStructs_h_32_GENERATED_BODY \
friend struct Z_Construct_UScriptStruct_FSQLiteTableField_Statics; \
static class UScriptStruct* StaticStruct();
#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteDatabaseStructs_h_22_GENERATED_BODY \
friend struct Z_Construct_UScriptStruct_FSQLitePrimaryKey_Statics; \
static class UScriptStruct* StaticStruct();
#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteDatabaseStructs_h_7_GENERATED_BODY \
friend struct Z_Construct_UScriptStruct_FSQLiteIndex_Statics; \
static class UScriptStruct* StaticStruct();
#undef CURRENT_FILE_ID
#define CURRENT_FILE_ID MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteDatabaseStructs_h
PRAGMA_ENABLE_DEPRECATION_WARNINGS
SQLiteDatabase.h:
#pragma once
#include "sqlite3.h"
#include "SQLiteBlueprintNodes.h"
#include "SQLiteDatabaseStructs.h"
#include "F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Intermediate/Build/Win64/UE4Editor/Inc/CISQLite3/SQLiteDatabase.generated.h"
USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteDatabaseReference
{
GENERATED_USTRUCT_BODY()
/** The database name (not the filename) */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Database Reference")
FString DatabaseName;
/** The database tables we want to get data from */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Database Reference")
TArray<FString> Tables;
};
USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteKeyValuePair
{
GENERATED_USTRUCT_BODY()
/** The database table field name */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Key Value Pair")
FString Key;
/** The value of the field */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Key Value Pair")
FString Value;
};
USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteQueryResultRow
{
GENERATED_USTRUCT_BODY()
/** A list of field name, field value pairs */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Query Result")
TArray<FSQLiteKeyValuePair> Fields;
};
USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteQueryResult
{
GENERATED_USTRUCT_BODY()
/** The resulting rows from the query */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Query Result")
TArray<FSQLiteQueryResultRow> ResultRows;
/** Was the query successful or not */
UPROPERTY(BlueprintReadOnly, Category = "SQLite Query Result")
bool Success;
/** If the query was unsuccessful a human readable error message will be populated here */
UPROPERTY(BlueprintReadOnly, Category = "SQLite Query Result")
FString ErrorMessage;
};
// A few things for internal use here.
namespace SQLiteResultValueTypes
{
enum SQLiteResultValType
{
Integer,
Float,
Text,
UnsupportedValueType
};
}
// Result field, used as an intermediary when collecting results from
// an SQLITE3 query.
struct SQLiteResultField
{
FString StringValue;
double DoubleValue;
int64 IntValue;
FString Name;
SQLiteResultValueTypes::SQLiteResultValType Type;
FString ToString()
{
if (Type == SQLiteResultValueTypes::Text)
return StringValue;
else if (Type == SQLiteResultValueTypes::Integer)
return FString::Printf(TEXT("%i"), IntValue);
else if (Type == SQLiteResultValueTypes::Float)
return FString::Printf(TEXT("%f"), DoubleValue);
return StringValue;
}
};
// Represents a single row in the result.
struct SQLiteResultValue
{
TArray<SQLiteResultField> Fields;
};
// The internal result object.
struct SQLiteQueryResult
{
bool Success;
FString ErrorMessage;
TArray<SQLiteResultValue> Results;
};
/**
* SQLite main database class.
*/
UCLASS()
class CISQLITE3_API USQLiteDatabase : public UObject
{
GENERATED_UCLASS_BODY()
public:
/** Create a sqlite database file if it doesn't exist already. Does nothing if already exists.
* Returns false if the file couldn't be created */
UFUNCTION(BlueprintCallable, Category = "SQLite")
static bool CreateDatabase(const FString& Filename, bool RelativeToGameContentDirectory);
/** Checks if the database is registered, ie. that it can be found in Databases. */
/** Add a database to the list of databases. It will be checked that it's valid (will try to open it) */
UFUNCTION(BlueprintCallable, Category = "SQLite")
static bool RegisterDatabase(const FString& Name, const FString& Filename, bool RelativeToGameContentDirectory, bool KeepOpen=false);
/** Remove a database from the list of databases. Closes the database in case KeepOpen flag was set during @ref RegisterDatabase */
UFUNCTION(BlueprintCallable, Category = "SQLite")
static void UnregisterDatabase(const FString& Name);
/** Checks if the database is registered, ie. that it can be found in Databases. */
UFUNCTION(BlueprintCallable, Category = "SQLite")
static bool IsDatabaseRegistered(const FString& DatabaseName);
/** Get data from the database using a select statement straight into an UObject, ie. populates its properties. */
UFUNCTION(BlueprintCallable, Category = "SQLite", meta = (DisplayName = "Get Data Into Object (manual query)"))
static bool GetDataIntoObject(const FString& DatabaseName, const FString& Query, UObject* ObjectToPopulate);
/** Blueprint: Gets data from the database using a select statement straight into an UObject, ie. populates its properties.
* Note: Does not create a new object. ObjectToPopulate is the reference to the object you want to populate. */
UFUNCTION(BlueprintCallable, Category = "SQLite", meta = (DisplayName = "Get Data Into Object"))
static bool GetDataIntoObjectBP(const FSQLiteDatabaseReference& DataSource, TArray<FString> Fields, FSQLiteQueryFinalizedQuery Query, UObject* ObjectToPopulate);
/** Get data from the database using a select statement and return the rows. */
UFUNCTION(BlueprintCallable, Category = "SQLite", meta = (DisplayName = "Get Data From Table(s) (manual query)"))
static FSQLiteQueryResult GetData(const FString& DatabaseName, const FString& Query);
/** Blueprint: Get data from the database. Returns the resulting rows. */
UFUNCTION(BlueprintCallable, Category = "SQLite", meta = (DisplayName = "Get Data From Table(s)"))
static FSQLiteQueryResult GetDataBP(const FSQLiteDatabaseReference& DataSource, TArray<FString> Fields, FSQLiteQueryFinalizedQuery Query, int32 MaxResults = -1, int32 ResultOffset = 0);
/** Create table in the database. */
UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Create Table"))
static FSQLiteTable CreateTable(const FString& DatabaseName, const FString& TableName,
const TArray<FSQLiteTableField> Fields, const FSQLitePrimaryKey PK);
/** Create indexes for table */
UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Create Indexes"))
static bool CreateIndexes(const FString& DatabaseName, const FString& TableName, const TArray<FSQLiteIndex> Indexes);
/** Create index for table */
UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Create Index"))
static bool CreateIndex(const FString& DatabaseName, const FString& TableName, const FSQLiteIndex Index);
/** Drop index*/
UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Drop Index"))
static bool DropIndex(const FString& DatabaseName, const FString& IndexName);
/** Drop Table*/
UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Drop Table"))
static bool DropTable(const FString& DatabaseName, const FString& TableName);
/** Truncate Table*/
UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Truncate Table"))
static bool TruncateTable(const FString& DatabaseName, const FString& TableName);
/** Is table exists?*/
UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Is table exists?"))
static bool IsTableExists(const FString& DatabaseName, const FString& TableName);
/** Insert rows into table */
UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Insert Rows Into Table"))
static void InsertRowsIntoTable(const FString& DatabaseName, const FString& TableName, TArray<FSQLiteTableRowSimulator> rowsOfFields);
/** Compact database*/
UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Compact database"))
static bool Vacuum(const FString& DatabaseName);
/** Execute SQL (can be used for insert statement)*/
UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Execute SQL"))
static bool ExecSql(const FString& DatabaseName, const FString& Query);
/** Checks database validity (if the file exists and/or if it can be opened). */
UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Is Valid Database"))
static bool IsValidDatabase(const FString& DatabaseFilename, bool TestByOpening);
/** Runs a query and returns fetched rows. */
static TUniquePtr<SQLiteQueryResult> RunQueryAndGetResults(const FString& DatabaseName, const FString& Query);
private:
/** 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<FString, UProperty*> CollectProperties(UObject* SourceObject);
/** Constructs an SQL query from the blueprint fed data. */
static FString ConstructQuery(TArray<FString> Tables, TArray<FString> 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. */
static void AssignResultsToObjectProperties(const SQLiteResultValue& ResultValue, UObject* ObjectToPopulate);
/** @brief Prepare given statement, returns whether to keep the database open */
static bool PrepareStatement(const FString& DatabaseName, const FString& Query, sqlite3** Db, int32** SqlReturnCode,
sqlite3_stmt** PreparedStatement);
private:
/** A list of the databases for convenience, easier to refer to them by name rather than a long filename. */
static TMap<FString, FString> Databases;
static TMap<FString, sqlite3*> SQLite3Databases;
};
用于SQLiteDatabase.genic.h的Pastbin,因为它太长了,无法包含在问题正文中:
目前我真的没有主意,即使使用此插件也无法在网上找到任何东西。不知道是否有人在使用较新版本的引擎。我本人以及计算机旁边的墙将对您的帮助深表感谢。
答案 0 :(得分:0)
因此,我已经设法仅通过将合并直接用于新项目的源文件夹中来解决此问题,但我认为,如果可以解决的话,UE4社区将从整体上受益。尽管有一些不错的SQLite3集成插件,但它们的成本很高,如果您不需要花哨的钱,它们的成本效益就不高。