MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / process_characters

Function process_characters

src/ifcparse/parse_ifcxml.cpp:303–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303static void process_characters(void* user, const xmlChar* character, int len) {
304 ifcxml_parse_state* state = (ifcxml_parse_state*)user;
305
306 if (state->file == nullptr) {
307 return;
308 }
309
310 std::string txt((char*)character, len);
311
312 stack_node::node_type state_type = stack_node::stack_empty;
313 if (!state->stack.empty()) {
314 state_type = state->stack.back().ntype();
315 }
316
317 if (!state->stack.empty() && state->stack.back().inst() != nullptr && (state->stack.back().inst()->declaration().as_type_declaration() != nullptr)) {
318 const auto* pt = state->stack.back().inst()->declaration().as_type_declaration()->declared_type();
319 boost::any val;
320 try {
321 val = parse_attribute_value(pt, txt);
322 } catch (const std::exception& e) {
323 Logger::Error(e, state->stack.back().inst());
324 }
325 if (!val.empty()) {
326 // type declaration always at idx 0
327 visit_any([&state](auto& v) {
328 state->stack.back().inst()->set_attribute_value(0, v);
329 }, val);
330 }
331 } else if (state_type == stack_node::node_header_entry) {
332 const std::string tagname = boost::replace_all_copy(state->stack.back().tagname(), "ex:", "");
333 auto& header = state->file->header();
334 if (tagname == "name") {
335 header.file_name()->setname(txt);
336 } else if (tagname == "time_stamp") {
337 header.file_name()->settime_stamp(txt);
338 } else if (tagname == "author") {
339 header.file_name()->setauthor({txt});
340 } else if (tagname == "organization") {
341 header.file_name()->setorganization({txt});
342 } else if (tagname == "preprocessor_version") {
343 header.file_name()->setpreprocessor_version(txt);
344 } else if (tagname == "originating_system") {
345 header.file_name()->setoriginating_system(txt);
346 } else if (tagname == "authorization") {
347 header.file_name()->setauthorization(txt);
348 } else if (tagname == "documentation") {
349 header.file_description()->setdescription({txt});
350 } else {
351 Logger::Error("Unrecognized header entry " + tagname);
352 }
353 } else if (state_type == stack_node::node_instance_attribute) {
354 const auto* pt = state->stack.back().inst()->declaration().as_entity()->attribute_by_index(state->stack.back().idx())->type_of_attribute();
355 auto cpp_type = IfcUtil::from_parameter_type(pt);
356 if (cpp_type != IfcUtil::Argument_ENTITY_INSTANCE) {
357 auto val = parse_attribute_value(pt, txt);
358 if (!val.empty()) {
359 visit_any([&state](auto& v) {
360 state->stack.back().inst()->set_attribute_value(state->stack.back().idx(), v);

Callers

nothing calls this directly

Calls 15

parse_attribute_valueFunction · 0.85
visit_anyFunction · 0.85
ntypeMethod · 0.80
instMethod · 0.80
set_attribute_valueMethod · 0.80
setnameMethod · 0.80
settime_stampMethod · 0.80
setauthorMethod · 0.80
setorganizationMethod · 0.80
setoriginating_systemMethod · 0.80
setauthorizationMethod · 0.80

Tested by

no test coverage detected