MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / FindIds

Function FindIds

Source/Engine/Content/JsonAsset.cpp:117–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115#if USE_EDITOR
116
117void FindIds(ISerializable::DeserializeStream& node, Array<Guid>& output, Array<String>& files, rapidjson_flax::Value* nodeName = nullptr)
118{
119 if (node.IsObject())
120 {
121 for (auto i = node.MemberBegin(); i != node.MemberEnd(); ++i)
122 {
123 FindIds(i->value, output, files, &i->name);
124 }
125 }
126 else if (node.IsArray())
127 {
128 for (rapidjson::SizeType i = 0; i < node.Size(); i++)
129 {
130 FindIds(node[i], output, files);
131 }
132 }
133 else if (node.IsString() && node.GetStringLength() != 0)
134 {
135 if (node.GetStringLength() == 32)
136 {
137 // Try parse as Guid in format `N` (32 hex chars)
138 Guid id;
139 if (!Guid::Parse(node.GetStringAnsiView(), id))
140 {
141 output.Add(id);
142 return;
143 }
144 }
145 if (node.GetStringLength() < 512 &&
146 (!nodeName || nodeName->GetStringAnsiView() != "ImportPath")) // Ignore path in ImportPath from ModelPrefab (TODO: resave prefabs/scenes before cooking to get rid of editor-only data)
147 {
148 // Try to detect file paths
149 String path = node.GetText();
150 if (FileSystem::FileExists(path))
151 {
152 files.Add(MoveTemp(path));
153 }
154 }
155 }
156}
157
158void JsonAssetBase::GetReferences(const StringAnsiView& json, Array<Guid>& assets)
159{

Callers 1

GetReferencesMethod · 0.85

Calls 7

MemberBeginMethod · 0.80
MemberEndMethod · 0.80
ParseFunction · 0.50
SizeMethod · 0.45
GetStringLengthMethod · 0.45
AddMethod · 0.45
GetTextMethod · 0.45

Tested by

no test coverage detected