comparison OrthancServer/DicomProtocol/RemoteModalityParameters.cpp @ 1654:3727a09e7b53

fix some icc warnings
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 28 Sep 2015 15:03:35 +0200
parents d710ea64f0fd
children 0001f8cd7849
comparison
equal deleted inserted replaced
1653:0c86b30bb8b2 1654:3727a09e7b53
48 { 48 {
49 } 49 }
50 50
51 RemoteModalityParameters::RemoteModalityParameters(const std::string& aet, 51 RemoteModalityParameters::RemoteModalityParameters(const std::string& aet,
52 const std::string& host, 52 const std::string& host,
53 int port, 53 uint16_t port,
54 ModalityManufacturer manufacturer) 54 ModalityManufacturer manufacturer)
55 { 55 {
56 SetApplicationEntityTitle(aet); 56 SetApplicationEntityTitle(aet);
57 SetHost(host); 57 SetHost(host);
58 SetPort(port); 58 SetPort(port);
59 SetManufacturer(manufacturer); 59 SetManufacturer(manufacturer);
60 } 60 }
61 61
62
63 void RemoteModalityParameters::SetPort(int port)
64 {
65 if (port <= 0 || port >= 65535)
66 {
67 throw OrthancException(ErrorCode_ParameterOutOfRange);
68 }
69
70 port_ = port;
71 }
72 62
73 void RemoteModalityParameters::FromJson(const Json::Value& modality) 63 void RemoteModalityParameters::FromJson(const Json::Value& modality)
74 { 64 {
75 if (!modality.isArray() || 65 if (!modality.isArray() ||
76 (modality.size() != 3 && modality.size() != 4)) 66 (modality.size() != 3 && modality.size() != 4))
82 SetHost(modality.get(1u, "").asString()); 72 SetHost(modality.get(1u, "").asString());
83 73
84 const Json::Value& portValue = modality.get(2u, ""); 74 const Json::Value& portValue = modality.get(2u, "");
85 try 75 try
86 { 76 {
87 SetPort(portValue.asInt()); 77 int tmp = portValue.asInt();
78
79 if (tmp <= 0 || tmp >= 65535)
80 {
81 throw OrthancException(ErrorCode_ParameterOutOfRange);
82 }
83
84 SetPort(static_cast<uint16_t>(tmp));
88 } 85 }
89 catch (std::runtime_error /* error inside JsonCpp */) 86 catch (std::runtime_error /* error inside JsonCpp */)
90 { 87 {
91 try 88 try
92 { 89 {
93 SetPort(boost::lexical_cast<int>(portValue.asString())); 90 SetPort(boost::lexical_cast<uint16_t>(portValue.asString()));
94 } 91 }
95 catch (boost::bad_lexical_cast) 92 catch (boost::bad_lexical_cast)
96 { 93 {
97 throw OrthancException(ErrorCode_BadFileFormat); 94 throw OrthancException(ErrorCode_BadFileFormat);
98 } 95 }