comparison Core/Enumerations.cpp @ 2908:9d277f8ad698

new enumeration: MimeType
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Oct 2018 16:16:07 +0100
parents 61a5667f37d9
children 22524fd06225
comparison
equal deleted inserted replaced
2907:0204af4ece6a 2908:9d277f8ad698
1017 1017
1018 default: 1018 default:
1019 throw OrthancException(ErrorCode_ParameterOutOfRange); 1019 throw OrthancException(ErrorCode_ParameterOutOfRange);
1020 } 1020 }
1021 } 1021 }
1022
1023
1024 const char* EnumerationToString(MimeType mime)
1025 {
1026 switch (mime)
1027 {
1028 case MimeType_Binary:
1029 return MIME_BINARY;
1030
1031 case MimeType_Dicom:
1032 return MIME_DICOM;
1033
1034 case MimeType_Jpeg:
1035 return MIME_JPEG;
1036
1037 case MimeType_Jpeg2000:
1038 return MIME_JPEG2000;
1039
1040 case MimeType_Json:
1041 return MIME_JSON;
1042
1043 case MimeType_Pdf:
1044 return MIME_PDF;
1045
1046 case MimeType_Png:
1047 return MIME_PNG;
1048
1049 case MimeType_Xml:
1050 return MIME_XML;
1051
1052 case MimeType_PlainText:
1053 return MIME_PLAIN_TEXT;
1054
1055 case MimeType_Pam:
1056 return MIME_PAM;
1057
1058 case MimeType_Html:
1059 return MIME_HTML;
1060
1061 case MimeType_Gzip:
1062 return MIME_GZIP;
1063
1064 case MimeType_JavaScript:
1065 return MIME_JAVASCRIPT;
1066
1067 case MimeType_Css:
1068 return MIME_CSS;
1069
1070 case MimeType_WebAssembly:
1071 return MIME_WEB_ASSEMBLY;
1072
1073 case MimeType_Gif:
1074 return MIME_GIF;
1075
1076 default:
1077 throw OrthancException(ErrorCode_ParameterOutOfRange);
1078 }
1079 }
1022 1080
1023 1081
1024 Encoding StringToEncoding(const char* encoding) 1082 Encoding StringToEncoding(const char* encoding)
1025 { 1083 {
1026 std::string s(encoding); 1084 std::string s(encoding);
1527 return RequestOrigin_Plugins; 1585 return RequestOrigin_Plugins;
1528 } 1586 }
1529 else if (origin == "Lua") 1587 else if (origin == "Lua")
1530 { 1588 {
1531 return RequestOrigin_Lua; 1589 return RequestOrigin_Lua;
1590 }
1591 else
1592 {
1593 throw OrthancException(ErrorCode_ParameterOutOfRange);
1594 }
1595 }
1596
1597
1598 MimeType StringToMimeType(const std::string& mime)
1599 {
1600 if (mime == MIME_BINARY)
1601 {
1602 return MimeType_Binary;
1603 }
1604 else if (mime == MIME_DICOM)
1605 {
1606 return MimeType_Dicom;
1607 }
1608 else if (mime == MIME_JPEG)
1609 {
1610 return MimeType_Jpeg;
1611 }
1612 else if (mime == MIME_JPEG2000)
1613 {
1614 return MimeType_Jpeg2000;
1615 }
1616 else if (mime == MIME_JSON)
1617 {
1618 return MimeType_Json;
1619 }
1620 else if (mime == MIME_PDF)
1621 {
1622 return MimeType_Pdf;
1623 }
1624 else if (mime == MIME_PNG)
1625 {
1626 return MimeType_Png;
1627 }
1628 else if (mime == MIME_XML ||
1629 mime == MIME_XML_2)
1630 {
1631 return MimeType_Xml;
1632 }
1633 else if (mime == MIME_PLAIN_TEXT)
1634 {
1635 return MimeType_PlainText;
1636 }
1637 else if (mime == MIME_PAM)
1638 {
1639 return MimeType_Pam;
1640 }
1641 else if (mime == MIME_HTML)
1642 {
1643 return MimeType_Html;
1644 }
1645 else if (mime == MIME_GZIP)
1646 {
1647 return MimeType_Gzip;
1648 }
1649 else if (mime == MIME_JAVASCRIPT)
1650 {
1651 return MimeType_JavaScript;
1652 }
1653 else if (mime == MIME_CSS)
1654 {
1655 return MimeType_Css;
1656 }
1657 else if (mime == MIME_WEB_ASSEMBLY)
1658 {
1659 return MimeType_WebAssembly;
1660 }
1661 else if (mime == MIME_GIF)
1662 {
1663 return MimeType_Gif;
1532 } 1664 }
1533 else 1665 else
1534 { 1666 {
1535 throw OrthancException(ErrorCode_ParameterOutOfRange); 1667 throw OrthancException(ErrorCode_ParameterOutOfRange);
1536 } 1668 }