DoorKeeper/include/doorkeeper/helpers/asciimapsource.hpp
2015-05-21 09:52:45 +02:00

53 lines
1.6 KiB
C++

#ifndef id263B7DAF9A1C40BB8517D5D328DF8A1B
#define id263B7DAF9A1C40BB8517D5D328DF8A1B
#include "doorkeeper/primitivetypes.hpp"
#include "doorkeeper/implem/vector.hpp"
#include <streambuf>
#include <vector>
#include <boost/iostreams/categories.hpp> // source_tag
namespace dkh {
class AsciiMapSource : public std::streambuf {
public:
typedef dk::Vector<dk::CoordinateScalarType, 2> coords;
typedef int MapTileType;
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;
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;
};
} //namespace dkh
#endif