MCPcopy Create free account
hub / github.com/assimp/assimp / readInline

Method readInline

code/AssetLib/X3D/X3DImporter_Networking.cpp:70–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68// url="" MFString [inputOutput]
69// />
70void X3DImporter::readInline(XmlNode &node) {
71 std::string def, use;
72 bool load = true;
73 std::list<std::string> url;
74
75 MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
76 XmlParser::getBoolAttribute(node, "load", load);
77 X3DXmlHelper::getStringListAttribute(node, "url", url);
78
79 // if "USE" defined then find already defined element.
80 X3DNodeElementBase *ne = nullptr;
81 if (!use.empty()) {
82 ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne);
83 } else {
84 ParseHelper_Group_Begin(true); // create new grouping element and go deeper if node has children.
85 // at this place new group mode created and made current, so we can name it.
86 if (!def.empty()) mNodeElementCur->ID = def;
87
88 if (load && !url.empty()) {
89 std::string full_path = mpIOHandler->CurrentDirectory() + url.front();
90
91 //full_path = std::regex_replace(full_path, pattern_parentDir, "$1");
92 for (std::string::size_type pos = full_path.find(parentDir); pos != std::string::npos; pos = full_path.find(parentDir, pos)) {
93 if (pos > 0) {
94 std::string::size_type pos2 = full_path.rfind('/', pos - 1);
95 if (pos2 != std::string::npos) {
96 full_path.erase(pos2, pos - pos2 + 3);
97 pos = pos2;
98 } else {
99 full_path.erase(0, pos + 4);
100 pos = 0;
101 }
102 } else {
103 pos += 3;
104 }
105 }
106 // Attribute "url" can contain list of strings. But we need only one - first.
107 std::string::size_type slashPos = full_path.find_last_of("\\/");
108 mpIOHandler->PushDirectory(slashPos == std::string::npos ? std::string() : full_path.substr(0, slashPos + 1));
109 ParseFile(full_path, mpIOHandler);
110 mpIOHandler->PopDirectory();
111 }
112
113 // check for X3DMetadataObject childs.
114 if (!isNodeEmpty(node)) childrenReadMetadata(node, mNodeElementCur, "Inline");
115
116 // exit from node in that place
117 ParseHelper_Node_Exit();
118 } // if(!use.empty()) else
119}
120
121} // namespace Assimp
122

Callers

nothing calls this directly

Calls 5

eraseMethod · 0.80
emptyMethod · 0.45
frontMethod · 0.45
PushDirectoryMethod · 0.45
PopDirectoryMethod · 0.45

Tested by

no test coverage detected