Skip to content

Commit

Permalink
Merge pull request #283 from abellgithub/getfield
Browse files Browse the repository at this point in the history
Change return type of getField from reference to value.
  • Loading branch information
abellgithub committed Apr 6, 2014
2 parents df9d32d + 1d83a09 commit e0fc02a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions include/pdal/PointBuffer.hpp
Expand Up @@ -179,7 +179,7 @@ class PDAL_DLL PointBuffer
\endverbatim
*/
template<class T>
T const& getField(Dimension const& dim, boost::uint32_t pointIndex) const;
T getField(Dimension const& dim, boost::uint32_t pointIndex) const;

/*! set the value T for a given :cpp:class:`pdal::Dimension` dim
at pointIndex i.
Expand Down Expand Up @@ -504,12 +504,11 @@ inline void PointBuffer::setField(pdal::Dimension const& dim,
}

template <class T>
inline T const& PointBuffer::getField(pdal::Dimension const& dim,
inline T PointBuffer::getField(pdal::Dimension const& dim,
boost::uint32_t pointIndex) const
{
static char buf[1000] = {0};
if (!getBufferByteLength())
return *(T const *)(void const *)buf;
return (T)0;

if (dim.getPosition() == -1)
{
Expand Down Expand Up @@ -550,8 +549,7 @@ inline T const& PointBuffer::getField(pdal::Dimension const& dim,

if (static_cast<dimension::size_type>(sizeof(T)) <= dim.getByteSize())
{
T const& output = *(T const*)(void const*)p;
return output;
return *(T *)(void *)p;
}
else
{
Expand Down

0 comments on commit e0fc02a

Please sign in to comment.