| 473 | } |
| 474 | |
| 475 | bool WriteSet(uint32_t modelID, emscripten::val &val) |
| 476 | { |
| 477 | bool responseCode = true; |
| 478 | auto loader = manager.GetIfcLoader(modelID); |
| 479 | loader->Push<uint8_t>(webifc::parsing::IfcTokenType::SET_BEGIN); |
| 480 | |
| 481 | uint32_t size = val["length"].as<uint32_t>(); |
| 482 | for (size_t i = 0; i < size; i++) |
| 483 | { |
| 484 | emscripten::val child = val[std::to_string(i)]; |
| 485 | if (child.isNull()) |
| 486 | loader->Push<uint8_t>(webifc::parsing::IfcTokenType::EMPTY); |
| 487 | else if (child.isUndefined()) |
| 488 | loader->Push<uint8_t>(webifc::parsing::IfcTokenType::UNKNOWN); |
| 489 | else if (child.isArray()) |
| 490 | WriteSet(modelID, child); |
| 491 | else if (child["value"].isArray()) |
| 492 | { |
| 493 | emscripten::val innerVal = child["value"]; |
| 494 | webifc::parsing::IfcTokenType type = static_cast<webifc::parsing::IfcTokenType>(child["type"].as<uint32_t>()); |
| 495 | loader->Push(webifc::parsing::IfcTokenType::SET_BEGIN); |
| 496 | uint32_t sz = innerVal["length"].as<uint32_t>(); |
| 497 | for (size_t z = 0; z < sz; z++) |
| 498 | { |
| 499 | loader->Push<uint8_t>(type); |
| 500 | if (type == webifc::parsing::IfcTokenType::INTEGER) |
| 501 | { |
| 502 | int value = innerVal[std::to_string(z)].as<int>(); |
| 503 | loader->PushInt(value); |
| 504 | } |
| 505 | else |
| 506 | { |
| 507 | double value = innerVal[std::to_string(z)].as<double>(); |
| 508 | loader->PushDouble(value); |
| 509 | } |
| 510 | } |
| 511 | loader->Push(webifc::parsing::IfcTokenType::SET_END); |
| 512 | } |
| 513 | else if (child["type"].isNumber()) |
| 514 | { |
| 515 | webifc::parsing::IfcTokenType type = static_cast<webifc::parsing::IfcTokenType>(child["type"].as<uint32_t>()); |
| 516 | loader->Push(type); |
| 517 | switch (type) |
| 518 | { |
| 519 | case webifc::parsing::IfcTokenType::LINE_END: |
| 520 | case webifc::parsing::IfcTokenType::EMPTY: |
| 521 | case webifc::parsing::IfcTokenType::SET_BEGIN: |
| 522 | case webifc::parsing::IfcTokenType::SET_END: |
| 523 | { |
| 524 | // ignore, we should not be seeing this |
| 525 | break; |
| 526 | } |
| 527 | case webifc::parsing::IfcTokenType::UNKNOWN: |
| 528 | { |
| 529 | // ignore, already pushed above, no further data |
| 530 | break; |
| 531 | } |
| 532 | case webifc::parsing::IfcTokenType::LABEL: |
no test coverage detected