DoorKeeper/include/doorkeeper/helpers/asciimapsource.hpp

54 lines
1.6 KiB
C++
Raw Normal View History

#ifndef id263B7DAF9A1C40BB8517D5D328DF8A1B
#define id263B7DAF9A1C40BB8517D5D328DF8A1B
#include "doorkeeper/primitivetypes.hpp"
#include "doorkeeper/implem/vector.hpp"
#include <streambuf>
#include <vector>
2014-12-29 15:14:36 +00:00
#include <boost/iostreams/categories.hpp> // source_tag
namespace dkh {
2014-12-29 15:14:36 +00:00
class AsciiMapSource : public std::streambuf {
public:
2014-12-29 15:14:36 +00:00
typedef dk::Vector<dk::CoordinateScalarType, 2> coords;
typedef int MapTileType;
2014-12-29 15:14:36 +00:00
typedef boost::iostreams::source_tag category;
enum {
MapDimensions = 2
};
AsciiMapSource ( void ) = delete;
AsciiMapSource ( const AsciiMapSource& ) = delete;
AsciiMapSource ( AsciiMapSource&& parOther ) = default;
AsciiMapSource ( const char* parFilename, const coords& parSize );
AsciiMapSource ( const std::string& parFilename, const coords& parSize );
AsciiMapSource ( std::istream& parData, const coords& parSize );
template <typename I>
AsciiMapSource ( I parDataFrom, I parDataTo, const coords& parSize );
~AsciiMapSource ( void ) noexcept = default;
2014-12-29 15:14:36 +00:00
const coords& mapSize ( void ) const noexcept { return m_mapSize; }
protected:
virtual int_type underflow ( void );
virtual int_type uflow ( void );
virtual int_type pbackfail ( int_type parCh );
virtual std::streamsize showmanyc ( void );
virtual pos_type seekoff ( off_type parOff, std::ios_base::seekdir parDir, std::ios_base::openmode parWhich );
virtual pos_type seekpos( pos_type parPos, std::ios_base::openmode parWhich );
private:
enum {
DataSize = sizeof(MapTileType)
};
void parse_map_data ( std::istream& parSrc );
std::vector<MapTileType> m_wholedata;
const coords m_mapSize;
std::size_t m_bytepos;
};
2014-12-29 15:14:36 +00:00
} //namespace dkh
#endif