Unreal Engine 4.21.2 и проблемы компиляции плагина Squareys CISQLite3 - PullRequest
0 голосов
/ 27 марта 2019

Я пытаюсь интегрировать SQLite3 в свой тестовый проект в UE4, но сталкиваюсь с некоторыми, без особых проблем.

Сначала немного по хозяйству. Ссылка на репозиторий на GitHub, где Square имеет плагин, который является раздвоенной и обновленной версией старого плагина CISQLite3:

https://github.com/Squareys/unreal-sqlite3

Далее, проект, который я использую, является проектом Blueprint с пользовательскими классами, созданными в редакторе.

Шаги установки: Я следовал руководству по установке в readme на репозитории, в котором говорится следующее:

Загрузите zip-файл плагина и распакуйте его в папку Plugins вашего проекта. Откройте редактор и перейдите в Менеджер плагинов и включите плагин. Перезапустите и дайте редактору скомпилировать плагин.

В 4.20.x это было, очевидно, все, что было нужно. По какой-либо причине в 4.21.2 этот процесс нарушен. Я получаю все виды проблем, связанных с созданными файлами.

Итак, что я попробовал: Я попытался указать абсолютный путь для сгенерированных файлов в промежуточной папке плагина - это просто позволяет компилятору выводить ошибки, как «Старый верный из ада».

Я попытался начать новый проект; три раза. Я всегда сталкиваюсь с тем, что не могу идти дальше из-за ошибки, которую я опишу позже в этом посте.

Я попытался восстановить файлы проекта после удаления .vs, двоичных файлов, промежуточных и сохраненных папок. Иногда перестройка работает для воссоздания файлов (не решает проблемы), но в какой-то момент она начинает давать сбой, и когда я открываю проект, он не может скомпилировать проект dll / lib и говорит, что компилирует вручную.

Ладно, так до фактических ошибок. Я проведу вас шаг за шагом и покажу ошибки на каждом шаге отладки, который я делаю.

Итак, во-первых, даже в новом проекте без пользовательского кода я получаю два предупреждения:

MiningTechDemo5 \ Plugins \ CISQLite3 \ Source \ CISQLite3 \ CISQLite3.Build.cs: предупреждение: модули должны указывать явный предварительно скомпилированный заголовок (например, PrivatePCHHeaderFile = "Private / CISQLite3PrivatePCH.h") из UE 4.21 и далее.

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: \, а не на папку проекта / плагина. Итак, эти ошибки исчезли. Все выглядит хорошо, пока я не включу SQLiteDatabase.h в свой пользовательский класс DatabaseHandler (созданный в редакторе).

Первая ошибка, которую я получаю, - это то, что DatabaseHandler.generated.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 также не работает; по крайней мере, не со строковыми свойствами, которые возвращают части пути в качестве вспомогательных элементов, поэтому меньше набираемого текста.

Так что я перестраиваю, та же ошибка. Я иду дальше и изменяю включение на абсолютный путь из этого:

включает "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.generated.h"

Именно в этот момент компилятор берет сгенерированный файл и удаляет его с кучей несоответствий компилятора и ошибка нового сгенерированного файла для SQLiteDatabaseStructs.generated.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.generated.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.generated.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.generated.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;

};

PasteBin для SQLiteDatabase.generated.h, поскольку его было слишком долго включать в тело вопроса:

https://pastebin.com/ZFsg9KEv

У меня действительно нет идей на данный момент, и я не могу найти в Интернете ничего похожего на этот плагин. Не уверен, что кто-то использовал его с более свежими версиями двигателя. Я буду очень признателен за любую помощь и стену рядом с моим компьютером.

1 Ответ

0 голосов
/ 27 марта 2019

Итак, мне удалось решить эту проблему, просто используя объединение непосредственно в исходной папке нового проекта, но я думаю, что сообщество UE4 выиграет в целом, если это можно будет выяснить. Хотя есть несколько хороших плагинов для интеграции с SQLite3, они стоят дорого, и если вам не нужны навороты, они не являются экономически эффективными.

...