comparison Core/Toolbox.cpp @ 3489:e7723a39adf8

Fixed alignment issue in Toolbox::DetectEndianness() + made the internal logger use an std::stringstream so that manipulators like "std::hex" are supported (when using ORTHANC_ENABLE_LOGGING_PLUGIN or ORTHANC_ENABLE_LOGGING_STDIO)
author Benjamin Golinvaux <bgo@osimis.io>
date Sat, 10 Aug 2019 13:40:08 +0200
parents 7d72e43f4a2d
children 7ae553d9c366 94f4a18a79cc
comparison
equal deleted inserted replaced
3487:ce29644acd19 3489:e7723a39adf8
921 921
922 Endianness Toolbox::DetectEndianness() 922 Endianness Toolbox::DetectEndianness()
923 { 923 {
924 // http://sourceforge.net/p/predef/wiki/Endianness/ 924 // http://sourceforge.net/p/predef/wiki/Endianness/
925 925
926 uint8_t buffer[4]; 926 uint32_t bufferView;
927
928 uint8_t* buffer = reinterpret_cast<uint8_t*>(&bufferView);
927 929
928 buffer[0] = 0x00; 930 buffer[0] = 0x00;
929 buffer[1] = 0x01; 931 buffer[1] = 0x01;
930 buffer[2] = 0x02; 932 buffer[2] = 0x02;
931 buffer[3] = 0x03; 933 buffer[3] = 0x03;
932 934
933 switch (*((uint32_t *)buffer)) 935 switch (bufferView)
934 { 936 {
935 case 0x00010203: 937 case 0x00010203:
936 return Endianness_Big; 938 return Endianness_Big;
937 939
938 case 0x03020100: 940 case 0x03020100:
940 942
941 default: 943 default:
942 throw OrthancException(ErrorCode_NotImplemented); 944 throw OrthancException(ErrorCode_NotImplemented);
943 } 945 }
944 } 946 }
945
946 947
947 std::string Toolbox::WildcardToRegularExpression(const std::string& source) 948 std::string Toolbox::WildcardToRegularExpression(const std::string& source)
948 { 949 {
949 // TODO - Speed up this with a regular expression 950 // TODO - Speed up this with a regular expression
950 951