Skip to content

Commit

Permalink
Merge pull request #1037 from ThatOpen/StringDeocding
Browse files Browse the repository at this point in the history
String deocding
  • Loading branch information
beachtom authored Sep 19, 2024
2 parents b42ebb9 + 98e7b03 commit ee7c979
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/cpp/web-ifc-wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#include "modelmanager/ModelManager.h"
#include "version.h"

namespace webifc::parsing {
void p21encode(std::string_view input, std::ostringstream &output);
std::string p21decode(std::string_view & str);
}

#ifdef __EMSCRIPTEN_PTHREADS__
constexpr bool MT_ENABLED = true;
Expand Down Expand Up @@ -705,6 +709,18 @@ void SetLogLevel(uint8_t levelArg) {
manager.SetLogLevel(levelArg);
}

std::string EncodeText(std::string text) {
const std::string_view strView{text};
std::ostringstream output;
webifc::parsing::p21encode(strView,output);
return output.str();
}

std::string DecodeText(std::string text) {
std::string_view strView{text};
return webifc::parsing::p21decode(strView);
}

EMSCRIPTEN_BINDINGS(my_module) {

emscripten::class_<webifc::geometry::IfcGeometry>("IfcGeometry")
Expand Down Expand Up @@ -839,4 +855,6 @@ EMSCRIPTEN_BINDINGS(my_module) {
emscripten::function("IsIfcElement", &IsIfcElement);
emscripten::function("GetVersion", &GetVersion);
emscripten::function("CloseAllModels", &CloseAllModels);
emscripten::function("DecodeText", &DecodeText);
emscripten::function("EncodeText", &EncodeText);
}
21 changes: 21 additions & 0 deletions src/ts/web-ifc-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1099,4 +1099,25 @@ export class IfcAPI {
Log.setLogLevel(level);
this.wasmModule.SetLogLevel(level);
}

/**
* Encodes test using IFC Encoding
* @text the text to encode
* @returns the text encoded
*/

EncodeText(text:string) {
return this.wasmModule.EncodeText(text);
}

/**
* Decodes test using IFC Encoding
* @text the text to decode
* @returns the text decoded
*/

DecodeText(text: string) {
return this.wasmModule.DecodeText(text);
}

}
2 changes: 1 addition & 1 deletion tests/regression/results.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"tests/ifcfiles/public/AC20-FZK-Haus.ifc":"ee2229c93b5e05099fd84f05cbe88f3a8fce93df56ab3a9c3203196ce775bf64","tests/ifcfiles/public/C20-Institute-Var-2.ifc":"cca012e9b5099de8df0c0e994cc5838d27fea9b7d942c3ef6d27eeed25461b82","tests/ifcfiles/public/FM_ARC_DigitalHub.ifc":"a89f69d3da8ad2e79c59af06ab5f482fc7dbbb7072675318bda659949b88fc05","tests/ifcfiles/public/ISSUE_005_haus.ifc":"ee2229c93b5e05099fd84f05cbe88f3a8fce93df56ab3a9c3203196ce775bf64","tests/ifcfiles/public/ISSUE_021_Mini Project.ifc":"095df6e92a880b16f758d3ecea9ae5ed026d5ab351d8d1c164a1091408c1dffd","tests/ifcfiles/public/ISSUE_034_HouseZ.ifc":"d5ebbcd113665a782031de18a453fa0747f9356e165f9225ea9c0fe7ecfb9350","tests/ifcfiles/public/ISSUE_044_test_IFCCOMPOSITEPROFILEDEF.ifc":"0a656ede479fe659631b13830f01c9a5e5ac5f907778c2324906129d0aef6ed7","tests/ifcfiles/public/ISSUE_053_20181220Holter_Tower_10.ifczip":"be64d8a81c0a7fc24b8c9d394bfc5cfcafcf5af4e26b8cb2919b778f42401a08","tests/ifcfiles/public/ISSUE_068_ARK_NUS_skolebygg.ifc":"4cf82d22e74d854687a76f7385a619825d1df61ff3c44ac73063f38ec3dd35dd","tests/ifcfiles/public/ISSUE_102_M3D-CON-CD.ifc":"e971d9c3c8d36d81b95edc469fb74dd61d633da42494d2f3f01d914457375522","tests/ifcfiles/public/ISSUE_102_M3D-CON.ifc":"a44123781b8dfbf02722da43e51f187fb5899fbfd54b83252fc03212903daf9a","tests/ifcfiles/public/ISSUE_126_model.ifc":"479a790e47380a3f2df805d695b10b950bc4469512bf7c66edc35713e03225e9","tests/ifcfiles/public/ISSUE_129_N1540_17_EXE_MOD_448200_02_09_11SMC_IGC_V17.ifc":"949cfedf430c3db965305384a7dcd10e5f3f5a1a86fd1efb0e3a5940083c6537","tests/ifcfiles/public/ISSUE_159_kleine_Wohnung_R22.ifc":"28495a5e662fb944c44069dec040aab7a9152e134eec284031b8c8464c2ad0fe","tests/ifcfiles/public/ISSUE_171_IfcSurfaceCurveSweptAreaSolid.ifc":"9472e564caedad9683e5d494a8441c02fa28adc3e0d1b1b468516677164219e1","tests/ifcfiles/public/IfcOpenHouse_IFC4.ifc":"9ad24c42d46cc7ade14a458cefad87ca66da1d5fb43e9e0aaf335a0ee59468a9","tests/ifcfiles/public/KIT-Simple-Road-Test-Web-IFC4x3_RC2.ifc":"c79460e22c21911190f029754908887ce95ef8cff6f22fc4381b261a54607257","tests/ifcfiles/public/Office_A_20110811.ifc":"637d18fc55b61d6be4a421b4768683c85c0a787ff50ef0dbdc8c25af9c6553a2","tests/ifcfiles/public/S_Office_Integrated Design Archi.ifc":"7d8b6dbb845c71fc70718756705f7b1e338ae13b44fd8b3e65e4a4b65d2ac9e9","tests/ifcfiles/public/Sample_entities.ifc":"ac57704667f0b32786fd4828db528c3840c900c2a33780a7c1936490b695e90d","tests/ifcfiles/public/advanced_model.ifc":"af897ee98c934b7f3f7226f3737927f7035d4d57ee42d2fcde7327c427208328","tests/ifcfiles/public/dental_clinic.ifc":"3762a95c075343906624b2f25015e375ae5e05d723af7b93a515b96d59a34c79","tests/ifcfiles/public/duplex.ifc":"548222c29439966cbb3ef5b7537589cd3b72ce11b05ccf03fa1f77f26d52a5a3","tests/ifcfiles/public/example.ifc":"7f85a12d72605322bd54c13209a90f670faa14cc70581dec7c628ea96eaa6a10","tests/ifcfiles/public/ifcbridge-model01.ifc":"edd9b70e659df5da1d058f87aa547e0c366453f1a9c9979450bdd45268cb0bdb","tests/ifcfiles/public/schependomlaan.ifc":"8e4e52aaedb952728fcc07041cb71a2ed9f5fdebc9c8c68ce11009851f41657e","tests/ifcfiles/public/tested_sample_project.ifc":"24c12ff9f9333cc92032c7bb82d836621de7a7ff49799487232455e1084c92c0"}
{"tests/ifcfiles/public/AC20-FZK-Haus.ifc":"ee2229c93b5e05099fd84f05cbe88f3a8fce93df56ab3a9c3203196ce775bf64","tests/ifcfiles/public/C20-Institute-Var-2.ifc":"cca012e9b5099de8df0c0e994cc5838d27fea9b7d942c3ef6d27eeed25461b82","tests/ifcfiles/public/FM_ARC_DigitalHub.ifc":"d87e8a394ce783a543f87b50fb036b09721c86eac3c58bb083850a5cc293a1f1","tests/ifcfiles/public/ISSUE_005_haus.ifc":"ee2229c93b5e05099fd84f05cbe88f3a8fce93df56ab3a9c3203196ce775bf64","tests/ifcfiles/public/ISSUE_021_Mini Project.ifc":"095df6e92a880b16f758d3ecea9ae5ed026d5ab351d8d1c164a1091408c1dffd","tests/ifcfiles/public/ISSUE_034_HouseZ.ifc":"d5ebbcd113665a782031de18a453fa0747f9356e165f9225ea9c0fe7ecfb9350","tests/ifcfiles/public/ISSUE_044_test_IFCCOMPOSITEPROFILEDEF.ifc":"0a656ede479fe659631b13830f01c9a5e5ac5f907778c2324906129d0aef6ed7","tests/ifcfiles/public/ISSUE_053_20181220Holter_Tower_10.ifczip":"be64d8a81c0a7fc24b8c9d394bfc5cfcafcf5af4e26b8cb2919b778f42401a08","tests/ifcfiles/public/ISSUE_068_ARK_NUS_skolebygg.ifc":"4cf82d22e74d854687a76f7385a619825d1df61ff3c44ac73063f38ec3dd35dd","tests/ifcfiles/public/ISSUE_102_M3D-CON-CD.ifc":"e971d9c3c8d36d81b95edc469fb74dd61d633da42494d2f3f01d914457375522","tests/ifcfiles/public/ISSUE_102_M3D-CON.ifc":"a44123781b8dfbf02722da43e51f187fb5899fbfd54b83252fc03212903daf9a","tests/ifcfiles/public/ISSUE_126_model.ifc":"479a790e47380a3f2df805d695b10b950bc4469512bf7c66edc35713e03225e9","tests/ifcfiles/public/ISSUE_129_N1540_17_EXE_MOD_448200_02_09_11SMC_IGC_V17.ifc":"509ca895b4cd6995e01be565aee3e6b46d1eb8d924ce50d98f6968d324c49765","tests/ifcfiles/public/ISSUE_159_kleine_Wohnung_R22.ifc":"be00a4269c83f052f5f569e3f35902e0b8e3d7a62b533dc48cf7306fdaacb6b3","tests/ifcfiles/public/ISSUE_171_IfcSurfaceCurveSweptAreaSolid.ifc":"9472e564caedad9683e5d494a8441c02fa28adc3e0d1b1b468516677164219e1","tests/ifcfiles/public/IfcOpenHouse_IFC4.ifc":"9ad24c42d46cc7ade14a458cefad87ca66da1d5fb43e9e0aaf335a0ee59468a9","tests/ifcfiles/public/KIT-Simple-Road-Test-Web-IFC4x3_RC2.ifc":"c79460e22c21911190f029754908887ce95ef8cff6f22fc4381b261a54607257","tests/ifcfiles/public/Office_A_20110811.ifc":"8b8e6ae79df9eb89a0fe091ed3c9319fd19bd73229e24d4b960fa5d3197f02f0","tests/ifcfiles/public/S_Office_Integrated Design Archi.ifc":"7d8b6dbb845c71fc70718756705f7b1e338ae13b44fd8b3e65e4a4b65d2ac9e9","tests/ifcfiles/public/Sample_entities.ifc":"ac57704667f0b32786fd4828db528c3840c900c2a33780a7c1936490b695e90d","tests/ifcfiles/public/advanced_model.ifc":"af897ee98c934b7f3f7226f3737927f7035d4d57ee42d2fcde7327c427208328","tests/ifcfiles/public/dental_clinic.ifc":"3762a95c075343906624b2f25015e375ae5e05d723af7b93a515b96d59a34c79","tests/ifcfiles/public/duplex.ifc":"548222c29439966cbb3ef5b7537589cd3b72ce11b05ccf03fa1f77f26d52a5a3","tests/ifcfiles/public/example.ifc":"7f85a12d72605322bd54c13209a90f670faa14cc70581dec7c628ea96eaa6a10","tests/ifcfiles/public/ifcbridge-model01.ifc":"edd9b70e659df5da1d058f87aa547e0c366453f1a9c9979450bdd45268cb0bdb","tests/ifcfiles/public/schependomlaan.ifc":"8e4e52aaedb952728fcc07041cb71a2ed9f5fdebc9c8c68ce11009851f41657e","tests/ifcfiles/public/tested_sample_project.ifc":"24c12ff9f9333cc92032c7bb82d836621de7a7ff49799487232455e1084c92c0"}

0 comments on commit ee7c979

Please sign in to comment.