#ifndef __IMFBoundary_h__ # define __IMFBoundary_h__ #include "Parser.h" namespace coreutils { /// /// IMFBoundary detects a MIME multipart boundary line in the shared /// StreamReader - either an ordinary boundary ("\r\n--" + boundary + /// "\r\n", meaning another part follows) or the closing boundary /// ("\r\n--" + boundary + "--", meaning this was the last part). /// Resumable: if the boundary text has been seen but there isn't yet /// enough buffered data to tell an ordinary boundary from the closing /// one, parse() reports INCOMPLETE without committing the cursor past /// the ambiguous point. /// class IMFBoundary : public Parser { public: IMFBoundary(StreamReader &reader, ZString boundary); /// /// Valid once doParse() has returned Status::COMPLETE - true if this /// was the closing boundary (no further parts follow). /// bool isLast(); protected: Status parse() override; private: enum State { PREFIX, TAIL } state = PREFIX; ZString boundary; bool last = false; }; } #endif