summaryrefslogtreecommitdiff
path: root/include/mbgl/platform/default/image_reader.hpp
blob: e46bb08ea25709409073948b350111d6b947cfe6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef MBGL_UTIL_IMAGE_READER_HPP
#define MBGL_UTIL_IMAGE_READER_HPP

#include <mbgl/util/noncopyable.hpp>
// stl
#include <stdexcept>
#include <string>
#include <memory>

namespace mbgl { namespace util {

class ImageReaderException : public std::exception
{
private:
    std::string message_;
public:
    ImageReaderException(std::string const& message)
        : message_(message) {}

    ~ImageReaderException() throw() {}

    virtual const char* what() const throw()
    {
        return message_.c_str();
    }
};

struct ImageReader : private noncopyable
{
    virtual unsigned width() const=0;
    virtual unsigned height() const=0;
    virtual std::unique_ptr<uint8_t[]> read()=0;
    virtual ~ImageReader() {}
};

std::unique_ptr<ImageReader> getImageReader(const uint8_t* data, size_t size);

}}

#endif