diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 000000000..80c95570c --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,59 @@ +name: "CMake build" + +on: + push: + pull_request: + workflow_dispatch: + +defaults: + run: + shell: bash + +jobs: + build: + name: ${{ matrix.toolchain }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + toolchain: + - linux-gcc + - macos-clang + - windows-msvc + - windows-mingw + configuration: + - Release + include: + - toolchain: linux-gcc + os: ubuntu-latest + compiler: gcc + - toolchain: macos-clang + os: macos-latest + compiler: clang + - toolchain: windows-msvc + os: windows-latest + compiler: msvc + - toolchain: windows-mingw + os: windows-latest + compiler: mingw + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 5 + - name: Configure (${{ matrix.configuration }}) + run: | + if [ "${{ matrix.compiler }}" == "msvc" ]; then + cmake -S . -B build -DBUILD_VIEWER_APPLICATION=OFF + elif [ "${{ matrix.compiler }}" == "mingw" ]; then + cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DBUILD_VIEWER_APPLICATION=OFF -G "MinGW Makefiles" + else + cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DBUILD_VIEWER_APPLICATION=OFF + fi + - name: Build with ${{ matrix.compiler }} + run: | + if [ "${{ matrix.compiler }}" == "msvc" ]; then + cmake --build build --config ${{ matrix.configuration }} + else + cmake --build build -- -j8 + fi diff --git a/IfcPlusPlus/src/ifcpp/reader/ReaderUtil.cpp b/IfcPlusPlus/src/ifcpp/reader/ReaderUtil.cpp index ff1819906..49f7f7c7a 100644 --- a/IfcPlusPlus/src/ifcpp/reader/ReaderUtil.cpp +++ b/IfcPlusPlus/src/ifcpp/reader/ReaderUtil.cpp @@ -63,6 +63,18 @@ static T convertToHex(unsigned char mc) // return (returnValue); //} +static std::string utf16_to_utf8(const std::u16string& u16str) +{ +#if _MSC_VER >= 1900 + std::wstring_convert, int16_t> convert; + auto p = reinterpret_cast(u16str.data()); + return convert.to_bytes(p, p + u16str.size()); +#else + std::wstring_convert, char16_t> convert; + return convert.to_bytes(u16str); +#endif +} + std::string wstring2string(const std::wstring& wstr) { if (wstr.empty()) return std::string(); @@ -1147,9 +1159,7 @@ void decodeArgumentString(const std::string& argument_str, std::string& arg_out) { combined16[0] = checkAndConvertAppleEncoding(combined16[0]); } - std::u16string u16str(combined16, 1); - std::wstring_convert, char16_t> convert; - std::string utf8 = convert.to_bytes(u16str); + std::string utf8 = utf16_to_utf8(std::u16string(combined16, 1)); arg_str_new += utf8; stream_pos += 5; @@ -1211,9 +1221,7 @@ void decodeArgumentString(const std::string& argument_str, std::string& arg_out) } while ((*stream_pos != '\0')); - std::u16string u16str(reinterpret_cast(&utf16Characters[0]), utf16Characters.size() / 2); - std::wstring_convert, char16_t> convert; - std::string utf8 = convert.to_bytes(u16str); + std::string utf8 = utf16_to_utf8(std::u16string(reinterpret_cast(&utf16Characters[0]), utf16Characters.size() / 2)); arg_str_new += utf8; } continue; diff --git a/IfcPlusPlus/src/ifcpp/reader/ReaderUtil.h b/IfcPlusPlus/src/ifcpp/reader/ReaderUtil.h index e744c8193..3ad7782a7 100644 --- a/IfcPlusPlus/src/ifcpp/reader/ReaderUtil.h +++ b/IfcPlusPlus/src/ifcpp/reader/ReaderUtil.h @@ -32,6 +32,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU #include "ifcpp/IFC4X3/TypeFactory.h" #ifdef _MSC_VER +#include #include #include #pragma warning(disable : 4996) diff --git a/README.md b/README.md index bb651c27a..6bcca3edd 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ for (auto it : currentBuildingStorey->m_IsDecomposedBy_inverse) } ``` Inverse attribute pointers are automatically generated by IFC++ for all object references in the model. - + - casting is possible for all types: ```cpp shared_ptr pset = dynamic_pointer_cast(relatingPropertyDefinition); @@ -42,9 +42,11 @@ for (auto it : currentBuildingStorey->m_IsDecomposedBy_inverse) - Professional support is available for bug fixing or custom implementations on www.ifcquery.com. - +## Status + +[![CMake build](https://github.com/ifcquery/ifcplusplus/actions/workflows/cmake.yml/badge.svg)](https://github.com/ifcquery/ifcplusplus/actions/workflows/cmake.yml) + - ## License The project is published under the MIT license, which means that you can use it for any purpose, personal or commercial. There is no obligation to publish your source code. @@ -60,5 +62,4 @@ https://github.com/ifcquery/ifcplusplus/wiki/Build-instructions ## Screenshot of steel frame model in the example viewer 980 000 entities loaded, 8000 with geometric representation. Loaded in < 4 sec. on a standard PC, including geometry. ![Steel frame model](http://www.ifcquery.com/img/Building-model-steel-frame-2018-02-05.png) - - +