# Getting ALL StringTables, their Keys and values?

**URL:** <https://forums.unrealengine.com/t/getting-all-stringtables-their-keys-and-values/2023587>\
**Category:** C++\
**Tags:** String-Tables, tmap, unreal-engine, UE5, CPP, question\
**Created:** [September 16, 2024, 9:44pm UTC](https://forums.unrealengine.com/t/getting-all-stringtables-their-keys-and-values/2023587 "2024-09-16T21:44:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BDC\_Patrick](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bdc_patrick/32/1104221_2.png) [@BDC\_Patrick](https://forums.unrealengine.com/u/BDC_Patrick)\
**Post date:** [September 16, 2024, 9:44pm UTC](https://forums.unrealengine.com/t/getting-all-stringtables-their-keys-and-values/2023587/1 "2024-09-16T21:44:56Z")

</div>

Hi there…

For an Editor Utility, I try to populate Variables with Stuff from StringTables (TMap Keys made by Words of StringTable values as Example…).

To achieve this, i need to  
1st: get ALL String Tables of the project.  
2nd: Check if the StringTable has any Value and the Asset name contains a prefix.  
3rd: read all Keys of a Table into a TArray.  
4th: When iterating the Array of Keys, getting the corresponding values to the Keys.

Now… i may figured out how to load StringTables:

```cpp
TArray<UStringTable*> ULoH_TextCrypter::GatherCryptingTables()
{
    TArray<UStringTable*> FoundTables;
    const FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");

    FARFilter Filter;
    Filter.ClassPaths.Add(UStringTable::StaticClass()->GetClassPathName());
    Filter.bRecursivePaths = true;

    TArray<FAssetData> AssetDataList;
    AssetRegistryModule.Get().GetAssets(Filter, AssetDataList);

    for (const FAssetData& AssetData : AssetDataList)
    {
        if (AssetData.AssetClassPath.ToString().Contains(UStringTable::StaticClass()->GetFName().ToString()))
        {
            if (UStringTable* StringTable = Cast<UStringTable>(AssetData.GetAsset()))
            {
                const FName TableID = StringTable->GetStringTableId();
                
                if (TSharedPtr<const FStringTable> ConstTablePtr = FStringTableRegistry::Get().FindStringTable(TableID); ConstTablePtr.IsValid())
                {
                    int32 KeyCount = ConstTablePtr->; //<<< How?
                    
                    if (AssetData.AssetName.ToString().Contains(TEXT("_crypt_")) && KeyCount > 0)
                    {
                        FoundTables.Add(StringTable);
                    }
                }
            }
        }
    }

    return FoundTables;
}

```

I’m having trouble finding a function to retrieve the keys and values, or even the key-value pairs, from a StringTable. Specifically, neither FStringTable nor UStringTable seems to provide such functionality directly.

Does one have an idea how to get that working?

---

<div class="post-metadata">

**Author:** ![PREDALIEN](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/predalien/32/1194670_2.png) [@PREDALIEN](https://forums.unrealengine.com/u/PREDALIEN)\
**Post date:** [September 16, 2024, 11:11pm UTC](https://forums.unrealengine.com/t/getting-all-stringtables-their-keys-and-values/2023587/2 "2024-09-16T23:11:52Z")

</div>

Looks like **FStringTable::EnumerateSourceStrings** is what you’re looking for.

Here is an example of usage:

```auto
void FStringTableEditor::RefreshCachedStringTable(const FString& InCachedSelection)
{
	CachedStringTableEntries.Reset();

	TSharedPtr<FCachedStringTableEntry> SelectedStringTableEntry;

	UStringTable* StringTable = Cast<UStringTable>(GetEditingObject());
	if (StringTable)
	{
		StringTable->GetStringTable()->EnumerateSourceStrings([&](const FString& InKey, const FString& InSourceString)
		{
			TSharedRef<FCachedStringTableEntry> NewStringTableEntry = MakeShared<FCachedStringTableEntry>(InKey, InSourceString);

			if (EntryTextFilter->PassesFilter(NewStringTableEntry))
			{
				CachedStringTableEntries.Add(NewStringTableEntry);
			}

			if (InCachedSelection.Equals(InKey, ESearchCase::CaseSensitive))
			{
				SelectedStringTableEntry = NewStringTableEntry;
			}

			return true; // continue enumeration
		});
	}

// other code

```
