本文整理汇总了C++中FConfigFile::Find方法的典型用法代码示例。如果您正苦于以下问题:C++ FConfigFile::Find方法的具体用法?C++ FConfigFile::Find怎么用?C++ FConfigFile::Find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FConfigFile
的用法示例。
在下文中一共展示了FConfigFile::Find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MigrateConfigSection
void FConfigManifest::MigrateConfigSection(FConfigFile& ConfigFile, const TCHAR* OldSectionName, const TCHAR* NewSectionName)
{
const FConfigSection* OldSection = ConfigFile.Find(OldSectionName);
if (OldSection)
{
FConfigSection* NewSection = ConfigFile.Find(NewSectionName);
if (NewSection)
{
for (auto& Setting : *OldSection)
{
if (!NewSection->Contains(Setting.Key))
{
NewSection->Add(Setting.Key, Setting.Value);
}
}
}
else
{
// Add the new section and remove the old
FConfigSection SectionCopy = *OldSection;
ConfigFile.Add(NewSectionName, MoveTemp(SectionCopy));
ConfigFile.Remove(OldSectionName);
}
ConfigFile.Dirty = true;
}
}
示例2: SetProjectConfigOverrides
void FCrashReportClientConfig::SetProjectConfigOverrides(const FConfigFile& InConfigFile)
{
const FConfigSection* Section = InConfigFile.Find(FGenericCrashContext::ConfigSectionName);
// Default to false (show the option) when config is missing.
bHideLogFilesOption = false;
// Default to true (Allow the user to close without sending) when config is missing.
bIsAllowedToCloseWithoutSending = true;
// Try to read values from override config file
if (Section != nullptr)
{
const FConfigValue* HideLogFilesOptionValue = Section->Find(TEXT("bHideLogFilesOption"));
if (HideLogFilesOptionValue != nullptr)
{
bHideLogFilesOption = FCString::ToBool(*HideLogFilesOptionValue->GetValue());
}
const FConfigValue* IsAllowedToCloseWithoutSendingValue = Section->Find(TEXT("bIsAllowedToCloseWithoutSending"));
if (IsAllowedToCloseWithoutSendingValue != nullptr)
{
bIsAllowedToCloseWithoutSending = FCString::ToBool(*IsAllowedToCloseWithoutSendingValue->GetValue());
}
}
}
示例3: GetStoredValue
bool FGenericPlatformMisc::GetStoredValue(const FString& InStoreId, const FString& InSectionName, const FString& InKeyName, FString& OutValue)
{
check(!InStoreId.IsEmpty());
check(!InSectionName.IsEmpty());
check(!InKeyName.IsEmpty());
// This assumes that FPlatformProcess::ApplicationSettingsDir() returns a user-specific directory; it doesn't on Windows, but Windows overrides this behavior to use the registry
const FString ConfigPath = FString(FPlatformProcess::ApplicationSettingsDir()) / InStoreId / FString(TEXT("KeyValueStore.ini"));
FConfigFile ConfigFile;
ConfigFile.Read(ConfigPath);
const FConfigSection* const Section = ConfigFile.Find(InSectionName);
if(Section)
{
const FString* const KeyValue = Section->Find(*InKeyName);
if(KeyValue)
{
OutValue = *KeyValue;
return true;
}
}
return false;
}
示例4: Main
int32 UGatherTextCommandlet::Main( const FString& Params )
{
const TCHAR* Parms = *Params;
TArray<FString> Tokens;
TArray<FString> Switches;
TMap<FString, FString> ParamVals;
UCommandlet::ParseCommandLine(*Params, Tokens, Switches, ParamVals);
// find the file corresponding to this object's loc file, loading it if necessary
FString GatherTextConfigPath;
const FString* ParamVal = ParamVals.Find(FString(TEXT("Config")));
if (ParamVal)
{
GatherTextConfigPath = *ParamVal;
}
else
{
UE_LOG(LogGatherTextCommandlet, Error, TEXT("-Config not specified.\n%s"), *UsageText);
return -1;
}
if(FPaths::IsRelative(GatherTextConfigPath))
{
FString ProjectBasePath;
if (!FPaths::GameDir().IsEmpty())
{
ProjectBasePath = FPaths::GameDir();
}
else
{
ProjectBasePath = FPaths::EngineDir();
}
GatherTextConfigPath = FPaths::Combine( *ProjectBasePath, *GatherTextConfigPath );
}
GConfig->LoadFile(*GatherTextConfigPath);
FConfigFile* ConfigFile = GConfig->FindConfigFile(*GatherTextConfigPath);
if( NULL == ConfigFile )
{
UE_LOG(LogGatherTextCommandlet, Error, TEXT("Loading Config File \"%s\" failed."), *GatherTextConfigPath);
return -1;
}
const bool bEnableSourceControl = Switches.Contains(TEXT("EnableSCC"));
const bool bDisableSubmit = Switches.Contains(TEXT("DisableSCCSubmit"));
UE_LOG(LogGatherTextCommandlet, Log,TEXT("Beginning GatherText Commandlet."));
TSharedPtr< FGatherTextSCC > CommandletSourceControlInfo = nullptr;
if( bEnableSourceControl )
{
CommandletSourceControlInfo = MakeShareable( new FGatherTextSCC() );
FText SCCErrorStr;
if( !CommandletSourceControlInfo->IsReady( SCCErrorStr ) )
{
UE_LOG( LogGatherTextCommandlet, Error, TEXT("Source Control error: %s"), *SCCErrorStr.ToString() );
return -1;
}
}
// Basic helper that can be used only to gather a new manifest for writing
TSharedRef<FLocTextHelper> CommandletGatherManifestHelper = MakeShareable(new FLocTextHelper(MakeShareable(new FLocFileSCCNotifies(CommandletSourceControlInfo))));
CommandletGatherManifestHelper->LoadManifest(ELocTextHelperLoadFlags::Create);
int32 NumSteps = (ConfigFile->Find("CommonSettings") != NULL) ? ConfigFile->Num() - 1 : ConfigFile->Num();
//Execute each step defined in the config file.
for( int32 i=0; i<NumSteps ; ++i )
{
FString SectionName = FString::Printf(TEXT("GatherTextStep%d"),i);
FConfigSection* CurrCommandletSection = ConfigFile->Find(SectionName);
if( NULL == CurrCommandletSection )
{
UE_LOG(LogGatherTextCommandlet, Error, TEXT("Could not find %s"),*SectionName);
continue;
}
FString CommandletClassName = GConfig->GetStr( *SectionName, TEXT("CommandletClass"), GatherTextConfigPath ) + TEXT("Commandlet");
UClass* CommandletClass = FindObject<UClass>(ANY_PACKAGE,*CommandletClassName,false);
if (!CommandletClass)
{
UE_LOG(LogGatherTextCommandlet, Error,TEXT("The commandlet name %s in section %s is invalid."), *CommandletClassName, *SectionName);
continue;
}
UGatherTextCommandletBase* Commandlet = NewObject<UGatherTextCommandletBase>(GetTransientPackage(), CommandletClass);
check(Commandlet);
Commandlet->AddToRoot();
Commandlet->Initialize( CommandletGatherManifestHelper, CommandletSourceControlInfo );
// Execute the commandlet.
double CommandletExecutionStartTime = FPlatformTime::Seconds();
UE_LOG(LogGatherTextCommandlet, Log,TEXT("Executing %s: %s"), *SectionName, *CommandletClassName);
//.........这里部分代码省略.........
示例5: EnumerateProjectsKnownByEngine
bool FDesktopPlatformBase::EnumerateProjectsKnownByEngine(const FString &Identifier, bool bIncludeNativeProjects, TArray<FString> &OutProjectFileNames)
{
// Get the engine root directory
FString RootDir;
if (!GetEngineRootDirFromIdentifier(Identifier, RootDir))
{
return false;
}
FString GameAgnosticConfigDir = GetEngineSavedConfigDirectory(Identifier);
if (GameAgnosticConfigDir.Len() == 0)
{
return false;
}
// Find all the created project directories. Start with the default project creation path.
TArray<FString> SearchDirectories;
SearchDirectories.AddUnique(GetDefaultProjectCreationPath());
// Load the config file
FConfigFile GameAgnosticConfig;
FConfigCacheIni::LoadExternalIniFile(GameAgnosticConfig, TEXT("EditorSettings"), NULL, *GameAgnosticConfigDir, false);
// Find the editor game-agnostic settings
FConfigSection* Section = GameAgnosticConfig.Find(TEXT("/Script/UnrealEd.EditorSettings"));
if (Section == NULL)
{
FConfigCacheIni::LoadExternalIniFile(GameAgnosticConfig, TEXT("EditorGameAgnostic"), NULL, *GameAgnosticConfigDir, false);
Section = GameAgnosticConfig.Find(TEXT("/Script/UnrealEd.EditorGameAgnosticSettings"));
}
if(Section != NULL)
{
// Add in every path that the user has ever created a project file. This is to catch new projects showing up in the user's project folders
TArray<FString> AdditionalDirectories;
Section->MultiFind(TEXT("CreatedProjectPaths"), AdditionalDirectories);
for(int Idx = 0; Idx < AdditionalDirectories.Num(); Idx++)
{
FPaths::NormalizeDirectoryName(AdditionalDirectories[Idx]);
SearchDirectories.AddUnique(AdditionalDirectories[Idx]);
}
// Also add in all the recently opened projects
TArray<FString> RecentlyOpenedFiles;
Section->MultiFind(TEXT("RecentlyOpenedProjectFiles"), RecentlyOpenedFiles);
for(int Idx = 0; Idx < RecentlyOpenedFiles.Num(); Idx++)
{
FPaths::NormalizeFilename(RecentlyOpenedFiles[Idx]);
OutProjectFileNames.AddUnique(RecentlyOpenedFiles[Idx]);
}
}
// Find all the other projects that are in the search directories
for(int Idx = 0; Idx < SearchDirectories.Num(); Idx++)
{
TArray<FString> ProjectFolders;
IFileManager::Get().FindFiles(ProjectFolders, *(SearchDirectories[Idx] / TEXT("*")), false, true);
for(int32 FolderIdx = 0; FolderIdx < ProjectFolders.Num(); FolderIdx++)
{
TArray<FString> ProjectFiles;
IFileManager::Get().FindFiles(ProjectFiles, *(SearchDirectories[Idx] / ProjectFolders[FolderIdx] / TEXT("*.uproject")), true, false);
for(int32 FileIdx = 0; FileIdx < ProjectFiles.Num(); FileIdx++)
{
OutProjectFileNames.AddUnique(SearchDirectories[Idx] / ProjectFolders[FolderIdx] / ProjectFiles[FileIdx]);
}
}
}
// Find all the native projects, and either add or remove them from the list depending on whether we want native projects
const FUProjectDictionary &Dictionary = GetCachedProjectDictionary(RootDir);
if(bIncludeNativeProjects)
{
TArray<FString> NativeProjectPaths = Dictionary.GetProjectPaths();
for(int Idx = 0; Idx < NativeProjectPaths.Num(); Idx++)
{
if(!NativeProjectPaths[Idx].Contains(TEXT("/Templates/")))
{
OutProjectFileNames.AddUnique(NativeProjectPaths[Idx]);
}
}
}
else
{
TArray<FString> NativeProjectPaths = Dictionary.GetProjectPaths();
for(int Idx = 0; Idx < NativeProjectPaths.Num(); Idx++)
{
OutProjectFileNames.Remove(NativeProjectPaths[Idx]);
}
}
return true;
}
示例6: if
void UInternationalizationConditioningCommandlet::FLocalizationFile::CompareToCounterpart( TSharedPtr<FLocalizationFile> Other )
{
check(Other.IsValid());
FConfigFile* OtherFile = Other->GetFile();
check(Other.IsValid());
check(LocFile != NULL);
// Iterate through all sections in the loc file
for ( FConfigFile::TIterator SectionIt(*LocFile); SectionIt; ++SectionIt )
{
const FString& LocSectionName = SectionIt.Key();
FConfigSection& MySection = SectionIt.Value();
// Skip the [Language] and [Public] sections
if( LocSectionName == TEXT("Language") || LocSectionName == TEXT("Public") )
{
continue;
}
// Find this section in the counterpart loc file
FConfigSection* OtherSection = OtherFile->Find(LocSectionName);
if ( OtherSection != NULL )
{
// Iterate through all keys in this section
for ( FConfigSection::TIterator It(MySection); It; ++It )
{
const FName Propname = It.Key();
const FString& PropValue = It.Value();
FString EscapedPropValue = PropValue.ReplaceQuotesWithEscapedQuotes();
// Find this key in the counterpart loc file
FString* OtherValue = OtherSection->Find(Propname);
if ( OtherValue != NULL )
{
FString EscapedOtherValue = *OtherValue->ReplaceQuotesWithEscapedQuotes();
// If the counterpart has the same value as we do or is empty, the value is untranslated
if( OtherValue->IsEmpty() )
{
// If the entry is empty we do nothing for the time being.
}
else if ( PropValue == *OtherValue )
{
new(IdenticalProperties) FLocalizationFileEntry( Other->GetFilename(), LocSectionName, Propname.ToString(), EscapedPropValue, EscapedPropValue );
}
else
{
new(TranslatedProperties) FLocalizationFileEntry( Other->GetFilename(), LocSectionName, Propname.ToString(), EscapedPropValue, EscapedOtherValue );
}
}
else
{
// The counterpart didn't contain this key
new(UnmatchedProperties) FString(LocSectionName + TEXT(".") + Propname.ToString());
}
}
}
else
{
// The counterpart didn't contain this section
new(UnmatchedSections) FString(FPaths::GetBaseFilename(LocFilename) + TEXT(".") + LocSectionName);
}
}
}