Mercurial > hg > orthanc
comparison OrthancFramework/Sources/Toolbox.cpp @ 4203:4d42408da117
improving const-correctness in ParsedDicomFile
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 17 Sep 2020 15:01:31 +0200 |
parents | bf7b9edf6b81 |
children | a38376b80cd1 |
comparison
equal
deleted
inserted
replaced
4202:2007ab69ac16 | 4203:4d42408da117 |
---|---|
911 | 911 |
912 Endianness Toolbox::DetectEndianness() | 912 Endianness Toolbox::DetectEndianness() |
913 { | 913 { |
914 // http://sourceforge.net/p/predef/wiki/Endianness/ | 914 // http://sourceforge.net/p/predef/wiki/Endianness/ |
915 | 915 |
916 uint32_t bufferView; | 916 uint32_t bufferView = 0; |
917 | 917 |
918 uint8_t* buffer = reinterpret_cast<uint8_t*>(&bufferView); | 918 uint8_t* buffer = reinterpret_cast<uint8_t*>(&bufferView); |
919 | 919 |
920 buffer[0] = 0x00; | 920 buffer[0] = 0x00; |
921 buffer[1] = 0x01; | 921 buffer[1] = 0x01; |
1567 "On UNIX-like systems, the file " + std::string(LOCALTIME) + | 1567 "On UNIX-like systems, the file " + std::string(LOCALTIME) + |
1568 " must be present on the filesystem (install \"tzdata\" package on Debian)"); | 1568 " must be present on the filesystem (install \"tzdata\" package on Debian)"); |
1569 } | 1569 } |
1570 #endif | 1570 #endif |
1571 | 1571 |
1572 // Make Orthanc use English, United States locale | |
1573 // Linux: use "en_US.UTF-8" | |
1574 // Windows: use "" | |
1575 // Wine: use NULL | |
1576 | |
1577 #if defined(__MINGW32__) | |
1578 // Visibly, there is no support of locales in MinGW yet | |
1579 // http://mingw.5.n7.nabble.com/How-to-use-std-locale-global-with-MinGW-correct-td33048.html | |
1580 static const char* DEFAULT_LOCALE = NULL; | |
1581 #elif defined(_WIN32) | |
1582 // For Windows: use default locale (using "en_US" does not work) | |
1583 static const char* DEFAULT_LOCALE = ""; | |
1584 #else | |
1585 // For Linux & cie | |
1586 static const char* DEFAULT_LOCALE = "en_US.UTF-8"; | |
1587 #endif | |
1588 | |
1589 bool ok; | 1572 bool ok; |
1590 | 1573 |
1591 if (locale == NULL) | 1574 if (locale == NULL) |
1592 { | 1575 { |
1576 // Make Orthanc use English, United States locale | |
1577 // Linux: use "en_US.UTF-8" | |
1578 // Windows: use "" | |
1579 // Wine: use NULL | |
1580 | |
1581 #if defined(__MINGW32__) | |
1582 // Visibly, there is no support of locales in MinGW yet | |
1583 // http://mingw.5.n7.nabble.com/How-to-use-std-locale-global-with-MinGW-correct-td33048.html | |
1584 static const char* DEFAULT_LOCALE = NULL; | |
1585 #elif defined(_WIN32) | |
1586 // For Windows: use default locale (using "en_US" does not work) | |
1587 static const char* DEFAULT_LOCALE = ""; | |
1588 #else | |
1589 // For Linux & cie | |
1590 static const char* DEFAULT_LOCALE = "en_US.UTF-8"; | |
1591 #endif | |
1592 | |
1593 ok = SetGlobalLocale(DEFAULT_LOCALE); | 1593 ok = SetGlobalLocale(DEFAULT_LOCALE); |
1594 | 1594 |
1595 #if defined(__MINGW32__) | 1595 #if defined(__MINGW32__) |
1596 LOG(WARNING) << "This is a MinGW build, case-insensitive comparison of " | 1596 LOG(WARNING) << "This is a MinGW build, case-insensitive comparison of " |
1597 << "strings with accents will not work outside of Wine"; | 1597 << "strings with accents will not work outside of Wine"; |
1771 | 1771 |
1772 private: | 1772 private: |
1773 const Dictionary& dictionary_; | 1773 const Dictionary& dictionary_; |
1774 | 1774 |
1775 public: | 1775 public: |
1776 VariableFormatter(const Dictionary& dictionary) : | 1776 explicit VariableFormatter(const Dictionary& dictionary) : |
1777 dictionary_(dictionary) | 1777 dictionary_(dictionary) |
1778 { | 1778 { |
1779 } | 1779 } |
1780 | 1780 |
1781 template<typename Out> | 1781 template<typename Out> |
2251 { | 2251 { |
2252 const Json::Value& array = v["Value"]; | 2252 const Json::Value& array = v["Value"]; |
2253 assert(array.isArray()); | 2253 assert(array.isArray()); |
2254 | 2254 |
2255 Json::Value children = Json::arrayValue; | 2255 Json::Value children = Json::arrayValue; |
2256 for (Json::Value::ArrayIndex i = 0; i < array.size(); i++) | 2256 for (Json::Value::ArrayIndex j = 0; j < array.size(); j++) |
2257 { | 2257 { |
2258 Json::Value c; | 2258 Json::Value c; |
2259 SimplifyDicomAsJson(c, array[i], format); | 2259 SimplifyDicomAsJson(c, array[j], format); |
2260 children.append(c); | 2260 children.append(c); |
2261 } | 2261 } |
2262 | 2262 |
2263 target[name] = children; | 2263 target[name] = children; |
2264 } | 2264 } |