2014-12-22 15:59:09 +00:00
|
|
|
#ifndef id263B7DAF9A1C40BB8517D5D328DF8A1B
|
|
|
|
#define id263B7DAF9A1C40BB8517D5D328DF8A1B
|
|
|
|
|
2015-01-06 15:38:52 +00:00
|
|
|
#include "doorkeeper/primitivetypes.hpp"
|
|
|
|
#include "doorkeeper/implem/vector.hpp"
|
2014-12-22 15:59:09 +00:00
|
|
|
#include <streambuf>
|
|
|
|
#include <vector>
|
2014-12-29 15:14:36 +00:00
|
|
|
#include <boost/iostreams/categories.hpp> // source_tag
|
2014-12-22 15:59:09 +00:00
|
|
|
|
|
|
|
namespace dkh {
|
2014-12-29 15:14:36 +00:00
|
|
|
class AsciiMapSource : public std::streambuf {
|
2014-12-22 15:59:09 +00:00
|
|
|
public:
|
2014-12-29 15:14:36 +00:00
|
|
|
typedef dk::Vector<dk::CoordinateScalarType, 2> coords;
|
2014-12-22 15:59:09 +00:00
|
|
|
typedef int MapTileType;
|
2014-12-29 15:14:36 +00:00
|
|
|
typedef boost::iostreams::source_tag category;
|
2014-12-22 15:59:09 +00:00
|
|
|
enum {
|
|
|
|
MapDimensions = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
AsciiMapSource ( void ) = delete;
|
2015-01-05 17:01:28 +00:00
|
|
|
AsciiMapSource ( const AsciiMapSource& ) = delete;
|
|
|
|
AsciiMapSource ( AsciiMapSource&& parOther ) = default;
|
2015-05-21 07:52:45 +00:00
|
|
|
AsciiMapSource ( const char* parFilename, const coords& parSize );
|
|
|
|
AsciiMapSource ( const std::string& parFilename, const coords& parSize );
|
|
|
|
AsciiMapSource ( std::istream& parData, const coords& parSize );
|
2014-12-22 15:59:09 +00:00
|
|
|
template <typename I>
|
2015-05-21 07:52:45 +00:00
|
|
|
AsciiMapSource ( I parDataFrom, I parDataTo, const coords& parSize );
|
2014-12-22 15:59:09 +00:00
|
|
|
~AsciiMapSource ( void ) noexcept = default;
|
|
|
|
|
2014-12-29 15:14:36 +00:00
|
|
|
const coords& mapSize ( void ) const noexcept { return m_mapSize; }
|
|
|
|
|
2015-01-05 17:01:28 +00:00
|
|
|
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 );
|
|
|
|
|
2014-12-22 15:59:09 +00:00
|
|
|
private:
|
2015-01-05 17:01:28 +00:00
|
|
|
enum {
|
|
|
|
DataSize = sizeof(MapTileType)
|
|
|
|
};
|
|
|
|
|
2014-12-22 15:59:09 +00:00
|
|
|
void parse_map_data ( std::istream& parSrc );
|
|
|
|
|
|
|
|
std::vector<MapTileType> m_wholedata;
|
2015-05-21 07:52:45 +00:00
|
|
|
const coords m_mapSize;
|
2015-01-05 17:01:28 +00:00
|
|
|
std::size_t m_bytepos;
|
2014-12-22 15:59:09 +00:00
|
|
|
};
|
2014-12-29 15:14:36 +00:00
|
|
|
} //namespace dkh
|
2014-12-22 15:59:09 +00:00
|
|
|
|
|
|
|
#endif
|