mirror of
				https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
				synced 2025-10-31 18:47:47 +00:00 
			
		
		
		
	Eliminate some gcc warnings
This commit is contained in:
		| @@ -116,7 +116,7 @@ public: | |||||||
| protected: | protected: | ||||||
| 	template <typename F, typename T> | 	template <typename F, typename T> | ||||||
| 	void convertToSmaller(const F& from, T& to) const | 	void convertToSmaller(const F& from, T& to) const | ||||||
| 		/// This function is meant to convert signed integral values from | 		/// This function is meant to convert signed numeric values from | ||||||
| 		/// larger to smaller type. It checks the upper and lower bound and | 		/// larger to smaller type. It checks the upper and lower bound and | ||||||
| 		/// if from value is within limits of type T (i.e. check calls do not throw),  | 		/// if from value is within limits of type T (i.e. check calls do not throw),  | ||||||
| 		/// it is converted. | 		/// it is converted. | ||||||
| @@ -126,7 +126,11 @@ protected: | |||||||
| 		poco_static_assert (std::numeric_limits<F>::is_signed); | 		poco_static_assert (std::numeric_limits<F>::is_signed); | ||||||
| 		poco_static_assert (std::numeric_limits<T>::is_signed); | 		poco_static_assert (std::numeric_limits<T>::is_signed); | ||||||
|  |  | ||||||
|  | 		if (std::numeric_limits<F>::is_integer) | ||||||
| 			checkUpperLimit(from, to);  | 			checkUpperLimit(from, to);  | ||||||
|  | 		else | ||||||
|  | 			checkUpperLimitFloat(from, to);  | ||||||
|  |  | ||||||
| 		checkLowerLimit(from, to); | 		checkLowerLimit(from, to); | ||||||
| 		to = static_cast<T>(from); | 		to = static_cast<T>(from); | ||||||
| 	} | 	} | ||||||
| @@ -153,7 +157,7 @@ protected: | |||||||
| 		/// This function is meant for converting signed integral data types to | 		/// This function is meant for converting signed integral data types to | ||||||
| 		/// unsigned data types. Negative values can not be converted and if one is  | 		/// unsigned data types. Negative values can not be converted and if one is  | ||||||
| 		/// encountered, RangeException is thrown.  | 		/// encountered, RangeException is thrown.  | ||||||
| 		/// If uper limit is within the target data type limits, the converiosn is performed. | 		/// If uper limit is within the target data type limits, the conversion is performed. | ||||||
| 	{ | 	{ | ||||||
| 		poco_static_assert (std::numeric_limits<F>::is_specialized); | 		poco_static_assert (std::numeric_limits<F>::is_specialized); | ||||||
| 		poco_static_assert (std::numeric_limits<T>::is_specialized); | 		poco_static_assert (std::numeric_limits<T>::is_specialized); | ||||||
| @@ -166,12 +170,31 @@ protected: | |||||||
| 		to = static_cast<T>(from); | 		to = static_cast<T>(from); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	template <typename F, typename T> | ||||||
|  | 	void convertSignedFloatToUnsigned(const F& from, T& to) const | ||||||
|  | 		/// This function is meant for converting floating point data types to | ||||||
|  | 		/// unsigned integral data types. Negative values can not be converted and if one is  | ||||||
|  | 		/// encountered, RangeException is thrown.  | ||||||
|  | 		/// If uper limit is within the target data type limits, the conversion is performed. | ||||||
|  | 	{ | ||||||
|  | 		poco_static_assert (std::numeric_limits<F>::is_specialized); | ||||||
|  | 		poco_static_assert (std::numeric_limits<T>::is_specialized); | ||||||
|  | 		poco_static_assert (!std::numeric_limits<F>::is_integer); | ||||||
|  | 		poco_static_assert (std::numeric_limits<T>::is_integer); | ||||||
|  | 		poco_static_assert (!std::numeric_limits<T>::is_signed); | ||||||
|  |  | ||||||
|  | 		if (from < 0) | ||||||
|  | 			throw RangeException("Value too small."); | ||||||
|  | 		checkUpperLimitFloat(from, to);  | ||||||
|  | 		to = static_cast<T>(from); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	template <typename F, typename T> | 	template <typename F, typename T> | ||||||
| 	void convertUnsignedToSigned(const F& from, T& to) const | 	void convertUnsignedToSigned(const F& from, T& to) const | ||||||
| 		/// This function is meant for converting unsigned integral data types to | 		/// This function is meant for converting unsigned integral data types to | ||||||
| 		/// unsigned data types. Negative values can not be converted and if one is  | 		/// unsigned data types. Negative values can not be converted and if one is  | ||||||
| 		/// encountered, RangeException is thrown.  | 		/// encountered, RangeException is thrown.  | ||||||
| 		/// If uper limit is within the target data type limits, the converiosn is performed. | 		/// If upper limit is within the target data type limits, the converiosn is performed. | ||||||
| 	{ | 	{ | ||||||
| 		poco_static_assert (std::numeric_limits<F>::is_specialized); | 		poco_static_assert (std::numeric_limits<F>::is_specialized); | ||||||
| 		poco_static_assert (std::numeric_limits<T>::is_specialized); | 		poco_static_assert (std::numeric_limits<T>::is_specialized); | ||||||
| @@ -185,6 +208,21 @@ protected: | |||||||
| private: | private: | ||||||
| 	template <typename F, typename T> | 	template <typename F, typename T> | ||||||
| 	void checkUpperLimit(const F& from, T& to) const | 	void checkUpperLimit(const F& from, T& to) const | ||||||
|  | 	{ | ||||||
|  | 		if ((sizeof(T) < sizeof(F)) && | ||||||
|  | 			(from > static_cast<F>(std::numeric_limits<T>::max()))) | ||||||
|  | 		{ | ||||||
|  | 			throw RangeException("Value too large."); | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 		if (static_cast<T>(from) > std::numeric_limits<T>::max())  | ||||||
|  | 		{ | ||||||
|  | 			throw RangeException("Value too large."); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	template <typename F, typename T> | ||||||
|  | 	void checkUpperLimitFloat(const F& from, T& to) const | ||||||
| 	{ | 	{ | ||||||
| 		if (from > std::numeric_limits<T>::max()) | 		if (from > std::numeric_limits<T>::max()) | ||||||
| 			throw RangeException("Value too large."); | 			throw RangeException("Value too large."); | ||||||
| @@ -1505,22 +1543,22 @@ public: | |||||||
|  |  | ||||||
| 	void convert(UInt8& val) const | 	void convert(UInt8& val) const | ||||||
| 	{ | 	{ | ||||||
| 		convertSignedToUnsigned(_val, val); | 		convertSignedFloatToUnsigned(_val, val); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	void convert(UInt16& val) const | 	void convert(UInt16& val) const | ||||||
| 	{ | 	{ | ||||||
| 		convertSignedToUnsigned(_val, val); | 		convertSignedFloatToUnsigned(_val, val); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	void convert(UInt32& val) const | 	void convert(UInt32& val) const | ||||||
| 	{ | 	{ | ||||||
| 		convertSignedToUnsigned(_val, val); | 		convertSignedFloatToUnsigned(_val, val); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	void convert(UInt64& val) const | 	void convert(UInt64& val) const | ||||||
| 	{ | 	{ | ||||||
| 		convertSignedToUnsigned(_val, val); | 		convertSignedFloatToUnsigned(_val, val); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	void convert(bool& val) const | 	void convert(bool& val) const | ||||||
| @@ -1630,22 +1668,22 @@ public: | |||||||
|  |  | ||||||
| 	void convert(UInt8& val) const | 	void convert(UInt8& val) const | ||||||
| 	{ | 	{ | ||||||
| 		convertSignedToUnsigned(_val, val); | 		convertSignedFloatToUnsigned(_val, val); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	void convert(UInt16& val) const | 	void convert(UInt16& val) const | ||||||
| 	{ | 	{ | ||||||
| 		convertSignedToUnsigned(_val, val); | 		convertSignedFloatToUnsigned(_val, val); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	void convert(UInt32& val) const | 	void convert(UInt32& val) const | ||||||
| 	{ | 	{ | ||||||
| 		convertSignedToUnsigned(_val, val); | 		convertSignedFloatToUnsigned(_val, val); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	void convert(UInt64& val) const | 	void convert(UInt64& val) const | ||||||
| 	{ | 	{ | ||||||
| 		convertSignedToUnsigned(_val, val); | 		convertSignedFloatToUnsigned(_val, val); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	void convert(bool& val) const | 	void convert(bool& val) const | ||||||
|   | |||||||
| @@ -114,7 +114,7 @@ void DynamicAnyTest::testInt8() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int16 value2 = a1.extract<Int16>(); | 		Int16 value2; value2 = a1.extract<Int16>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -185,7 +185,7 @@ void DynamicAnyTest::testInt16() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int32 value2 = a1.extract<Int32>(); | 		Int32 value2; value2 = a1.extract<Int32>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -256,7 +256,7 @@ void DynamicAnyTest::testInt32() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int16 value2 = a1.extract<Int16>(); | 		Int16 value2; value2 = a1.extract<Int16>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -327,7 +327,7 @@ void DynamicAnyTest::testInt64() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int16 value2 = a1.extract<Int16>(); | 		Int16 value2; value2 = a1.extract<Int16>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -398,7 +398,7 @@ void DynamicAnyTest::testUInt8() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int16 value2 = a1.extract<Int16>(); | 		Int16 value2; value2 = a1.extract<Int16>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -469,7 +469,7 @@ void DynamicAnyTest::testUInt16() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int16 value2 = a1.extract<Int16>(); | 		Int16 value2; value2 = a1.extract<Int16>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -540,7 +540,7 @@ void DynamicAnyTest::testUInt32() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int16 value2 = a1.extract<Int16>(); | 		Int16 value2; value2 = a1.extract<Int16>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -611,7 +611,7 @@ void DynamicAnyTest::testUInt64() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int16 value2 = a1.extract<Int16>(); | 		Int16 value2; value2 = a1.extract<Int16>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -682,7 +682,7 @@ void DynamicAnyTest::testBool() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int16 value2 = a1.extract<Int16>(); | 		Int16 value2; value2 = a1.extract<Int16>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -753,7 +753,7 @@ void DynamicAnyTest::testChar() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int16 value2 = a1.extract<Int16>(); | 		Int16 value2; value2 = a1.extract<Int16>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -824,7 +824,7 @@ void DynamicAnyTest::testFloat() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int16 value2 = a1.extract<Int16>(); | 		Int16 value2; value2 = a1.extract<Int16>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -895,7 +895,7 @@ void DynamicAnyTest::testDouble() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int16 value2 = a1.extract<Int16>(); | 		Int16 value2; value2 = a1.extract<Int16>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -961,7 +961,7 @@ void DynamicAnyTest::testString() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int16 value2 = a1.extract<Int16>(); | 		Int16 value2; value2 = a1.extract<Int16>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -1032,7 +1032,7 @@ void DynamicAnyTest::testLong() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int16 value2 = a1.extract<Int16>(); | 		Int16 value2; value2 = a1.extract<Int16>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -1103,7 +1103,7 @@ void DynamicAnyTest::testULong() | |||||||
| 	 | 	 | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Int16 value2 = a1.extract<Int16>(); | 		Int16 value2; value2 = a1.extract<Int16>(); | ||||||
| 		fail("bad cast - must throw"); | 		fail("bad cast - must throw"); | ||||||
| 	} | 	} | ||||||
| 	catch (Poco::BadCastException&) | 	catch (Poco::BadCastException&) | ||||||
| @@ -1123,9 +1123,8 @@ void DynamicAnyTest::testConversionOperator() | |||||||
| 	assert (s == "123"); | 	assert (s == "123"); | ||||||
|  |  | ||||||
| 	any = 321; | 	any = 321; | ||||||
| 	//fails on gcc 3.4.4.  | 	s = any.convert<std::string>(); | ||||||
| 	//s = (std::string) any;//must cast to disambiguate char/string | 	assert (s == "321"); | ||||||
| 	//assert (s == "321"); |  | ||||||
|  |  | ||||||
| 	any = "456"; | 	any = "456"; | ||||||
| 	assert (any == "456"); | 	assert (any == "456"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Aleksandar Fabijanic
					Aleksandar Fabijanic