MCPcopy Create free account
hub / github.com/Snapchat/Valdi / parse

Method parse

valdi/src/valdi/runtime/Resources/Bundle.cpp:40–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40Result<Ref<ModuleLoadStrategy>> ModuleLoadStrategy::parse(const Byte* data, size_t length) {
41 auto result = jsonToValue(data, length);
42 if (!result) {
43 return result.moveError();
44 }
45
46 SimpleExceptionTracker exceptionTracker;
47 auto map = result.value().checkedTo<Ref<ValueMap>>(exceptionTracker);
48 if (!exceptionTracker) {
49 return exceptionTracker.extractError();
50 }
51
52 FlatMap<StringBox, ComponentLoadStrategy> strategies;
53
54 for (const auto& it : *map) {
55 auto& strategy = strategies[it.first];
56
57 auto moduleNamesValue = it.second.getMapValue("valdi_modules");
58 auto moduleNamesArray = moduleNamesValue.checkedTo<Ref<ValueArray>>(exceptionTracker);
59 if (!exceptionTracker) {
60 return exceptionTracker.extractError();
61 }
62
63 for (const auto& moduleName : *moduleNamesArray) {
64 strategy.valdiModules.emplace_back(moduleName.toStringBox());
65 }
66 }
67
68 return makeShared<ModuleLoadStrategy>(std::move(strategies));
69}
70
71BundleInitializer::BundleInitializer(Bundle* bundle) : _bundle(strongSmallRef(bundle)), _lock(bundle->_mutex) {}
72BundleInitializer::~BundleInitializer() {

Callers

nothing calls this directly

Calls 5

extractErrorMethod · 0.80
getMapValueMethod · 0.80
valueMethod · 0.65
jsonToValueFunction · 0.50
toStringBoxMethod · 0.45

Tested by

no test coverage detected