Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
ConfigContext.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
6#include "Containers/Map.h"
7#include "Containers/Set.h"
8#include "Containers/SparseArray.h"
9#include "Containers/UnrealString.h"
10#include "CoreGlobals.h"
11#include "CoreTypes.h"
12#include "Misc/ConfigTypes.h"
13
14
15#ifndef CUSTOM_CONFIG
16#define CUSTOM_CONFIG ""
17#endif
18
19#ifndef DISABLE_GENERATED_INI_WHEN_COOKED
20#define DISABLE_GENERATED_INI_WHEN_COOKED 0
21#endif
22
23
24
25
26class FConfigCacheIni;
27class FConfigFile;
28
30{
31public:
32
33 /**
34 * Create a context to read a hierarchical config into the given local FConfigFile, optionally for another platform
35 *
36 */
37 static FConfigContext ReadIntoLocalFile(FConfigFile& DestConfigFile, const FString& Platform=FString())
38 {
39 return FConfigContext(nullptr, true, Platform, &DestConfigFile);
40 }
41
42 /**
43 * Create a context to read a non-hierarchical config into the given local FConfigFile, optionally for another platform
44 */
45 static FConfigContext ReadSingleIntoLocalFile(FConfigFile& DestConfigFile, const FString& Platform=FString())
46 {
47 return FConfigContext(nullptr, false, Platform, &DestConfigFile);
48 }
49
50 /**
51 * Create a context to read a hierarchical config into GConfig. Only for current platform.
52 */
54 {
56 }
57
58 /**
59 * Create a context to read a hierarchical config into GConfig. Only for current platform.
60 */
62 {
64 Context.bForceReload = true;
65 return Context;
66 }
67
68 /**
69 * Create a context to read a non-hierarchical config into GConfig. Only for current platform.
70 */
72 {
74 }
75
76 /**
77 * Create a context to read a hierarchical config into the given ConfigSystem structure - usually will be for other platforms
78 */
79 static FConfigContext ReadIntoConfigSystem(FConfigCacheIni* ConfigSystem, const FString& Platform)
80 {
81 return FConfigContext(ConfigSystem, true, Platform);
82 }
83
84 /**
85 * Create a context to read a non-hierarchical config into the given ConfigSystem structure - usually will be for other platforms
86 */
88 {
89 return FConfigContext(GConfig, false, Platform);
90 }
91
92 /**
93 * Create a context to read a plugin's ini file named for the plugin. This is not used for inserting, say, Engine.ini into GConfig
94 */
95 static FConfigContext ReadIntoPluginFile(FConfigFile& DestConfigFile, const FString& PluginRootDir)
96 {
97 FConfigContext Context(nullptr, true, FString(), &DestConfigFile);
98 Context.bIsForPlugin = true;
99 Context.PluginRootDir = PluginRootDir;
100
101 // plugins are read in parallel, so we are reading into a file, but not touching GConfig, so bWriteDest would be false, but we
102 // want to write them out as if we had been using GConfig
103 // @todo: honestly, that's just to keep same behavior, but i am not sure it is correct behavior! actually why would reading in ever need to write out?
104 Context.bWriteDestIni = true;
105
106 return Context;
107 }
108
109 /**
110 * Create a context to read a hierarchy, but once it reaches the given filename (StartDeletingFilename), it will not read in anymore
111 * files at that point
112 */
113 static FConfigContext ReadUpToBeforeFile(FConfigFile& DestConfigFile, const FString& Platform, const FString& StartSkippingAtFilename)
114 {
115 FConfigContext Context(nullptr, true, Platform, &DestConfigFile);
116 Context.StartSkippingAtFilename = StartSkippingAtFilename;
117 return Context;
118 }
119
120 /**
121 * Call to make before attempting parallel config init
122 */
124
125 /**
126 * Use the context to perform the actual load operation. Note that this is where you specify the Ini name (for instance "Engine"), meaning
127 * you can use the same context for multiple configs (Engine, Game, Input, etc)
128 */
129 bool Load(const TCHAR* IniName);
130
131 /**
132 * Use the context to perform the actual load operation as above, but will return the generated final ini filename (in the case of GConfig, this would
133 * be the key used to look up into GConfig, for example)
134 */
135 bool Load(const TCHAR* IniName, FString& OutFilename);
136
137
138 // because the hierarchy can jump between platforms, we cache off some directories per chained-platform
140 {
143 };
144 /**
145 * Return the paths to use to find hierarchical config files for the given platform (note that these are independent of the ini name)
146 */
147 const FPerPlatformDirs& GetPerPlatformDirs(const FString& PlatformName);
148
149
150 // @todo make these private and friend the FCOnfigCacheIni and FConfigFile once everything is a member function!!!!
152
160
166
167 // useful strings that are used alot when walking the hierarchy
171
172 bool bUseHierarchyCache = false;
174 bool bForceReload = false;
175 bool bAllowRemoteConfig = false;
177 bool bWriteDestIni = false;
179 bool bIsForPlugin = false;
180
181 // if this is non-null, it contains a set of pre-scanned ini files to use to find files, instead of looking on disk
182 const TSet<FString>* IniCacheSet = nullptr;
183
184protected:
185
187 bool bCacheOnNextLoad = true;
188
189 FConfigContext(FConfigCacheIni* InConfigSystem, bool InIsHierarchicalConfig, const FString& InPlatform, FConfigFile* DestConfigFile=nullptr);
190
191 FConfigContext& ResetBaseIni(const TCHAR* InBaseIniName);
193
194 bool PrepareForLoad(bool& bPerformLoad);
196
199 FString PerformFinalExpansions(const FString& InString, const FString& Platform);
200};
201
202bool DoesConfigFileExistWrapper(const TCHAR* IniFile, const TSet<FString>* IniCacheSet = nullptr);
bool DoesConfigFileExistWrapper(const TCHAR *IniFile, const TSet< FString > *IniCacheSet=nullptr)
FConfigCacheIni * GConfig
FString EngineRootDir
TMap< FString, FPerPlatformDirs > PerPlatformDirs
bool Load(const TCHAR *IniName)
FString StartSkippingAtFilename
FString ProjectNotForLicenseesDir
bool bDefaultEngineRequired
static void EnsureRequiredGlobalPathsHaveBeenInitialized()
bool PerformLoad()
FString DestIniFilename
static FConfigContext ReadSingleIntoConfigSystem(FConfigCacheIni *ConfigSystem, const FString &Platform)
FString GeneratedConfigDir
static FConfigContext ForceReloadIntoGConfig()
static FConfigContext ReadSingleIntoGConfig()
FString ProjectNoRedistDir
static FConfigContext ReadIntoLocalFile(FConfigFile &DestConfigFile, const FString &Platform=FString())
void AddStaticLayersToHierarchy()
FString PluginRootDir
static FConfigContext ReadUpToBeforeFile(FConfigFile &DestConfigFile, const FString &Platform, const FString &StartSkippingAtFilename)
FConfigFile * ConfigFile
FConfigCacheIni * ConfigSystem
FString ProjectConfigDir
const FPerPlatformDirs & GetPerPlatformDirs(const FString &PlatformName)
bool PrepareForLoad(bool &bPerformLoad)
FConfigContext(FConfigCacheIni *InConfigSystem, bool InIsHierarchicalConfig, const FString &InPlatform, FConfigFile *DestConfigFile=nullptr)
FString PerformFinalExpansions(const FString &InString, const FString &Platform)
FString ProjectRootDir
FString EngineConfigDir
static FConfigContext ReadSingleIntoLocalFile(FConfigFile &DestConfigFile, const FString &Platform=FString())
static FConfigContext ReadIntoGConfig()
bool GenerateDestIniFile()
FConfigContext & ResetBaseIni(const TCHAR *InBaseIniName)
bool bAllowGeneratedIniWhenCooked
static FConfigContext ReadIntoConfigSystem(FConfigCacheIni *ConfigSystem, const FString &Platform)
static FConfigContext ReadIntoPluginFile(FConfigFile &DestConfigFile, const FString &PluginRootDir)
bool Load(const TCHAR *IniName, FString &OutFilename)
const TSet< FString > * IniCacheSet
FString()=default