DoorKeeper/include/doorkeeper/implem/tilemapdata.inl
King_DuckZ 701366bf86 Replace size_t with uint32_t for template parameter D
This fixes the build on 64-bit machines, where size_t and uint32_t from vector.hpp would mismatch.
2015-01-08 12:20:17 +01:00

34 lines
1.3 KiB
C++

namespace dk {
///-------------------------------------------------------------------------
///-------------------------------------------------------------------------
template <typename T, uint32_t D>
TileMapData<T, D>::TileMapData (std::unique_ptr<MapStreamBase<D>>&& parStream) :
m_mapstream(std::move(parStream))
{
}
///-------------------------------------------------------------------------
///-------------------------------------------------------------------------
template <typename T, uint32_t D>
void TileMapData<T, D>::fetch (std::vector<T>& parOut, const coords& parFrom, const coords& parTo) {
DK_ASSERT(parFrom >= coords(0));
DK_ASSERT(parFrom < parTo);
DK_ASSERT(parFrom < m_mapstream->mapSize());
DK_ASSERT(parTo <= m_mapstream->mapSize());
const auto tileCount = implem::area(parTo - parFrom);
parOut.resize(tileCount);
m_mapstream->read(
reinterpret_cast<char*>(parOut.data()),
parOut.size() * sizeof(typename std::vector<T>::value_type),
parFrom,
parTo);
}
///-------------------------------------------------------------------------
///-------------------------------------------------------------------------
template <typename T, uint32_t D>
const typename TileMapData<T, D>::coords& TileMapData<T, D>::mapSize() const {
return m_mapstream->mapSize();
}
} //namespace dk