#pragma once #include #include #include "RawImage.hpp" namespace MC::Image { class PPMParser { public: explicit PPMParser(std::string_view source) : m_source(source) {}; RawImage parse(); private: enum PPMType { None, P3, P6 }; struct PPMHeader { PPMType type; uint32_t width; uint32_t height; uint8_t max_color; }; PPMHeader parse_header(); RawImage::Pixel parse_pixel(uint8_t max_color); uint64_t parse_sample(); uint64_t chomp_number(); std::string_view chomp_part(); void skip_whitespace(); void skip_comment(); bool is_eof(); std::string_view m_source; uint64_t m_cursor = 0; }; }