Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SF Bug 599

SF Bug #599 JSON::Array and JSON::Object size() member can implicitly
lose precision
https://sourceforge.net/p/poco/patches/120/
  • Loading branch information...
commit cdd17f5203aa183c60474537f62bb329bad70c93 1 parent a54c34e
@aleks-f aleks-f authored
View
16 JSON/include/Poco/JSON/Array.h
@@ -57,7 +57,7 @@ class Object;
class JSON_API Array
{
public:
- typedef std::vector<Dynamic::Var> ValueVector;
+ typedef std::vector<Dynamic::Var> ValueVec;
typedef SharedPtr<Array> Ptr;
Array();
@@ -69,10 +69,10 @@ class JSON_API Array
virtual ~Array();
/// Destructor
- ValueVector::const_iterator begin() const;
+ ValueVec::const_iterator begin() const;
/// Returns iterator
- ValueVector::const_iterator end() const;
+ ValueVec::const_iterator end() const;
/// Returns iterator
Dynamic::Var get(unsigned int index) const;
@@ -148,26 +148,26 @@ class JSON_API Array
/// Removes the element on the given index.
private:
- ValueVector _values;
+ ValueVec _values;
};
-inline Array::ValueVector::const_iterator Array::begin() const
+inline Array::ValueVec::const_iterator Array::begin() const
{
return _values.begin();
}
-inline Array::ValueVector::const_iterator Array::end() const
+inline Array::ValueVec::const_iterator Array::end() const
{
return _values.end();
}
-inline unsigned int Array::size() const
+inline std::size_t Array::size() const
{
- return _values.size();
+ return static_cast<std::size_t>(_values.size());
}
View
4 JSON/include/Poco/JSON/Object.h
@@ -186,9 +186,9 @@ inline void Object::set(const std::string& key, const Dynamic::Var& value)
}
-inline unsigned int Object::size() const
+inline std::size_t Object::size() const
{
- return _values.size();
+ return static_cast<std::size_t>(_values.size());
}
View
2  JSON/src/Array.cpp
@@ -115,7 +115,7 @@ void Array::stringify(std::ostream& out, unsigned int indent) const
if ( indent > 0 )
out << std::endl;
- for(ValueVector::const_iterator it = _values.begin(); it != _values.end();)
+ for(ValueVec::const_iterator it = _values.begin(); it != _values.end();)
{
for(int i = 0; i < indent; i++)
{

1 comment on commit cdd17f5

@fduhem

In file included from src/Array.cpp:37:
include/Poco/JSON/Array.h:168:27: error: out-of-line definition of 'Poco::JSON::Array::size' differs from the declaration in the return type
inline std::size_t Array::size() const
^
include/Poco/JSON/Array.h:102:15: note: previous declaration is here
unsigned int size() const;
^
In file included from src/Array.cpp:38:
include/Poco/JSON/Object.h:189:28: error: out-of-line definition of 'Poco::JSON::Object::size' differs from the declaration in the return type
inline std::size_t Object::size() const
^
include/Poco/JSON/Object.h:136:15: note: previous declaration is here
unsigned int size() const;
^
2 errors generated.

Please sign in to comment.
Something went wrong with that request. Please try again.