MCPcopy Create free account
hub / github.com/chigraph/chigraph / nodeTypeFromName

Method nodeTypeFromName

libchigraph/src/GraphModule.cpp:761–924  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759}
760
761Result GraphModule::nodeTypeFromName(boost::string_view name, const nlohmann::json& jsonData,
762 std::unique_ptr<NodeType>* toFill) {
763 Result res = {};
764
765 // see if it's a C call
766 if (cEnabled() && name == "c-call") {
767 if (!jsonData.is_object()) {
768 res.addEntry("WUKN", "Data for c-call must be an object", {{"Given Data"}, jsonData});
769 }
770
771 std::string code;
772 if (jsonData.is_object() && jsonData.find("code") != jsonData.end() &&
773 jsonData["code"].is_string()) {
774 code = jsonData["code"];
775 } else {
776 res.addEntry(
777 "WUKN",
778 "Data for c-call must have a pair with the key of code and that the data is a "
779 "string",
780 {{"Given Data"}, jsonData});
781 }
782
783 std::string function;
784 if (jsonData.is_object() && jsonData.find("function") != jsonData.end() &&
785 jsonData["function"].is_string()) {
786 function = jsonData["function"];
787 } else {
788 res.addEntry(
789 "WUKN",
790 "Data for c-call must have a pair with the key of function and that the data is a "
791 "string",
792 {{"Given Data"}, jsonData});
793 }
794
795 std::vector<std::string> extraFlags;
796 if (jsonData.is_object() && jsonData.find("extraflags") != jsonData.end() &&
797 jsonData["extraflags"].is_array()) {
798 for (const auto& flag : jsonData["extraflags"]) {
799 std::string str = flag;
800 extraFlags.emplace_back(std::move(str));
801 }
802 } else {
803 res.addEntry("WUKN", "Data for c-call must have an extraflags array",
804 {{"Given Data"}, jsonData});
805 }
806
807 std::vector<NamedDataType> inputs;
808 if (jsonData.is_object() && jsonData.find("inputs") != jsonData.end() &&
809 jsonData["inputs"].is_array()) {
810 inputs.reserve(jsonData["inputs"].size());
811 for (const auto& jsonArg : jsonData["inputs"]) {
812 std::string docstring, qualifiedName;
813 std::tie(docstring, qualifiedName) = parseObjectPair(jsonArg);
814
815 std::string moduleName, typeName;
816 std::tie(moduleName, typeName) = parseColonPair(qualifiedName);
817
818 DataType ty;

Callers

nothing calls this directly

Calls 10

parseObjectPairFunction · 0.85
parseColonPairFunction · 0.85
is_objectMethod · 0.80
addEntryMethod · 0.80
endMethod · 0.80
is_stringMethod · 0.80
is_arrayMethod · 0.80
typeFromModuleMethod · 0.80
is_nullMethod · 0.80
to_stringMethod · 0.80

Tested by

no test coverage detected