MCPcopy Create free account
hub / github.com/NotYetGames/DlgSystem / ReadMap

Method ReadMap

Source/DlgSystem/Private/IO/DlgConfigParser.cpp:584–646  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

582
583////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
584bool FDlgConfigParser::ReadMap(void* TargetObject, FMapProperty& Property, UObject* DefaultObjectOuter)
585{
586 FScriptMapHelper Helper(&Property, Property.ContainerPtrToValuePtr<uint8>(TargetObject));
587 Helper.EmptyValues();
588
589 if (!FindNextWordAndCheckIfBlockStart("Map block") || !FindNextWord("map entry"))
590 {
591 return false;
592 }
593
594 while (!CheckIfBlockEnd("Map block"))
595 {
596 const int32 Index = Helper.AddDefaultValue_Invalid_NeedsRehash();
597 void* Ptrs[] = { Helper.GetKeyPtr(Index), Helper.GetValuePtr(Index) };
598 FProperty* Props[] = { Helper.KeyProp, Helper.ValueProp };
599 bool bDone = false;
600
601 for (int32 i = 0; i < 2; ++i)
602 {
603 if (FNYReflectionHelper::CastProperty<FBoolProperty>(Props[i])) { *(bool*)Ptrs[i] = GetAsBool(); bDone = true; }
604 else if (FNYReflectionHelper::CastProperty<FFloatProperty>(Props[i])) { *(float*)Ptrs[i] = GetAsFloat(); bDone = true; }
605 else if (FNYReflectionHelper::CastProperty<FIntProperty>(Props[i])) { *(int32*)Ptrs[i] = GetAsInt32(); bDone = true; }
606 else if (FNYReflectionHelper::CastProperty<FInt64Property>(Props[i])) { *(int64*)Ptrs[i] = GetAsInt64(); bDone = true; }
607 else if (FNYReflectionHelper::CastProperty<FNameProperty>(Props[i])) { *(FName*)Ptrs[i] = GetAsName(); bDone = true; }
608 else if (FNYReflectionHelper::CastProperty<FStrProperty>(Props[i])) { *(FString*)Ptrs[i] = GetAsString(); bDone = true; }
609 else if (FNYReflectionHelper::CastProperty<FTextProperty>(Props[i])) { *(FText*)Ptrs[i] = GetAsText(); bDone = true; }
610 else if (i == 1 && bHasNullptr) { bDone = true; } // Value is nullptr, ignore
611 // else if (FNYReflectionHelper::CastProperty<FByteProperty>(Props[i])) { *(uint8*)Ptrs[i] = OnGetAsEnum(); bDone = true; } // would not work, check enum above
612
613 auto* StructVal = FNYReflectionHelper::CastProperty<FStructProperty>(Props[i]);
614 if (StructVal != nullptr)
615 {
616 if (!CompareToActiveWord("{"))
617 {
618 UE_LOG(LogDlgConfigParser, Warning, TEXT("Syntax error: missing struct block start '{' in script %s(:%d)"),
619 *FileName, GetActiveLineNumber());
620 return false;
621 }
622 if (!ReadPurePropertyBlock(Ptrs[i], StructVal->Struct, true, DefaultObjectOuter))
623 {
624 return false;
625 }
626 }
627 else
628 {
629 if (!bDone)
630 {
631 UE_LOG(LogDlgConfigParser, Warning, TEXT("Invalid map type %s in script `%s` (:%d)"), *Helper.KeyProp->GetName(), *FileName, GetActiveLineNumber());
632 return false;
633 }
634 bDone = false;
635 if (!FindNextWord("Map Key or Value or End"))
636 {
637 return false;
638 }
639 }
640 }
641 Helper.Rehash();

Callers

nothing calls this directly

Calls 1

GetNameMethod · 0.45

Tested by

no test coverage detected