MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / Import

Method Import

modules/tools/tool_core/src/assets/config_asset.cpp:14–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12namespace asset
13{
14void* SJsonConfigImporter::Import(skr_io_ram_service_t* ioService, SCookContext* context)
15{
16 const auto assetRecord = context->GetAssetRecord();
17 auto type = skr::rttr::get_type_from_guid(configType);
18 if (type == nullptr)
19 {
20 SKR_LOG_ERROR(u8"import resource %s failed, rtti is not load", assetRecord->path.u8string().c_str());
21 return nullptr;
22 }
23
24 skr::BlobId blob = nullptr;
25 context->AddFileDependencyAndLoad(ioService, assetPath.c_str(), blob);
26 SKR_DEFER({blob.reset();});
27
28 auto jsonString = simdjson::padded_string((char*)blob->get_data(), blob->get_size());
29 simdjson::ondemand::parser parser;
30 auto doc = parser.iterate(jsonString);
31 if(doc.error())
32 {
33 SKR_LOG_FMT_ERROR(u8"Import config asset {} from {} failed, json parse error {}", assetRecord->guid, assetPath, simdjson::error_message(doc.error()));
34 return nullptr;
35 }
36
37 //skr::resource::SConfigFactory::NewConfig(configType);
38 skr_config_resource_t* resource = SkrNew<skr_config_resource_t>();
39 resource->SetType(configType);
40 type->read_json(resource->configData, doc.get_value().value_unsafe());
41 return resource; //导入具体数据
42}
43
44void SJsonConfigImporter::Destroy(void* resource)
45{

Callers 1

_ImportMethod · 0.45

Calls 14

get_type_from_guidFunction · 0.85
SetTypeMethod · 0.80
padded_stringClass · 0.50
error_messageFunction · 0.50
GetAssetRecordMethod · 0.45
c_strMethod · 0.45
resetMethod · 0.45
get_dataMethod · 0.45
get_sizeMethod · 0.45
iterateMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected