comparison OrthancFramework/Sources/Toolbox.cpp @ 5257:0b183bb77c83

Avoid the use of "externalproject_add()" to build the sample plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Apr 2023 11:54:08 +0200
parents 0ea402b4d901
children f66b8d70917e
comparison
equal deleted inserted replaced
5252:742448a9b600 5257:0b183bb77c83
34 34
35 #if !defined(JSONCPP_VERSION_MAJOR) || !defined(JSONCPP_VERSION_MINOR) 35 #if !defined(JSONCPP_VERSION_MAJOR) || !defined(JSONCPP_VERSION_MINOR)
36 # error Cannot access the version of JsonCpp 36 # error Cannot access the version of JsonCpp
37 #endif 37 #endif
38 38
39 #if !defined(ORTHANC_ENABLE_ICU)
40 # define ORTHANC_ENABLE_ICU 1
41 #endif
42
39 43
40 /** 44 /**
41 * We use deprecated "Json::Reader", "Json::StyledWriter" and 45 * We use deprecated "Json::Reader", "Json::StyledWriter" and
42 * "Json::FastWriter" if JsonCpp < 1.7.0. This choice is rather 46 * "Json::FastWriter" if JsonCpp < 1.7.0. This choice is rather
43 * arbitrary, but if Json >= 1.9.0, gcc generates explicit deprecation 47 * arbitrary, but if Json >= 1.9.0, gcc generates explicit deprecation
140 # include <uuid/uuid.h> 144 # include <uuid/uuid.h>
141 #endif 145 #endif
142 } 146 }
143 147
144 148
145 #if defined(ORTHANC_STATIC_ICU) 149 #if defined(ORTHANC_STATIC_ICU) && (ORTHANC_ENABLE_ICU == 1)
146 # if (ORTHANC_STATIC_ICU == 1 && ORTHANC_ENABLE_LOCALE == 1) 150 # if (ORTHANC_STATIC_ICU == 1 && ORTHANC_ENABLE_LOCALE == 1)
147 # include <OrthancFrameworkResources.h> 151 # include <OrthancFrameworkResources.h>
148 # include <unicode/udata.h> 152 # include <unicode/udata.h>
149 # include <unicode/uloc.h> 153 # include <unicode/uloc.h>
150 # include "Compression/GzipCompressor.h" 154 # include "Compression/GzipCompressor.h"
624 std::string Toolbox::ConvertToUtf8(const std::string& source, 628 std::string Toolbox::ConvertToUtf8(const std::string& source,
625 Encoding sourceEncoding, 629 Encoding sourceEncoding,
626 bool hasCodeExtensions) 630 bool hasCodeExtensions)
627 { 631 {
628 #if ORTHANC_STATIC_ICU == 1 632 #if ORTHANC_STATIC_ICU == 1
633 # if ORTHANC_ENABLE_ICU == 0
634 throw OrthancException(ErrorCode_NotImplemented, "ICU is disabled for this target");
635 # else
629 if (globalIcuData_.empty()) 636 if (globalIcuData_.empty())
630 { 637 {
631 throw OrthancException(ErrorCode_BadSequenceOfCalls, 638 throw OrthancException(ErrorCode_BadSequenceOfCalls,
632 "Call Toolbox::InitializeGlobalLocale()"); 639 "Call Toolbox::InitializeGlobalLocale()");
633 } 640 }
641 # endif
634 #endif 642 #endif
635 643
636 // The "::skip" flag makes boost skip invalid UTF-8 644 // The "::skip" flag makes boost skip invalid UTF-8
637 // characters. This can occur in badly-encoded DICOM files. 645 // characters. This can occur in badly-encoded DICOM files.
638 646
683 #if ORTHANC_ENABLE_LOCALE == 1 691 #if ORTHANC_ENABLE_LOCALE == 1
684 std::string Toolbox::ConvertFromUtf8(const std::string& source, 692 std::string Toolbox::ConvertFromUtf8(const std::string& source,
685 Encoding targetEncoding) 693 Encoding targetEncoding)
686 { 694 {
687 #if ORTHANC_STATIC_ICU == 1 695 #if ORTHANC_STATIC_ICU == 1
696 # if ORTHANC_ENABLE_ICU == 0
697 throw OrthancException(ErrorCode_NotImplemented, "ICU is disabled for this target");
698 # else
688 if (globalIcuData_.empty()) 699 if (globalIcuData_.empty())
689 { 700 {
690 throw OrthancException(ErrorCode_BadSequenceOfCalls, 701 throw OrthancException(ErrorCode_BadSequenceOfCalls,
691 "Call Toolbox::InitializeGlobalLocale()"); 702 "Call Toolbox::InitializeGlobalLocale()");
692 } 703 }
704 # endif
693 #endif 705 #endif
694 706
695 // The "::skip" flag makes boost skip invalid UTF-8 707 // The "::skip" flag makes boost skip invalid UTF-8
696 // characters. This can occur in badly-encoded DICOM files. 708 // characters. This can occur in badly-encoded DICOM files.
697 709
1523 } 1535 }
1524 1536
1525 1537
1526 static void InitializeIcu() 1538 static void InitializeIcu()
1527 { 1539 {
1528 #if ORTHANC_STATIC_ICU == 1 1540 #if (ORTHANC_STATIC_ICU == 1) && (ORTHANC_ENABLE_ICU == 1)
1529 if (globalIcuData_.empty()) 1541 if (globalIcuData_.empty())
1530 { 1542 {
1531 LOG(INFO) << "Setting up the ICU common data"; 1543 LOG(INFO) << "Setting up the ICU common data";
1532 1544
1533 GzipCompressor compressor; 1545 GzipCompressor compressor;
1691 std::string Toolbox::ToUpperCaseWithAccents(const std::string& source) 1703 std::string Toolbox::ToUpperCaseWithAccents(const std::string& source)
1692 { 1704 {
1693 bool error = (globalLocale_.get() == NULL); 1705 bool error = (globalLocale_.get() == NULL);
1694 1706
1695 #if ORTHANC_STATIC_ICU == 1 1707 #if ORTHANC_STATIC_ICU == 1
1708 # if ORTHANC_ENABLE_ICU == 0
1709 throw OrthancException(ErrorCode_NotImplemented, "ICU is disabled for this target");
1710 # else
1696 if (globalIcuData_.empty()) 1711 if (globalIcuData_.empty())
1697 { 1712 {
1698 error = true; 1713 error = true;
1699 } 1714 }
1715 # endif
1700 #endif 1716 #endif
1701 1717
1702 if (error) 1718 if (error)
1703 { 1719 {
1704 throw OrthancException(ErrorCode_BadSequenceOfCalls, 1720 throw OrthancException(ErrorCode_BadSequenceOfCalls,