Mercurial > hg > orthanc
comparison Core/Toolbox.cpp @ 453:30086c1aca30
endianness
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 04 Jul 2013 14:29:44 +0200 |
parents | d2c69150a979 |
children | c9a5d72f8481 |
comparison
equal
deleted
inserted
replaced
452:80f7539147a2 | 453:30086c1aca30 |
---|---|
32 | 32 |
33 #include "Toolbox.h" | 33 #include "Toolbox.h" |
34 | 34 |
35 #include "OrthancException.h" | 35 #include "OrthancException.h" |
36 | 36 |
37 #include <stdint.h> | |
37 #include <string.h> | 38 #include <string.h> |
38 #include <boost/filesystem.hpp> | 39 #include <boost/filesystem.hpp> |
39 #include <boost/filesystem/fstream.hpp> | 40 #include <boost/filesystem/fstream.hpp> |
40 #include <boost/date_time/posix_time/posix_time.hpp> | 41 #include <boost/date_time/posix_time/posix_time.hpp> |
41 #include <algorithm> | 42 #include <algorithm> |
669 } | 670 } |
670 } | 671 } |
671 | 672 |
672 s.resize(target); | 673 s.resize(target); |
673 } | 674 } |
675 | |
676 | |
677 Endianness Toolbox::DetectEndianness() | |
678 { | |
679 // http://sourceforge.net/p/predef/wiki/Endianness/ | |
680 | |
681 uint8_t buffer[4]; | |
682 | |
683 buffer[0] = 0x00; | |
684 buffer[1] = 0x01; | |
685 buffer[2] = 0x02; | |
686 buffer[3] = 0x03; | |
687 | |
688 switch (*((uint32_t *)buffer)) | |
689 { | |
690 case 0x00010203: | |
691 return Endianness_Big; | |
692 | |
693 case 0x03020100: | |
694 return Endianness_Little; | |
695 | |
696 default: | |
697 throw OrthancException(ErrorCode_NotImplemented); | |
698 } | |
699 } | |
674 } | 700 } |