comparison Core/Enumerations.cpp @ 2006:6301bbcbcaed

more generic support of value representations
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 09 Jun 2016 14:48:40 +0200
parents e2a3ff770b48
children 655489d9165d
comparison
equal deleted inserted replaced
2005:9e021b2b348b 2006:6301bbcbcaed
33 #include "PrecompiledHeaders.h" 33 #include "PrecompiledHeaders.h"
34 #include "Enumerations.h" 34 #include "Enumerations.h"
35 35
36 #include "OrthancException.h" 36 #include "OrthancException.h"
37 #include "Toolbox.h" 37 #include "Toolbox.h"
38 #include "Logging.h"
38 39
39 #include <string.h> 40 #include <string.h>
40 #include <cassert> 41 #include <cassert>
41 42
42 namespace Orthanc 43 namespace Orthanc
894 return LogLevel_Trace; 895 return LogLevel_Trace;
895 } 896 }
896 else 897 else
897 { 898 {
898 throw OrthancException(ErrorCode_InternalError); 899 throw OrthancException(ErrorCode_InternalError);
900 }
901 }
902
903
904 ValueRepresentation StringToValueRepresentation(const std::string& vr,
905 bool throwIfUnsupported)
906 {
907 if (vr == "AE")
908 {
909 return ValueRepresentation_ApplicationEntity;
910 }
911 else if (vr == "AS")
912 {
913 return ValueRepresentation_AgeString;
914 }
915 else if (vr == "AT")
916 {
917 return ValueRepresentation_AttributeTag;
918 }
919 else if (vr == "CS")
920 {
921 return ValueRepresentation_CodeString;
922 }
923 else if (vr == "DA")
924 {
925 return ValueRepresentation_Date;
926 }
927 else if (vr == "DS")
928 {
929 return ValueRepresentation_DecimalString;
930 }
931 else if (vr == "DT")
932 {
933 return ValueRepresentation_DateTime;
934 }
935 else if (vr == "FL")
936 {
937 return ValueRepresentation_FloatingPointSingle;
938 }
939 else if (vr == "FD")
940 {
941 return ValueRepresentation_FloatingPointDouble;
942 }
943 else if (vr == "IS")
944 {
945 return ValueRepresentation_IntegerString;
946 }
947 else if (vr == "LO")
948 {
949 return ValueRepresentation_LongString;
950 }
951 else if (vr == "LT")
952 {
953 return ValueRepresentation_LongText;
954 }
955 else if (vr == "OB")
956 {
957 return ValueRepresentation_OtherByte;
958 }
959 else if (vr == "OD")
960 {
961 return ValueRepresentation_OtherDouble;
962 }
963 else if (vr == "OF")
964 {
965 return ValueRepresentation_OtherFloat;
966 }
967 else if (vr == "OL")
968 {
969 return ValueRepresentation_OtherLong;
970 }
971 else if (vr == "OW")
972 {
973 return ValueRepresentation_OtherWord;
974 }
975 else if (vr == "PN")
976 {
977 return ValueRepresentation_PatientName;
978 }
979 else if (vr == "SH")
980 {
981 return ValueRepresentation_ShortString;
982 }
983 else if (vr == "SL")
984 {
985 return ValueRepresentation_SignedLong;
986 }
987 else if (vr == "SQ")
988 {
989 return ValueRepresentation_Sequence;
990 }
991 else if (vr == "SS")
992 {
993 return ValueRepresentation_SignedShort;
994 }
995 else if (vr == "ST")
996 {
997 return ValueRepresentation_ShortText;
998 }
999 else if (vr == "TM")
1000 {
1001 return ValueRepresentation_Time;
1002 }
1003 else if (vr == "UC")
1004 {
1005 return ValueRepresentation_UnlimitedCharacters;
1006 }
1007 else if (vr == "UI")
1008 {
1009 return ValueRepresentation_UniqueIdentifier;
1010 }
1011 else if (vr == "UL")
1012 {
1013 return ValueRepresentation_UnsignedLong;
1014 }
1015 else if (vr == "UN")
1016 {
1017 return ValueRepresentation_Unknown;
1018 }
1019 else if (vr == "UR")
1020 {
1021 return ValueRepresentation_UniversalResource;
1022 }
1023 else if (vr == "US")
1024 {
1025 return ValueRepresentation_UnsignedShort;
1026 }
1027 else if (vr == "UT")
1028 {
1029 return ValueRepresentation_UnlimitedText;
1030 }
1031 else
1032 {
1033 std::string s = "Unsupported value representation encountered: " + vr;
1034
1035 if (throwIfUnsupported)
1036 {
1037 LOG(ERROR) << s;
1038 throw OrthancException(ErrorCode_ParameterOutOfRange);
1039 }
1040 else
1041 {
1042 LOG(INFO) << s;
1043 return ValueRepresentation_NotSupported;
1044 }
899 } 1045 }
900 } 1046 }
901 1047
902 1048
903 unsigned int GetBytesPerPixel(PixelFormat format) 1049 unsigned int GetBytesPerPixel(PixelFormat format)