Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
ConfigCacheIni.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*-----------------------------------------------------------------------------
4 Config cache.
5-----------------------------------------------------------------------------*/
6
7#pragma once
8
9#include "Algo/Reverse.h"
10#include "Containers/Array.h"
11#include "Containers/Map.h"
12#include "Containers/Set.h"
13#include "Containers/SparseArray.h"
14#include "Containers/StringFwd.h"
15#include "Containers/UnrealString.h"
16#include "CoreGlobals.h"
17#include "CoreTypes.h"
18#include "Delegates/Delegate.h"
19#include "HAL/PlatformCrt.h"
20#include "Internationalization/Text.h"
21#include "Internationalization/TextLocalizationResource.h"
22#include "Logging/LogMacros.h"
23#include "Math/Color.h"
24#include "Math/MathFwd.h"
25#include "Math/Rotator.h"
26#include "Math/Vector.h"
27#include "Math/Vector2D.h"
28#include "Math/Vector4.h"
29#include "Misc/AccessDetection.h"
30#include "Misc/Build.h"
31#include "Misc/ConfigTypes.h"
32#include "Misc/Paths.h"
33#include "Serialization/Archive.h"
34#include "Serialization/StructuredArchive.h"
35#include "Serialization/StructuredArchiveAdapters.h"
36#include "Serialization/StructuredArchiveSlots.h"
37#include "Templates/ChooseClass.h"
38#include "Templates/Function.h"
39#include "Templates/UnrealTemplate.h"
40#include "UObject/NameTypes.h"
41
42class FConfigCacheIni;
43class FConfigFile;
44class FOutputDevice;
46struct FColor;
47
49
50// Server builds should be tweakable even in Shipping
51#define ALLOW_INI_OVERRIDE_FROM_COMMANDLINE (UE_SERVER || !(UE_BUILD_SHIPPING))
52#define CONFIG_REMEMBER_ACCESS_PATTERN (WITH_EDITOR || 0)
53
54
55///////////////////////////////////////////////////////////////////////////////
56//
57// This is the master list of known ini files that are used and processed
58// on all platforms (specifically for runtime/binary speedups. Other, editor-
59// specific inis, or non-hierarchical ini files will still work with the
60// old system, but they won't have any optimizations applied
61//
62// These should be listed in the order of highest to lowest use, for optimization
63//
64///////////////////////////////////////////////////////////////////////////////
65
66#define ENUMERATE_KNOWN_INI_FILES(op)
67 op(Engine)
68 op(Game)
69 op(Input)
70 op(DeviceProfiles)
71 op(GameUserSettings)
72 op(Scalability)
73 op(RuntimeOptions)
74 op(InstallBundle)
75 op(Hardware)
76 op(GameplayTags)
77
78
79#define KNOWN_INI_ENUM(IniName) IniName,
80enum class EKnownIniFile : uint8
81{
82 // make an enum entry for each known ini above
84
85 // conventient counter for the above list
87};
88
89namespace UE
90{
92{
93namespace Private
94{
95struct FAccessor;
96}
97}
98}
99
100class FConfigContext;
101
103{
104public:
106
107 FConfigValue(const TCHAR* InValue)
110 , bRead(false)
111#endif
112 {
113 SavedValueHash = FTextLocalizationResource::HashString(SavedValue);
115 }
116
117 FConfigValue(const FString& InValue)
120 , bRead(false)
121#endif
122 {
123 SavedValueHash = FTextLocalizationResource::HashString(SavedValue);
125 }
126
130 , bRead(false)
131#endif
132 {
133 SavedValueHash = FTextLocalizationResource::HashString(SavedValue);
135 }
136
137 FConfigValue(const FConfigValue& InConfigValue)
140 , SavedValueHash(InConfigValue.SavedValueHash)
143#endif
144 {
145 // shouldn't need to expand value it's assumed that the other FConfigValue has done this already
146 }
147
148 FConfigValue(FConfigValue&& InConfigValue)
151 , SavedValueHash(InConfigValue.SavedValueHash)
154#endif
155 {
156 // shouldn't need to expand value it's assumed that the other FConfigValue has done this already
157 }
158
160 {
161 SavedValue = MoveTemp(RHS.SavedValue);
162 ExpandedValue = MoveTemp(RHS.ExpandedValue);
165 bRead = RHS.bRead;
166#endif
167
168 return *this;
169 }
170
172 {
173 SavedValue = RHS.SavedValue;
174 ExpandedValue = RHS.ExpandedValue;
177 bRead = RHS.bRead;
178#endif
179
180 return *this;
181 }
182
183 // Returns the ini setting with any macros expanded out
184 const FString& GetValue() const
185 {
186 UE::AccessDetection::ReportAccess(UE::AccessDetection::EType::Ini);
188 bRead = true;
189#endif
190 return (ExpandedValue.Len() > 0 ? ExpandedValue : SavedValue);
191 }
192
193 // Returns the original ini setting without macro expansion
194 const FString& GetSavedValue() const
195 {
196 UE::AccessDetection::ReportAccess(UE::AccessDetection::EType::Ini);
198 bRead = true;
199#endif
200 return SavedValue;
201 }
203 inline const bool HasBeenRead() const
204 {
205 return bRead;
206 }
207 inline void SetHasBeenRead(bool InBRead ) const
208 {
209 bRead = InBRead;
210 }
211#endif
212
213 bool operator==(const FConfigValue& Other) const { return SavedValueHash == Other.SavedValueHash; }
214 bool operator!=(const FConfigValue& Other) const { return !(FConfigValue::operator==(Other)); }
215
216 friend FArchive& operator<<(FArchive& Ar, FConfigValue& ConfigSection)
217 {
219 return Ar;
220 }
221
222 friend void operator<<(FStructuredArchive::FSlot Slot, FConfigValue& ConfigSection)
223 {
224 Slot << ConfigSection.SavedValue;
225
227 {
228 ConfigSection.ExpandValueInternal();
230 ConfigSection.bRead = false;
231#endif
232 }
233 }
234
235 /**
236 * Given a collapsed config value, try and produce an expanded version of it (removing any placeholder tokens).
237 *
238 * @param InCollapsedValue The collapsed config value to try and expand.
239 * @param OutExpandedValue String to fill with the expanded version of the config value.
240 *
241 * @return true if expansion occurred, false if the collapsed and expanded values are equal.
242 */
243 static bool ExpandValue(const FString& InCollapsedValue, FString& OutExpandedValue);
244
245 /**
246 * Given a collapsed config value, try and produce an expanded version of it (removing any placeholder tokens).
247 *
248 * @param InCollapsedValue The collapsed config value to try and expand.
249 *
250 * @return The expanded version of the config value.
251 */
252 static FString ExpandValue(const FString& InCollapsedValue);
253
254 /**
255 * Given an expanded config value, try and produce a collapsed version of it (adding any placeholder tokens).
256 *
257 * @param InExpandedValue The expanded config value to try and expand.
258 * @param OutCollapsedValue String to fill with the collapsed version of the config value.
259 *
260 * @return true if collapsing occurred, false if the collapsed and expanded values are equal.
261 */
262 static bool CollapseValue(const FString& InExpandedValue, FString& OutCollapsedValue);
263
264 /**
265 * Given an expanded config value, try and produce a collapsed version of it (adding any placeholder tokens).
266 *
267 * @param InExpandedValue The expanded config value to try and expand.
268 *
269 * @return The collapsed version of the config value.
270 */
271 static FString CollapseValue(const FString& InExpandedValue);
272
273private:
274 /** Internal version of ExpandValue that expands SavedValue into ExpandedValue, or produces an empty ExpandedValue if no expansion occurred. */
276
277 /** Gets the SavedValue without marking it as having been accessed for e.g. writing out to a ConfigFile to disk */
280 {
281 return SavedValue;
282 };
283
288 mutable bool bRead; // has this value been read since the config system started
289#endif
290};
291
292namespace UE
293{
294namespace ConfigCacheIni
295{
296namespace Private
297{
298/** An accessor class to access functions that should be restricted only to FConfigFileCache Internal use */
300{
301private:
302 friend class ::FConfigCacheIni;
303 friend class ::FConfigFile;
304
305 static const FString& GetSavedValueForWriting(const FConfigValue& ConfigValue)
306 {
307 return ConfigValue.GetSavedValueForWriting();
308 }
309};
310}
311}
312}
313
315
316// One section in a config file.
318{
319public:
320 /**
321 * Check whether the input string is surrounded by quotes
322 *
323 * @param Test The string to check
324 *
325 * @return true if the input string is surrounded by quotes
326 */
327 static bool HasQuotes( const FString& Test );
328 bool operator==( const FConfigSection& Other ) const;
329 bool operator!=( const FConfigSection& Other ) const;
330
331 // process the '+' and '.' commands, takingf into account ArrayOfStruct unique keys
332 void HandleAddCommand(FName Key, FString&& Value, bool bAppendValueIfNotArrayOfStructsKeyUsed);
333
335
336 template<typename Allocator>
337 void MultiFind(const FName Key, TArray<FConfigValue, Allocator>& OutValues, const bool bMaintainOrder = false) const
338 {
340 }
341
342 template<typename Allocator>
343 void MultiFind(const FName Key, TArray<FString, Allocator>& OutValues, const bool bMaintainOrder = false) const
344 {
345 for (typename ElementSetType::TConstKeyIterator It(Pairs, Key); It; ++It)
346 {
348 }
349
350 if (bMaintainOrder)
351 {
353 }
354 }
355
356 // look for "array of struct" keys for overwriting single entries of an array
358
359 friend FArchive& operator<<(FArchive& Ar, FConfigSection& ConfigSection);
360};
361
362
364// Options which stemmed from the commandline
365struct FConfigCommandlineOverride
366{
367 FString BaseFileName, Section, PropertyKey, PropertyValue;
368};
369#endif // ALLOW_INI_OVERRIDE_FROM_COMMANDLINE
370
371
372// One config file.
373
375{
376public:
377 bool Dirty;
378 bool NoSave;
379 bool bHasPlatformName = false;
380
381 /** The name of this config file */
383
384 // The collection of source files which were used to generate this file.
386
387 // Locations where this file may have come from - used to merge with non-standard ini locations
390
391 /** The untainted config file which contains the coalesced base/default options. I.e. No Saved/ options*/
393
395
397 /** The collection of overrides which stemmed from the commandline */
399#endif // ALLOW_INI_OVERRIDE_FROM_COMMANDLINE
400
402 FConfigFile( int32 ) {} // @todo UE-DLL: Workaround for instantiated TMap template during DLLExport (TMap::FindRef)
404
405 // looks for a section by name, and creates an empty one if it can't be found
407
408 bool operator==( const FConfigFile& Other ) const;
409 bool operator!=( const FConfigFile& Other ) const;
410
411 bool Combine( const FString& Filename);
412 void CombineFromBuffer(const FString& Buffer, const FString& FileHint);
413 UE_DEPRECATED(5.1, "Use CombineFromBuffer that takes FileHint")
414 void CombineFromBuffer(const FString& Buffer)
415 {
416 CombineFromBuffer(Buffer, TEXT("Unknown file, using deprecated function"));
417 }
418 void Read( const FString& Filename );
419
420 /** Whether to write a temp file then move it to it's destination when saving. */
422
423 /** Write this ConfigFile to the given Filename, constructed the text from the config sections in *this, prepended by the optional PrefixText */
424 bool Write( const FString& Filename, bool bDoRemoteWrite=true, const FString& PrefixText=FString());
425
426 /** Write this ConfigFile to the given string, constructed the text from the config sections in *this, prepended by the optional PrefixText
427 * @param SimulatedFilename - If writing a default hierarchal ini, can be used to correctly deduce position in the hierarchy
428 */
429 void WriteToString(FString& InOutText, const FString& SimulatedFilename = FString(), const FString& PrefixText = FString());
430
431private:
432 /** Determine if writing a default hierarchal ini, and deduce position in the hierarchy */
433 bool IsADefaultIniWrite(const FString& Filename, int32& OutIniCombineThreshold) const;
434
435 /** Write a ConfigFile to the given Filename, constructed from the given SectionTexts, in the given order, with sections in *this overriding sections in SectionTexts
436 * @param Filename - The file to write to
437 * @param bDoRemoteWrite - If true, also write the file to FRemoteConfig::Get()
438 * @param InOutSectionTexts - A map from section name to existing text for that section; text does not include the name of the section.
439 * Entries in the TMap that also exist in *this will be updated.
440 * If the empty string is present, it will be written out first (it is interpreted as a prefix before the first section)
441 * @param InSectionOrder - List of section names in the order in which each section should be written to disk, from e.g. the existing file.
442 * Any section in this array that is not found in InOutSectionTexts will be ignored.
443 * Any section in InOutSectionTexts that is not in this array will be appended to the end.
444 * Duplicate entries are ignored; the first found index is used.
445 * @return TRUE if the write was successful
446 */
447 bool WriteInternal(const FString& Filename, bool bDoRemoteWrite, TMap<FString, FString>& InOutSectionTexts, const TArray<FString>& InSectionOrder);
448
449 /** Write a ConfigFile to InOutText, constructed from the given SectionTexts, in the given order, with sections in *this overriding sections in SectionTexts
450 * @param InOutText - The string to write to
451 * @param bIsADefaultIniWrite - If true, force all properties to be written
452 * @param IniCombineThreshold - Cutoff level for combining ini (to prevent applying changes from the same ini that we're writing)
453 * @param InOutSectionTexts - A map from section name to existing text for that section; text does not include the name of the section.
454 * Entries in the TMap that also exist in *this will be updated.
455 * If the empty string is present, it will be written out first (it is interpreted as a prefix before the first section)
456 * @param InSectionOrder - List of section names in the order in which each section should be written to disk, from e.g. the existing file.
457 * Any section in this array that is not found in InOutSectionTexts will be ignored.
458 * Any section in InOutSectionTexts that is not in this array will be appended to the end.
459 * Duplicate entries are ignored; the first found index is used.
460 * @return TRUE if the write was successful
461 */
462 void WriteToStringInternal(FString& InOutText, bool bIsADefaultIniWrite, int32 IniCombineThreshold, TMap<FString, FString>& InOutSectionTexts, const TArray<FString>& InSectionOrder);
463
464public:
466
467 bool GetString( const TCHAR* Section, const TCHAR* Key, FString& Value ) const;
468 bool GetText( const TCHAR* Section, const TCHAR* Key, FText& Value ) const;
469 bool GetInt(const TCHAR* Section, const TCHAR* Key, int32& Value) const;
470 bool GetFloat(const TCHAR* Section, const TCHAR* Key, float& Value) const;
471 bool GetDouble(const TCHAR* Section, const TCHAR* Key, double& Value) const;
472 bool GetInt64( const TCHAR* Section, const TCHAR* Key, int64& Value ) const;
473 bool GetBool( const TCHAR* Section, const TCHAR* Key, bool& Value ) const;
474 int32 GetArray(const TCHAR* Section, const TCHAR* Key, TArray<FString>& Value) const;
475
476 /* Generic versions for use with templates */
477 bool GetValue(const TCHAR* Section, const TCHAR* Key, FString& Value) const
478 {
479 return GetString(Section, Key, Value);
480 }
481 bool GetValue(const TCHAR* Section, const TCHAR* Key, FText& Value) const
482 {
483 return GetText(Section, Key, Value);
484 }
485 bool GetValue(const TCHAR* Section, const TCHAR* Key, int32& Value) const
486 {
487 return GetInt(Section, Key, Value);
488 }
489 bool GetValue(const TCHAR* Section, const TCHAR* Key, float& Value) const
490 {
491 return GetFloat(Section, Key, Value);
492 }
493 bool GetValue(const TCHAR* Section, const TCHAR* Key, double& Value) const
494 {
495 return GetDouble(Section, Key, Value);
496 }
497 bool GetValue(const TCHAR* Section, const TCHAR* Key, int64& Value) const
498 {
499 return GetInt64(Section, Key, Value);
500 }
501 bool GetValue(const TCHAR* Section, const TCHAR* Key, bool& Value) const
502 {
503 return GetBool(Section, Key, Value);
504 }
505 int32 GetValue(const TCHAR* Section, const TCHAR* Key, TArray<FString>& Value) const
506 {
507 return GetArray(Section, Key, Value);
508 }
509
510 bool DoesSectionExist(const TCHAR* Section) const;
511
512 void SetString(const TCHAR* Section, const TCHAR* Key, const TCHAR* Value);
513 void SetText(const TCHAR* Section, const TCHAR* Key, const FText& Value);
514 void SetFloat(const TCHAR* Section, const TCHAR* Key, float Value);
515 void SetDouble(const TCHAR* Section, const TCHAR* Key, double Value);
516 void SetBool(const TCHAR* Section, const TCHAR* Key, bool Value);
517 void SetInt64(const TCHAR* Section, const TCHAR* Key, const int64 Value);
518 void SetArray(const TCHAR* Section, const TCHAR* Key, const TArray<FString>& Value);
519
520 /**
521 * Process the contents of an .ini file that has been read into an FString
522 *
523 * @param Filename Name of the .ini file the contents came from
524 * @param Contents Contents of the .ini file
525 */
526 void ProcessInputFileContents(FStringView Contents, const FString& FileHint);
527 UE_DEPRECATED(5.1, "Use ProcessInputFileContents that takes FileHint")
529 {
530 ProcessInputFileContents(Buffer, TEXT("Unknown file, using deprecated function"));
531 }
532
533
534 /** Adds any properties that exist in InSourceFile that this config file is missing */
535 void AddMissingProperties(const FConfigFile& InSourceFile);
536
537 /**
538 * Saves only the sections in this FConfigFile into the given file. All other sections in the file are left alone. The sections in this
539 * file are completely replaced. If IniRootName is specified, the current section settings are diffed against the file in the hierarchy up
540 * to right before this file (so, if you are saving DefaultEngine.ini, and IniRootName is "Engine", then Base.ini and BaseEngine.ini
541 * will be loaded, and only differences against that will be saved into DefaultEngine.ini)
542 *
543 * ======================================
544 * @todo: This currently doesn't work with array properties!! It will output the entire array, and without + notation!!
545 * ======================================
546 *
547 * @param IniRootName the name (like "Engine") to use to load a .ini hierarchy to diff against
548 */
549 void UpdateSections(const TCHAR* DiskFilename, const TCHAR* IniRootName=nullptr, const TCHAR* OverridePlatform=nullptr);
550
551 /**
552 * Update a single property in the config file, for the section that is specified.
553 */
554 bool UpdateSinglePropertyInSection(const TCHAR* DiskFilename, const TCHAR* PropertyName, const TCHAR* SectionName);
555
556
557 /**
558 * Check the source hierarchy which was loaded without any user changes from the Config/Saved dir.
559 * If anything in the default/base options have changed, we need to ensure that these propagate through
560 * to the final config so they are not potentially ignored
561 */
563
564 /** Checks if the PropertyValue should be exported in quotes when writing the ini to disk. */
565 static bool ShouldExportQuotedString(const FString& PropertyValue);
566
567 /** Generate a correctly escaped line to add to the config file for the given property */
568 static FString GenerateExportedPropertyLine(const FString& PropertyName, const FString& PropertyValue);
569
570 /** Append a correctly escaped line to add to the config file for the given property */
571 static void AppendExportedPropertyLine(FString& Out, const FString& PropertyName, const FString& PropertyValue);
572
573 /** Checks the command line for any overridden config settings */
574 static void OverrideFromCommandline(FConfigFile* File, const FString& Filename);
575
576 /** Checks the command line for any overridden config file settings */
577 static bool OverrideFileFromCommandline(FString& Filename);
578
579 /** Appends a new INI file to the SourceIniHierarchy and combines it with the current contents */
580 void AddDynamicLayerToHierarchy(const FString& Filename);
581
582 UE_DEPRECATED(5.0, "Call AddDynamicLayerToHierarchy. You also may need to call GetConfigFilename to get the right FConfigFile")
584
585 friend FArchive& operator<<(FArchive& Ar, FConfigFile& ConfigFile);
586private:
587
588 // This holds per-object config class names, with their ArrayOfStructKeys. Since the POC sections are all unique,
589 // we can't track it just in that section. This is expected to be empty/small
591
592 /**
593 * Save the source hierarchy which was loaded out to a backup file so we can check future changes in the base/default configs
594 */
596
597 /**
598 * Process the property for Writing to a default file. We will need to check for array operations, as default ini's rely on this
599 * being correct to function properly
600 *
601 * @param IniCombineThreshold - Cutoff level for combining ini (to prevent applying changes from the same ini that we're writing)
602 * @param InCompletePropertyToProcess - The complete property which we need to process for saving.
603 * @param OutText - The stream we are processing the array to
604 * @param SectionName - The section name the array property is being written to
605 * @param PropertyName - The property name of the array
606 */
607 void ProcessPropertyAndWriteForDefaults(int32 IniCombineThreshold, const TArray<const FConfigValue*>& InCompletePropertyToProcess, FString& OutText, const FString& SectionName, const FString& PropertyName);
608
609 /**
610 * Creates a chain of ini filenames to load and combine.
611 *
612 * @param InBaseIniName Ini name.
613 * @param InPlatformName Platform name, nullptr means to use the current platform
614 * @param OutHierarchy An array which is to receive the generated hierachy of ini filenames.
615 */
616 void AddStaticLayersToHierarchy(const TCHAR* InBaseIniName, const TCHAR* InPlatformName, const TCHAR* EngineConfigDir, const TCHAR* SourceConfigDir);
618
619 // for AddStaticLayersToHierarchy
620 friend class FConfigCacheIni;
622};
623
624/**
625 * Declares a delegate type that's used by the config system to allow iteration of key value pairs.
626 */
627DECLARE_DELEGATE_TwoParams(FKeyValueSink, const TCHAR*, const TCHAR*);
628
630{
631 // this type of config cache will write its files to disk during Flush (i.e. GConfig)
633 // this type of config cache is temporary and will never write to disk (only load from disk)
634 Temporary,
635};
636
637// Set of all cached config files.
638class FConfigCacheIni
639{
640public:
641 // Basic functions.
643
644 /** DO NOT USE. This constructor is for internal usage only for hot-reload purposes. */
646
647 virtual ~FConfigCacheIni();
648
649 /**
650 * Disables any file IO by the config cache system
651 */
652 virtual void DisableFileOperations();
653
654 /**
655 * Re-enables file IO by the config cache system
656 */
657 virtual void EnableFileOperations();
658
659 /**
660 * Returns whether or not file operations are disabled
661 */
663
664 /**
665 * @return true after after the basic .ini files have been loaded
666 */
668 {
669 return bIsReadyForUse;
670 }
671
672 /**
673 * Prases apart an ini section that contains a list of 1-to-N mappings of strings in the following format
674 * [PerMapPackages]
675 * MapName=Map1
676 * Package=PackageA
677 * Package=PackageB
678 * MapName=Map2
679 * Package=PackageC
680 * Package=PackageD
681 *
682 * @param Section Name of section to look in
683 * @param KeyOne Key to use for the 1 in the 1-to-N (MapName in the above example)
684 * @param KeyN Key to use for the N in the 1-to-N (Package in the above example)
685 * @param OutMap Map containing parsed results
686 * @param Filename Filename to use to find the section
687 *
688 * NOTE: The function naming is weird because you can't apparently have an overridden function differnt only by template type params
689 */
690 virtual void Parse1ToNSectionOfStrings(const TCHAR* Section, const TCHAR* KeyOne, const TCHAR* KeyN, TMap<FString, TArray<FString> >& OutMap, const FString& Filename);
691
692 /**
693 * Parses apart an ini section that contains a list of 1-to-N mappings of names in the following format
694 * [PerMapPackages]
695 * MapName=Map1
696 * Package=PackageA
697 * Package=PackageB
698 * MapName=Map2
699 * Package=PackageC
700 * Package=PackageD
701 *
702 * @param Section Name of section to look in
703 * @param KeyOne Key to use for the 1 in the 1-to-N (MapName in the above example)
704 * @param KeyN Key to use for the N in the 1-to-N (Package in the above example)
705 * @param OutMap Map containing parsed results
706 * @param Filename Filename to use to find the section
707 *
708 * NOTE: The function naming is weird because you can't apparently have an overridden function differnt only by template type params
709 */
710 virtual void Parse1ToNSectionOfNames(const TCHAR* Section, const TCHAR* KeyOne, const TCHAR* KeyN, TMap<FName, TArray<FName> >& OutMap, const FString& Filename);
711
712 /**
713 * Finds the in-memory config file for a config cache filename.
714 *
715 * @param A known key like GEngineIni, or the return value of GetConfigFilename
716 *
717 * @return The existing config file or null if it does not exist in memory
718 */
720
721 /**
722 * Finds, loads, or creates the in-memory config file for a config cache filename.
723 *
724 * @param A known key like GEngineIni, or the return value of GetConfigFilename
725 *
726 * @return A new or existing config file
727 */
728 FConfigFile* Find(const FString& InFilename);
729
730 /**
731 * Reports whether an FConfigFile* is pointing to a config file inside of this
732 * Used for downstream functions to check whether a config file they were passed came from this ConfigCacheIni or from
733 * a different source such as LoadLocalIniFile
734 */
735 bool ContainsConfigFile(const FConfigFile* ConfigFile) const;
736
737 UE_DEPRECATED(5.0, "CreateIfNotFound is deprecated, please use the overload without this parameter or FindConfigFile")
738 FConfigFile* Find(const FString& Filename, bool CreateIfNotFound);
739
740 /** Finds Config file that matches the base name such as "Engine" */
742
743 FConfigFile& Add(const FString& Filename, const FConfigFile& File)
744 {
745 return *OtherFiles.Add(Filename, new FConfigFile(File));
746 }
747 int32 Remove(const FString& Filename)
748 {
749 delete OtherFiles.FindRef(Filename);
750 return OtherFiles.Remove(Filename);
751 }
753
754
755 void Flush(bool bRemoveFromCache, const FString& Filename=TEXT(""));
756
757 void LoadFile( const FString& InFilename, const FConfigFile* Fallback = NULL, const TCHAR* PlatformString = NULL );
758 void SetFile( const FString& InFilename, const FConfigFile* NewConfigFile );
759 void UnloadFile( const FString& Filename );
760 void Detach( const FString& Filename );
761
762 bool GetString( const TCHAR* Section, const TCHAR* Key, FString& Value, const FString& Filename );
763 bool GetText( const TCHAR* Section, const TCHAR* Key, FText& Value, const FString& Filename );
764 bool GetSection( const TCHAR* Section, TArray<FString>& Result, const FString& Filename );
765 bool DoesSectionExist(const TCHAR* Section, const FString& Filename);
766 /**
767 * @param Force Whether to create the Section on Filename if it did not exist previously.
768 * @param Const If Const (and not Force), then it will not modify File->Dirty. If not Const (or Force is true), then File->Dirty will be set to true.
769 */
770 FConfigSection* GetSectionPrivate( const TCHAR* Section, const bool Force, const bool Const, const FString& Filename );
771 void SetString( const TCHAR* Section, const TCHAR* Key, const TCHAR* Value, const FString& Filename );
772 void SetText( const TCHAR* Section, const TCHAR* Key, const FText& Value, const FString& Filename );
773 bool RemoveKey( const TCHAR* Section, const TCHAR* Key, const FString& Filename );
774 bool EmptySection( const TCHAR* Section, const FString& Filename );
775 bool EmptySectionsMatchingString( const TCHAR* SectionString, const FString& Filename );
776
777 /**
778 * For a base ini name, gets the config cache filename key that is used by other functions like Find.
779 * This will be the base name for known configs like Engine and the destination filename for others.
780 *
781 * @param IniBaseName Base name of the .ini (Engine, Game, CustomSystem)
782 *
783 * @return Filename key used by other cache functions
784 */
785 FString GetConfigFilename(const TCHAR* BaseIniName);
786
787 /**
788 * Retrieve a list of all of the config files stored in the cache
789 *
790 * @param ConfigFilenames Out array to receive the list of filenames
791 */
792 void GetConfigFilenames(TArray<FString>& ConfigFilenames);
793
794 /**
795 * Retrieve the names for all sections contained in the file specified by Filename
796 *
797 * @param Filename the file to retrieve section names from
798 * @param out_SectionNames will receive the list of section names
799 *
800 * @return true if the file specified was successfully found;
801 */
802 bool GetSectionNames( const FString& Filename, TArray<FString>& out_SectionNames );
803
804 /**
805 * Retrieve the names of sections which contain data for the specified PerObjectConfig class.
806 *
807 * @param Filename the file to retrieve section names from
808 * @param SearchClass the name of the PerObjectConfig class to retrieve sections for.
809 * @param out_SectionNames will receive the list of section names that correspond to PerObjectConfig sections of the specified class
810 * @param MaxResults the maximum number of section names to retrieve
811 *
812 * @return true if the file specified was found and it contained at least 1 section for the specified class
813 */
814 bool GetPerObjectConfigSections( const FString& Filename, const FString& SearchClass, TArray<FString>& out_SectionNames, int32 MaxResults=1024 );
815
816 void Exit();
817
818 /**
819 * Prints out the entire config set, or just a single file if an ini is specified
820 *
821 * @param Ar the device to write to
822 * @param IniName An optional ini name to restrict the writing to (Engine or WrangleContent) - meant to be used with "final" .ini files (not Default*)
823 */
824 void Dump(FOutputDevice& Ar, const TCHAR* IniName=NULL);
825
826 /**
827 * Dumps memory stats for each file in the config cache to the specified archive.
828 *
829 * @param Ar the output device to dump the results to
830 */
831 virtual void ShowMemoryUsage( FOutputDevice& Ar );
832
833 /**
834 * USed to get the max memory usage for the FConfigCacheIni
835 *
836 * @return the amount of memory in byes
837 */
838 virtual SIZE_T GetMaxMemoryUsage();
839
840 /**
841 * allows to iterate through all key value pairs
842 * @return false:error e.g. Section or Filename not found
843 */
844 virtual bool ForEachEntry(const FKeyValueSink& Visitor, const TCHAR* Section, const FString& Filename);
845
846 // Derived functions.
848 (
849 const TCHAR* Section,
850 const TCHAR* Key,
851 const FString& Filename
852 );
854 (
855 const TCHAR* Section,
856 const TCHAR* Key,
857 int32& Value,
858 const FString& Filename
859 );
861 (
862 const TCHAR* Section,
863 const TCHAR* Key,
864 float& Value,
865 const FString& Filename
866 );
868 (
869 const TCHAR* Section,
870 const TCHAR* Key,
871 double& Value,
872 const FString& Filename
873 );
875 (
876 const TCHAR* Section,
877 const TCHAR* Key,
878 bool& Value,
879 const FString& Filename
880 );
882 (
883 const TCHAR* Section,
884 const TCHAR* Key,
885 TArray<FString>& out_Arr,
886 const FString& Filename
887 );
888 /** Loads a "delimited" list of strings
889 * @param Section - Section of the ini file to load from
890 * @param Key - The key in the section of the ini file to load
891 * @param out_Arr - Array to load into
892 * @param Filename - Ini file to load from
893 */
895 (
896 const TCHAR* Section,
897 const TCHAR* Key,
898 TArray<FString>& out_Arr,
899 const FString& Filename
900 );
902 (
903 const TCHAR* Section,
904 const TCHAR* Key,
905 FColor& Value,
906 const FString& Filename
907 );
909 const TCHAR* Section,
910 const TCHAR* Key,
911 FVector2D& Value,
912 const FString& Filename);
914 (
915 const TCHAR* Section,
916 const TCHAR* Key,
917 FVector& Value,
918 const FString& Filename
919 );
921 (
922 const TCHAR* Section,
923 const TCHAR* Key,
924 FVector4& Value,
925 const FString& Filename
926 );
928 (
929 const TCHAR* Section,
930 const TCHAR* Key,
931 FRotator& Value,
932 const FString& Filename
933 );
934
935 /* Generic versions for use with templates */
936 bool GetValue(const TCHAR* Section, const TCHAR* Key, FString& Value, const FString& Filename)
937 {
938 return GetString(Section, Key, Value, Filename);
939 }
940 bool GetValue(const TCHAR* Section, const TCHAR* Key, FText& Value, const FString& Filename)
941 {
942 return GetText(Section, Key, Value, Filename);
943 }
944 bool GetValue(const TCHAR* Section, const TCHAR* Key, int32& Value, const FString& Filename)
945 {
946 return GetInt(Section, Key, Value, Filename);
947 }
948 bool GetValue(const TCHAR* Section, const TCHAR* Key, float& Value, const FString& Filename)
949 {
950 return GetFloat(Section, Key, Value, Filename);
951 }
952 bool GetValue(const TCHAR* Section, const TCHAR* Key, bool& Value, const FString& Filename)
953 {
954 return GetBool(Section, Key, Value, Filename);
955 }
956 int32 GetValue(const TCHAR* Section, const TCHAR* Key, TArray<FString>& Value, const FString& Filename)
957 {
958 return GetArray(Section, Key, Value, Filename);
959 }
960
961 // Return a config value if found, if not found return default value
962 // does not indicate if return value came from config or the default value
963 // useful for one-time init of static variables in code locations where config may be queried too often, like :
964 // static int32 bMyConfigValue = GConfig->GetIntOrDefault(Section,Key,DefaultValue,ConfigFilename);
965 int32 GetIntOrDefault(const TCHAR* Section, const TCHAR* Key, const int32 DefaultValue, const FString& Filename)
966 {
967 int32 Value = DefaultValue;
968 GetInt(Section,Key,Value,Filename);
969 return Value;
970 }
971 float GetFloatOrDefault(const TCHAR* Section, const TCHAR* Key, const float DefaultValue, const FString& Filename)
972 {
973 float Value = DefaultValue;
974 GetFloat(Section,Key,Value,Filename);
975 return Value;
976 }
977 bool GetBoolOrDefault(const TCHAR* Section, const TCHAR* Key, const bool DefaultValue, const FString& Filename)
978 {
979 bool Value = DefaultValue;
980 GetBool(Section,Key,Value,Filename);
981 return Value;
982 }
983 FString GetStringOrDefault(const TCHAR* Section, const TCHAR* Key, const FString & DefaultValue, const FString& Filename)
984 {
985 FString Value;
986 if ( GetString(Section,Key,Value,Filename) )
987 {
988 return Value;
989 }
990 else
991 {
992 return DefaultValue;
993 }
994 }
995 FText GetTextOrDefault(const TCHAR* Section, const TCHAR* Key, const FText & DefaultValue, const FString& Filename)
996 {
997 FText Value;
998 if ( GetText(Section,Key,Value,Filename) )
999 {
1000 return Value;
1001 }
1002 else
1003 {
1004 return DefaultValue;
1005 }
1006 }
1007
1009 (
1010 const TCHAR* Section,
1011 const TCHAR* Key,
1012 int32 Value,
1013 const FString& Filename
1014 );
1016 (
1017 const TCHAR* Section,
1018 const TCHAR* Key,
1019 float Value,
1020 const FString& Filename
1021 );
1023 (
1024 const TCHAR* Section,
1025 const TCHAR* Key,
1026 double Value,
1027 const FString& Filename
1028 );
1030 (
1031 const TCHAR* Section,
1032 const TCHAR* Key,
1033 bool Value,
1034 const FString& Filename
1035 );
1037 (
1038 const TCHAR* Section,
1039 const TCHAR* Key,
1040 const TArray<FString>& Value,
1041 const FString& Filename
1042 );
1043 /** Saves a "delimited" list of strings
1044 * @param Section - Section of the ini file to save to
1045 * @param Key - The key in the section of the ini file to save
1046 * @param out_Arr - Array to save from
1047 * @param Filename - Ini file to save to
1048 */
1050 (
1051 const TCHAR* Section,
1052 const TCHAR* Key,
1053 const TArray<FString>& In_Arr,
1054 const FString& Filename
1055 );
1057 (
1058 const TCHAR* Section,
1059 const TCHAR* Key,
1060 FColor Value,
1061 const FString& Filename
1062 );
1064 const TCHAR* Section,
1065 const TCHAR* Key,
1066 FVector2D Value,
1067 const FString& Filename);
1069 (
1070 const TCHAR* Section,
1071 const TCHAR* Key,
1072 FVector Value,
1073 const FString& Filename
1074 );
1076 (
1077 const TCHAR* Section,
1078 const TCHAR* Key,
1079 const FVector4& Value,
1080 const FString& Filename
1081 );
1083 (
1084 const TCHAR* Section,
1085 const TCHAR* Key,
1086 FRotator Value,
1087 const FString& Filename
1088 );
1089
1090 // Static helper functions
1091
1092 /**
1093 * Creates GConfig, loads the standard global ini files (Engine, Editor, etc),
1094 * fills out GEngineIni, etc. and marks GConfig as ready for use
1095 */
1097
1098 /**
1099 * Returns the Custom Config string, which if set will load additional config files from Config/Custom/{CustomConfig}/DefaultX.ini to allow different types of builds.
1100 * It can be set from a game Target.cs file with CustomConfig = "Name".
1101 * Or in development, it can be overridden with a -CustomConfig=Name command line parameter.
1102 */
1104
1105 /**
1106 * Calculates the name of a dest (generated) .ini file for a given base (ie Engine, Game, etc)
1107 *
1108 * @param IniBaseName Base name of the .ini (Engine, Game)
1109 * @param PlatformName Name of the platform to get the .ini path for (nullptr means to use the current platform)
1110 * @param GeneratedConfigDir The base folder that will contain the generated config files.
1111 *
1112 * @return Standardized .ini filename
1113 */
1114 static FString GetDestIniFilename(const TCHAR* BaseIniName, const TCHAR* PlatformName, const TCHAR* GeneratedConfigDir);
1115
1116 /**
1117 * Loads and generates a destination ini file and adds it to GConfig:
1118 * - Looking on commandline for override source/dest .ini filenames
1119 * - Generating the name for the engine to refer to the ini
1120 * - Loading a source .ini file hierarchy
1121 * - Filling out an FConfigFile
1122 * - Save the generated ini
1123 * - Adds the FConfigFile to GConfig
1124 *
1125 * @param FinalIniFilename The output name of the generated .ini file (in Game\Saved\Config)
1126 * @param BaseIniName The "base" ini name, with no extension (ie, Engine, Game, etc)
1127 * @param Platform The platform to load the .ini for (if NULL, uses current)
1128 * @param bForceReload If true, the destination .in will be regenerated from the source, otherwise this will only process if the dest isn't in GConfig
1129 * @param bRequireDefaultIni If true, the Default*.ini file is required to exist when generating the final ini file.
1130 * @param bAllowGeneratedIniWhenCooked If true, the engine will attempt to load the generated/user INI file when loading cooked games
1131 * @param GeneratedConfigDir The location where generated config files are made.
1132 * @return true if the final ini was created successfully.
1133 */
1134 static bool LoadGlobalIniFile(FString& FinalIniFilename, const TCHAR* BaseIniName, const TCHAR* Platform = NULL, bool bForceReload = false, bool bRequireDefaultIni = false, bool bAllowGeneratedIniWhenCooked = true, bool bAllowRemoteConfig = true, const TCHAR* GeneratedConfigDir = *FPaths::GeneratedConfigDir(), FConfigCacheIni* ConfigSystem=GConfig);
1135
1136 /**
1137 * Load an ini file directly into an FConfigFile, and nothing is written to GConfig or disk.
1138 * The passed in .ini name can be a "base" (Engine, Game) which will be modified by platform and/or commandline override,
1139 * or it can be a full ini filename (ie WrangleContent) loaded from the Source config directory
1140 *
1141 * @param ConfigFile The output object to fill
1142 * @param IniName Either a Base ini name (Engine) or a full ini name (WrangleContent). NO PATH OR EXTENSION SHOULD BE USED!
1143 * @param bIsBaseIniName true if IniName is a Base name, which can be overridden on commandline, etc.
1144 * @param Platform The platform to use for Base ini names, NULL means to use the current platform
1145 * @param bForceReload force reload the ini file from disk this is required if you make changes to the ini file not using the config system as the hierarchy cache will not be updated in this case
1146 * @return true if the ini file was loaded successfully
1147 */
1148 static bool LoadLocalIniFile(FConfigFile& ConfigFile, const TCHAR* IniName, bool bIsBaseIniName, const TCHAR* Platform=NULL, bool bForceReload=false);
1149
1150 /**
1151 * Load an ini file directly into an FConfigFile from the specified config folders, optionally writing to disk.
1152 * The passed in .ini name can be a "base" (Engine, Game) which will be modified by platform and/or commandline override,
1153 * or it can be a full ini filename (ie WrangleContent) loaded from the Source config directory
1154 *
1155 * @param ConfigFile The output object to fill
1156 * @param IniName Either a Base ini name (Engine) or a full ini name (WrangleContent). NO PATH OR EXTENSION SHOULD BE USED!
1157 * @param EngineConfigDir Engine config directory.
1158 * @param SourceConfigDir Game config directory.
1159 * @param bIsBaseIniName true if IniName is a Base name, which can be overridden on commandline, etc.
1160 * @param Platform The platform to use for Base ini names
1161 * @param bForceReload force reload the ini file from disk this is required if you make changes to the ini file not using the config system as the hierarchy cache will not be updated in this case
1162 * @param bWriteDestIni write out a destination ini file to the Saved folder, only valid if bIsBaseIniName is true
1163 * @param bAllowGeneratedIniWhenCooked If true, the engine will attempt to load the generated/user INI file when loading cooked games
1164 * @param GeneratedConfigDir The location where generated config files are made.
1165 * @return true if the ini file was loaded successfully
1166 */
1167 static bool LoadExternalIniFile(FConfigFile& ConfigFile, const TCHAR* IniName, const TCHAR* EngineConfigDir, const TCHAR* SourceConfigDir, bool bIsBaseIniName, const TCHAR* Platform=NULL, bool bForceReload=false, bool bWriteDestIni=false, bool bAllowGeneratedIniWhenCooked = true, const TCHAR* GeneratedConfigDir = *FPaths::GeneratedConfigDir());
1168
1169 /**
1170 * Needs to be called after GConfig is set and LoadCoalescedFile was called.
1171 * Loads the state of console variables.
1172 * Works even if the variable is registered after the ini file was loaded.
1173 */
1175
1176 /**
1177 * Normalizes file paths to INI files.
1178 *
1179 * If an INI file is accessed with multiple paths, then we can run into issues where we cache multiple versions
1180 * of the file. Specifically, any updates to the file may only be applied to one cached version, and could cause
1181 * changes to be lost.
1182 *
1183 * E.G.
1184 *
1185 * // Standard path.
1186 * C:\ProjectDir\Engine\Config\DefaultEngine.ini
1187 *
1188 * // Lowercase drive, and an extra slash between ProjectDir and Engine.
1189 * c:\ProjectDir\\Engine\Confg\DefaultEngine.ini
1190 *
1191 * // Relative to a project binary.
1192 * ..\..\..\ConfigDefaultEngine.ini
1193 *
1194 * The paths above could all be used to reference the same ini file (namely, DefaultEngine.ini).
1195 * However, they would end up generating unique entries in the GConfigCache.
1196 * That means any modifications to *one* of the entries would not propagate to the others, and if
1197 * any / all of the ini files are saved, they will stomp changes to the other entries.
1198 *
1199 * We can prevent these types of issues by enforcing normalized paths when accessing configs.
1200 *
1201 * @param NonNormalizedPath The path to the INI file we want to access.
1202 * @return A normalized version of the path (may be the same as the input).
1203 */
1204 static FString NormalizeConfigIniPath(const FString& NonNormalizedPath);
1205
1206 /**
1207 * This helper function searches the cache before trying to load the ini file using LoadLocalIniFile.
1208 * Note that the returned FConfigFile pointer must have the same lifetime as the passed in LocalFile.
1209 *
1210 * @param LocalFile The output object to fill. If the FConfigFile is found in the cache, this won't be used.
1211 * @param IniName Either a Base ini name (Engine) or a full ini name (WrangleContent). NO PATH OR EXTENSION SHOULD BE USED!
1212 * @param Platform The platform to use for Base ini names, NULL means to use the current platform
1213 * @return FConfigFile Found or loaded FConfigFile
1214 */
1215 static FConfigFile* FindOrLoadPlatformConfig(FConfigFile& LocalFile, const TCHAR* IniName, const TCHAR* Platform = NULL);
1216
1217 /**
1218 * Attempts to find the platform config in the cache.
1219 *
1220 * @param IniName Either a Base ini name (Engine) or a full ini name (WrangleContent). NO PATH OR EXTENSION SHOULD BE USED!
1221 * @param Platform The platform to use for Base ini names, NULL means to use the current platform
1222 * @return FConfigFile Found FConfigFile
1223 */
1224 static FConfigFile* FindPlatformConfig(const TCHAR* IniName, const TCHAR* Platform);
1225
1226 /**
1227 * Save the current config cache state into a file for bootstrapping other processes.
1228 */
1229 void SaveCurrentStateForBootstrap(const TCHAR* Filename);
1230
1232
1233
1235 {
1237
1238 // Write out this for binary config serialization
1239 friend FArchive& operator<<(FArchive& Ar, FKnownConfigFiles& Names);
1240
1241 // setup GEngineIni based on this structure's values
1243
1244 // given an name ("Engine") return the FConfigFile for it
1246 // given an name ("Engine") return the modifiable FConfigFile for it
1248
1249 // get the disk-based filename for the given known ini name
1251
1252
1253 // create the list of members for the known inis (Engine, Game, etc) See the top of this file for the list
1255 {
1259 };
1260
1261 // array of all known filesd
1263 };
1264
1265 /**
1266 * Load the standard (used on all platforms) ini files, like Engine, Input, etc
1267 *
1268 * @param PlatformName Ini name of the platform this is loadenig for (or nullptr for current platform)
1269 * @param bDefaultEngineIniRequired True if the engine ini is required
1270 * @param OverrideProjectDir Used to generate configs for another project (like from a program making binary configs)
1271 *
1272 * return True if the engine ini was loaded
1273 */
1274 bool InitializeKnownConfigFiles(const TCHAR* PlatformName, bool bDefaultEngineIniRequired, const TCHAR* OverrideProjectDir=nullptr);
1276
1277 /**
1278 * Returns true if the given name is one of the known configs, where the matching G****Ini property is going to match the
1279 * base name ("Engine" returns true, which means GEngineIni's value is just "Engine")
1280 */
1281 bool IsKnownConfigName(FName ConfigName);
1282
1283 /**
1284 * Create GConfig from a saved file
1285 */
1286 static bool CreateGConfigFromSaved(const TCHAR* Filename);
1287
1288 /**
1289 * Retrieve the fully processed ini system for another platform. The editor will start loading these
1290 * in the background on startup
1291 */
1292 static FConfigCacheIni* ForPlatform(FName PlatformName);
1293
1294 /**
1295 * Wipe all cached platform configs. Next ForPlatform call will load on-demand the platform configs
1296 */
1298
1299private:
1300#if WITH_EDITOR
1301 /** We only auto-initialize other platform configs in the editor to not slow down programs like ShaderCOmpileWorker */
1303#endif
1304
1305 /** Serialize a bootstrapping state into or from an archive */
1307
1308 /** true if file operations should not be performed */
1310
1311 /** true after the base .ini files have been loaded, and GConfig is generally "ready for use" */
1313
1314 /** The type of the cache (basically, do we call Flush in the destructor) */
1316
1317 /** The filenames for the known files in this config */
1319
1321
1323};
1324
1325
1326
1327/**
1328 * Helper function to read the contents of an ini file and a specified group of cvar parameters, where sections in the ini file are marked [InName]
1329 * @param InSectionBaseName - The base name of the section to apply cvars from
1330 * @param InIniFilename - The ini filename
1331 * @param SetBy anything in ECVF_LastSetMask e.g. ECVF_SetByScalability
1332 */
1333UE_DEPRECATED(5.1, "Use UE::ConfigUtilities::ApplyCVarSettingsFromIni")
1334void ApplyCVarSettingsFromIni(const TCHAR* InSectionBaseName, const TCHAR* InIniFilename, uint32 SetBy, bool bAllowCheating = false);
1335
1336/**
1337 * Helper function to operate a user defined function for each CVar key/value pair in the specified section in an ini file
1338 * @param InSectionName - The name of the section to apply cvars from
1339 * @param InIniFilename - The ini filename
1340 * @param InEvaluationFunction - The evaluation function to be called for each key/value pair
1341 */
1342UE_DEPRECATED(5.1, "Use UE::ConfigUtilities::ForEachCVarInSectionFromIni")
1343void ForEachCVarInSectionFromIni(const TCHAR* InSectionName, const TCHAR* InIniFilename, TFunction<void(IConsoleVariable* CVar, const FString& KeyString, const FString& ValueString)> InEvaluationFunction);
1344
1345/**
1346 * CVAR Ini history records all calls to ApplyCVarSettingsFromIni and can re run them
1347 */
1348
1349/**
1350 * Helper function to start recording ApplyCVarSettings function calls
1351 * uses these to generate a history of applied ini settings sections
1352 */
1353UE_DEPRECATED(5.1, "Use UE::ConfigUtilities::RecordApplyCVarSettingsFromIni")
1355
1356/**
1357 * Helper function to reapply inis which have been applied after RecordCVarIniHistory was called
1358 */
1359UE_DEPRECATED(5.1, "Use UE::ConfigUtilities::ReapplyRecordedCVarSettingsFromIni")
1361
1362/**
1363 * Helper function to clean up ini history
1364 */
1365UE_DEPRECATED(5.1, "Use UE::ConfigUtilities::DeleteRecordedCVarSettingsFromIni")
1367
1368/**
1369 * Helper function to start recording config reads
1370 */
1371UE_DEPRECATED(5.1, "Use UE::ConfigUtilities::RecordConfigReadsFromIni")
1373
1374/**
1375 * Helper function to dump config reads to csv after RecordConfigReadsFromIni was called
1376 */
1377UE_DEPRECATED(5.1, "Use UE::ConfigUtilities::DumpRecordedConfigReadsFromIni")
1379
1380/**
1381 * Helper function to clean up config read history
1382 */
1383UE_DEPRECATED(5.1, "Use UE::ConfigUtilities::DeleteRecordedConfigReadsFromIni")
1385
1386/**
1387 * Helper function to deal with "True","False","Yes","No","On","Off"
1388 */
1389UE_DEPRECATED(5.1, "Use UE::ConfigUtilities::ConvertValueFromHumanFriendlyValue")
1390const TCHAR* ConvertValueFromHumanFriendlyValue(const TCHAR* Value);
#define UE_BUILD_SHIPPING
Definition Build.h:4
#define UE_SERVER
Definition Build.h:45
#define WITH_EDITOR
Definition Build.h:7
#define CONFIG_REMEMBER_ACCESS_PATTERN
void RecordConfigReadsFromIni()
void DeleteRecordedCVarSettingsFromIni()
#define ENUMERATE_KNOWN_INI_FILES(op)
void DeleteRecordedConfigReadsFromIni()
void RecordApplyCVarSettingsFromIni()
void ReapplyRecordedCVarSettingsFromIni()
#define ALLOW_INI_OVERRIDE_FROM_COMMANDLINE
TMultiMap< FName, FConfigValue > FConfigSectionMap
const TCHAR * ConvertValueFromHumanFriendlyValue(const TCHAR *Value)
void ForEachCVarInSectionFromIni(const TCHAR *InSectionName, const TCHAR *InIniFilename, TFunction< void(IConsoleVariable *CVar, const FString &KeyString, const FString &ValueString)> InEvaluationFunction)
void ApplyCVarSettingsFromIni(const TCHAR *InSectionBaseName, const TCHAR *InIniFilename, uint32 SetBy, bool bAllowCheating=false)
void DumpRecordedConfigReadsFromIni()
FConfigCacheIni * GConfig
#define UE_DEPRECATED(Version, Message)
#define DECLARE_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
EKnownIniFile
Definition Enums.h:20462
EConfigCacheType
Definition Enums.h:13074
DECLARE_LOG_CATEGORY_EXTERN(LogChunkInstaller, Log, All)
#define TEXT(x)
Definition Platform.h:1108
bool GetValue(const TCHAR *Section, const TCHAR *Key, double &Value) const
static bool WriteTempFileThenMove()
void Read(const FString &Filename)
void SetText(const TCHAR *Section, const TCHAR *Key, const FText &Value)
void WriteToString(FString &InOutText, const FString &SimulatedFilename=FString(), const FString &PrefixText=FString())
void AddStaticLayersToHierarchy(const TCHAR *InBaseIniName, const TCHAR *InPlatformName, const TCHAR *EngineConfigDir, const TCHAR *SourceConfigDir)
static void AddStaticLayersToHierarchy(FConfigContext &Context)
void ProcessInputFileContents(FStringView Contents, const FString &FileHint)
bool UpdateSinglePropertyInSection(const TCHAR *DiskFilename, const TCHAR *PropertyName, const TCHAR *SectionName)
void SetString(const TCHAR *Section, const TCHAR *Key, const TCHAR *Value)
bool GetValue(const TCHAR *Section, const TCHAR *Key, float &Value) const
bool GetBool(const TCHAR *Section, const TCHAR *Key, bool &Value) const
bool DoesSectionExist(const TCHAR *Section) const
bool GetFloat(const TCHAR *Section, const TCHAR *Key, float &Value) const
FString SourceEngineConfigDir
void AddDynamicLayerToHierarchy(const FString &Filename)
bool GetString(const TCHAR *Section, const TCHAR *Key, FString &Value) const
bool GetValue(const TCHAR *Section, const TCHAR *Key, FString &Value) const
static void AppendExportedPropertyLine(FString &Out, const FString &PropertyName, const FString &PropertyValue)
static bool ShouldExportQuotedString(const FString &PropertyValue)
bool GetValue(const TCHAR *Section, const TCHAR *Key, int32 &Value) const
void SetInt64(const TCHAR *Section, const TCHAR *Key, const int64 Value)
void SetBool(const TCHAR *Section, const TCHAR *Key, bool Value)
TMap< FString, TMap< FName, FString > > PerObjectConfigArrayOfStructKeys
void AddMissingProperties(const FConfigFile &InSourceFile)
void CombineFromBuffer(const FString &Buffer, const FString &FileHint)
void SetDouble(const TCHAR *Section, const TCHAR *Key, double Value)
FConfigFile * SourceConfigFile
void ProcessInputFileContents(const FString &Buffer)
static FString GenerateExportedPropertyLine(const FString &PropertyName, const FString &PropertyValue)
void SetFloat(const TCHAR *Section, const TCHAR *Key, float Value)
void ProcessPropertyAndWriteForDefaults(int32 IniCombineThreshold, const TArray< const FConfigValue * > &InCompletePropertyToProcess, FString &OutText, const FString &SectionName, const FString &PropertyName)
bool IsADefaultIniWrite(const FString &Filename, int32 &OutIniCombineThreshold) const
void Dump(FOutputDevice &Ar)
bool GetDouble(const TCHAR *Section, const TCHAR *Key, double &Value) const
bool operator!=(const FConfigFile &Other) const
FConfigFileHierarchy SourceIniHierarchy
bool Combine(const FString &Filename)
FString PlatformName
bool GetValue(const TCHAR *Section, const TCHAR *Key, bool &Value) const
void AddDynamicLayerToHeirarchy(const FString &Filename)
void ProcessSourceAndCheckAgainstBackup()
static bool OverrideFileFromCommandline(FString &Filename)
int32 GetArray(const TCHAR *Section, const TCHAR *Key, TArray< FString > &Value) const
void WriteToStringInternal(FString &InOutText, bool bIsADefaultIniWrite, int32 IniCombineThreshold, TMap< FString, FString > &InOutSectionTexts, const TArray< FString > &InSectionOrder)
FString SourceProjectConfigDir
void SetArray(const TCHAR *Section, const TCHAR *Key, const TArray< FString > &Value)
void CombineFromBuffer(const FString &Buffer)
bool GetValue(const TCHAR *Section, const TCHAR *Key, int64 &Value) const
void UpdateSections(const TCHAR *DiskFilename, const TCHAR *IniRootName=nullptr, const TCHAR *OverridePlatform=nullptr)
FConfigSection * FindOrAddSection(const FString &Name)
bool GetInt(const TCHAR *Section, const TCHAR *Key, int32 &Value) const
bool Write(const FString &Filename, bool bDoRemoteWrite=true, const FString &PrefixText=FString())
void SaveSourceToBackupFile()
static void OverrideFromCommandline(FConfigFile *File, const FString &Filename)
bool operator==(const FConfigFile &Other) const
bool GetValue(const TCHAR *Section, const TCHAR *Key, FText &Value) const
bool GetInt64(const TCHAR *Section, const TCHAR *Key, int64 &Value) const
bool WriteInternal(const FString &Filename, bool bDoRemoteWrite, TMap< FString, FString > &InOutSectionTexts, const TArray< FString > &InSectionOrder)
bool GetText(const TCHAR *Section, const TCHAR *Key, FText &Value) const
bool HandleArrayOfKeyedStructsCommand(FName Key, FString &&Value)
bool operator!=(const FConfigSection &Other) const
static bool HasQuotes(const FString &Test)
bool operator==(const FConfigSection &Other) const
void MultiFind(const FName Key, TArray< FString, Allocator > &OutValues, const bool bMaintainOrder=false) const
TMap< FName, FString > ArrayOfStructKeys
void MultiFind(const FName Key, TArray< FConfigValue, Allocator > &OutValues, const bool bMaintainOrder=false) const
void HandleAddCommand(FName Key, FString &&Value, bool bAppendValueIfNotArrayOfStructsKeyUsed)
Definition Paths.h:36
static FString GeneratedConfigDir()
FString()=default
UE_NODISCARD FORCEINLINE const TCHAR * operator*() const UE_LIFETIMEBOUND
FStructuredArchiveSlot GetSlot()
FStructuredArchiveFromArchive(FArchive &Ar)
Definition Text.h:357
Definition Vector.h:40
FORCEINLINE bool IsLoading() const
Definition Archive.h:249
const FString & GetFilename(FName Name)
FKnownConfigFile Files[(uint8) EKnownIniFile::NumKnownFiles]
FConfigFile * GetMutableFile(FName Name)
const FConfigFile * GetFile(FName Name)
void SetBool(const TCHAR *Section, const TCHAR *Key, bool Value, const FString &Filename)
virtual bool ForEachEntry(const FKeyValueSink &Visitor, const TCHAR *Section, const FString &Filename)
virtual void Parse1ToNSectionOfNames(const TCHAR *Section, const TCHAR *KeyOne, const TCHAR *KeyN, TMap< FName, TArray< FName > > &OutMap, const FString &Filename)
void SetText(const TCHAR *Section, const TCHAR *Key, const FText &Value, const FString &Filename)
virtual void DisableFileOperations()
bool EmptySection(const TCHAR *Section, const FString &Filename)
unsigned __int64 GetMaxMemoryUsage()
Definition Other.h:2379
bool GetSection(const TCHAR *Section, TArray< FString > &Result, const FString &Filename)
void SetString(const TCHAR *Section, const TCHAR *Key, const TCHAR *Value, const FString &Filename)
void SetArray(const TCHAR *Section, const TCHAR *Key, const TArray< FString > &Value, const FString &Filename)
bool GetText(const TCHAR *Section, const TCHAR *Key, FText &Value, const FString &Filename)
static void InitializeConfigSystem()
static bool LoadGlobalIniFile(FString &FinalIniFilename, const TCHAR *BaseIniName, const TCHAR *Platform=NULL, bool bForceReload=false, bool bRequireDefaultIni=false, bool bAllowGeneratedIniWhenCooked=true, bool bAllowRemoteConfig=true, const TCHAR *GeneratedConfigDir= *FPaths::GeneratedConfigDir(), FConfigCacheIni *ConfigSystem=GConfig)
static bool CreateGConfigFromSaved(const wchar_t *Filename)
Definition Other.h:2385
bool GetValue(const TCHAR *Section, const TCHAR *Key, int32 &Value, const FString &Filename)
int32 GetSingleLineArray(const TCHAR *Section, const TCHAR *Key, TArray< FString > &out_Arr, const FString &Filename)
bool GetBool(const TCHAR *Section, const TCHAR *Key, bool &Value, const FString &Filename)
bool GetDouble(const TCHAR *Section, const TCHAR *Key, double &Value, const FString &Filename)
FConfigFile * Find(const FString &InFilename)
bool GetValue(const TCHAR *Section, const TCHAR *Key, FText &Value, const FString &Filename)
FText GetTextOrDefault(const TCHAR *Section, const TCHAR *Key, const FText &DefaultValue, const FString &Filename)
bool GetSectionNames(const FString &Filename, TArray< FString > &out_SectionNames)
int32 Remove(const FString &Filename)
FString GetConfigFilename(const TCHAR *BaseIniName)
bool GetBoolOrDefault(const TCHAR *Section, const TCHAR *Key, const bool DefaultValue, const FString &Filename)
bool GetColor(const TCHAR *Section, const TCHAR *Key, FColor &Value, const FString &Filename)
FConfigFile * Find(const FString &Filename, bool CreateIfNotFound)
FKnownConfigFiles KnownFiles
static void ClearOtherPlatformConfigs()
void UnloadFile(const FString &Filename)
virtual void Parse1ToNSectionOfStrings(const TCHAR *Section, const TCHAR *KeyOne, const TCHAR *KeyN, TMap< FString, TArray< FString > > &OutMap, const FString &Filename)
EConfigCacheType Type
void SetVector(const TCHAR *Section, const TCHAR *Key, FVector Value, const FString &Filename)
TArray< FString > GetFilenames()
TMap< FString, FConfigFile * > OtherFiles
void SetSingleLineArray(const TCHAR *Section, const TCHAR *Key, const TArray< FString > &In_Arr, const FString &Filename)
void SaveCurrentStateForBootstrap(const TCHAR *Filename)
bool GetVector(const TCHAR *Section, const TCHAR *Key, FVector &Value, const FString &Filename)
static FConfigFile * FindOrLoadPlatformConfig(FConfigFile &LocalFile, const TCHAR *IniName, const TCHAR *Platform=NULL)
FConfigCacheIni(EConfigCacheType Type)
static FString NormalizeConfigIniPath(const FString &NonNormalizedPath)
FConfigFile * FindConfigFile(const FString &Filename)
void SerializeStateForBootstrap_Impl(FArchive &Ar)
bool GetVector2D(const TCHAR *Section, const TCHAR *Key, FVector2D &Value, const FString &Filename)
void SetInt(const TCHAR *Section, const TCHAR *Key, int32 Value, const FString &Filename)
bool GetFloat(const TCHAR *Section, const TCHAR *Key, float &Value, const FString &Filename)
static bool LoadExternalIniFile(FConfigFile &ConfigFile, const TCHAR *IniName, const TCHAR *EngineConfigDir, const TCHAR *SourceConfigDir, bool bIsBaseIniName, const TCHAR *Platform=NULL, bool bForceReload=false, bool bWriteDestIni=false, bool bAllowGeneratedIniWhenCooked=true, const TCHAR *GeneratedConfigDir= *FPaths::GeneratedConfigDir())
bool EmptySectionsMatchingString(const TCHAR *SectionString, const FString &Filename)
static bool LoadLocalIniFile(FConfigFile &ConfigFile, const TCHAR *IniName, bool bIsBaseIniName, const TCHAR *Platform=NULL, bool bForceReload=false)
virtual void ShowMemoryUsage(FOutputDevice &Ar)
bool ContainsConfigFile(const FConfigFile *ConfigFile) const
void Serialize(FArchive &Ar)
bool GetValue(const TCHAR *Section, const TCHAR *Key, FString &Value, const FString &Filename)
bool IsKnownConfigName(FName ConfigName)
static FConfigFile * FindPlatformConfig(const wchar_t *IniName, const wchar_t *Platform)
Definition Other.h:2390
int32 GetArray(const TCHAR *Section, const TCHAR *Key, TArray< FString > &out_Arr, const FString &Filename)
void LoadFile(const FString &InFilename, const FConfigFile *Fallback=NULL, const TCHAR *PlatformString=NULL)
void SetColor(const TCHAR *Section, const TCHAR *Key, FColor Value, const FString &Filename)
FConfigFile & Add(const FString &Filename, const FConfigFile &File)
void Flush(bool bRemoveFromCache, const FString &Filename=TEXT(""))
bool GetVector4(const TCHAR *Section, const TCHAR *Key, FVector4 &Value, const FString &Filename)
bool GetRotator(const TCHAR *Section, const TCHAR *Key, FRotator &Value, const FString &Filename)
bool GetPerObjectConfigSections(const FString &Filename, const FString &SearchClass, TArray< FString > &out_SectionNames, int32 MaxResults=1024)
bool GetInt(const TCHAR *Section, const TCHAR *Key, int32 &Value, const FString &Filename)
static FConfigCacheIni * ForPlatform(FName PlatformName)
void SetFloat(const TCHAR *Section, const TCHAR *Key, float Value, const FString &Filename)
bool GetValue(const TCHAR *Section, const TCHAR *Key, bool &Value, const FString &Filename)
virtual void EnableFileOperations()
FConfigFile * FindConfigFileWithBaseName(FName BaseName)
Definition Other.h:2349
float GetFloatOrDefault(const TCHAR *Section, const TCHAR *Key, const float DefaultValue, const FString &Filename)
void Dump(FOutputDevice &Ar, const TCHAR *IniName=NULL)
FString GetStringOrDefault(const TCHAR *Section, const TCHAR *Key, const FString &DefaultValue, const FString &Filename)
bool GetValue(const TCHAR *Section, const TCHAR *Key, float &Value, const FString &Filename)
static const FString * GetCustomConfigString()
Definition Other.h:2387
bool InitializeKnownConfigFiles(const TCHAR *PlatformName, bool bDefaultEngineIniRequired, const TCHAR *OverrideProjectDir=nullptr)
bool AreFileOperationsDisabled()
Definition Other.h:2345
void Detach(const FString &Filename)
void SetVector2D(const TCHAR *Section, const TCHAR *Key, FVector2D Value, const FString &Filename)
void SetDouble(const TCHAR *Section, const TCHAR *Key, double Value, const FString &Filename)
FString GetStr(const TCHAR *Section, const TCHAR *Key, const FString &Filename)
bool GetString(const TCHAR *Section, const TCHAR *Key, FString &Value, const FString &Filename)
void SetRotator(const TCHAR *Section, const TCHAR *Key, FRotator Value, const FString &Filename)
FConfigSection * GetSectionPrivate(const TCHAR *Section, const bool Force, const bool Const, const FString &Filename)
static void LoadConsoleVariablesFromINI()
void GetConfigFilenames(TArray< FString > &ConfigFilenames)
void SetVector4(const TCHAR *Section, const TCHAR *Key, const FVector4 &Value, const FString &Filename)
bool RemoveKey(const TCHAR *Section, const TCHAR *Key, const FString &Filename)
static FString GetDestIniFilename(const TCHAR *BaseIniName, const TCHAR *PlatformName, const TCHAR *GeneratedConfigDir)
void SetFile(const FString &InFilename, const FConfigFile *NewConfigFile)
virtual ~FConfigCacheIni()
int32 GetIntOrDefault(const TCHAR *Section, const TCHAR *Key, const int32 DefaultValue, const FString &Filename)
static bool InitializeKnownConfigFiles(FConfigContext &Context)
bool DoesSectionExist(const TCHAR *Section, const FString &Filename)
const FString & GetSavedValue() const
static bool CollapseValue(const FString &InExpandedValue, FString &OutCollapsedValue)
friend void operator<<(FStructuredArchive::FSlot Slot, FConfigValue &ConfigSection)
FConfigValue & operator=(FConfigValue &&RHS)
const FString & GetValue() const
FConfigValue(const FString &InValue)
const FString & GetSavedValueForWriting() const
uint32 SavedValueHash
FConfigValue & operator=(const FConfigValue &RHS)
FConfigValue(FString &&InValue)
FConfigValue(FConfigValue &&InConfigValue)
static bool ExpandValue(const FString &InCollapsedValue, FString &OutExpandedValue)
FString ExpandedValue
static FString CollapseValue(const FString &InExpandedValue)
FConfigValue(const TCHAR *InValue)
static FString ExpandValue(const FString &InCollapsedValue)
void ExpandValueInternal()
bool operator!=(const FConfigValue &Other) const
bool operator==(const FConfigValue &Other) const
FConfigValue(const FConfigValue &InConfigValue)
static const FString & GetSavedValueForWriting(const FConfigValue &ConfigValue)