StatefulParser.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/web/mime/multipart/StatefulParser.hpp"

StatefulParser

Stateful parser of multipart-data stream. Parser designed to work with stream-like data in order to store minimum data in the memory.

namespace oatpp { namespace web { namespace mime { namespace multipart { 
  class StatefulParser {}
}}}}

Typedefs

Type Name Summary
std::unordered_map<oatpp::data::share::StringKeyLabelCI_FAST, oatpp::data::share::StringKeyLabel> Headers Typedef for headers map. Headers map key is case-insensitive. std::unordered_map of oatpp::data::share::StringKeyLabelCI_FAST and oatpp::data::share::StringKeyLabel.

Methods

Return Type Name Summary
[none] StatefulParser Constructor.
v_int32 parseNext Parse next chunk of bytes.
async::Action parseNextAsyncInline Parse next chunk of bytes in Async-Inline manner.
bool finished Check if parser done parsing data.

StatefulParser::Headers

Typedef for headers map. Headers map key is case-insensitive. std::unordered_map of oatpp::data::share::StringKeyLabelCI_FAST and oatpp::data::share::StringKeyLabel.

typedef std::unordered_map<oatpp::data::share::StringKeyLabelCI_FAST, oatpp::data::share::StringKeyLabel> Headers

StatefulParser::StatefulParser

Constructor.

StatefulParser(const oatpp::String& boundary,
               const std::shared_ptr<Listener>& listener,
               const std::shared_ptr<AsyncListener>& asyncListener)

StatefulParser::parseNext

Parse next chunk of bytes.

  • @param data - pointer to data.
  • @param size - data size.
  • @return - exact number of parsed bytes.
    returned value may be less than size given.

v_int32 parseNext(p_char8 data, v_int32 size)

StatefulParser::parseNextAsyncInline

Parse next chunk of bytes in Async-Inline manner.

  • @param coroutine - caller coroutine.
  • @param inlineData - data.
  • @param nextAction - action on when done with current chunk of data.
  • @return - oatpp::async::Action.

async::Action parseNextAsyncInline(async::AbstractCoroutine* coroutine,
                                   data::stream::AsyncInlineWriteData& inlineData,
                                   async::Action&& nextAction)

StatefulParser::finished

Check if parser done parsing data.

  • @return - true or false.

bool finished()

StatefulParser::Listener

Listener for parsed items.

namespace oatpp { namespace web { namespace mime { namespace multipart { 
  class StatefulParser {
    class Listener {}
  };
}}}}

Typedefs

Type Name Summary
std::unordered_map<oatpp::data::share::StringKeyLabelCI_FAST, oatpp::data::share::StringKeyLabel> Headers Convenience typedef for headers map. Headers map key is case-insensitive. std::unordered_map of oatpp::data::share::StringKeyLabelCI_FAST and oatpp::data::share::StringKeyLabel.

Methods

Return Type Name Summary
[none] ~Listener Default virtual Destructor.
void onPartHeaders Called on new part found in the stream.
void onPartData Called on each new chunk of bytes parsed from the part body.

StatefulParser::Listener::Headers

Convenience typedef for headers map. Headers map key is case-insensitive. std::unordered_map of oatpp::data::share::StringKeyLabelCI_FAST and oatpp::data::share::StringKeyLabel.

typedef std::unordered_map<oatpp::data::share::StringKeyLabelCI_FAST, oatpp::data::share::StringKeyLabel> Headers

StatefulParser::Listener::~Listener

Default virtual Destructor.

virtual ~Listener() = default

StatefulParser::Listener::onPartHeaders

Called on new part found in the stream. Always called before onPartData events.

  • @param partHeaders - complete set of part headers.

virtual void onPartHeaders(const Headers& partHeaders) = 0

StatefulParser::Listener::onPartData

Called on each new chunk of bytes parsed from the part body. When all data of message is read, readMessage is called again with size == 0 to indicate end of the part.

  • @param data - pointer to data.
  • @param size - size of the data in bytes.

virtual void onPartData(p_char8 data, oatpp::data::v_io_size size) = 0

StatefulParser::AsyncListener

Async Listener for parsed items.

namespace oatpp { namespace web { namespace mime { namespace multipart { 
  class StatefulParser {
    class AsyncListener {}
  };
}}}}

Typedefs

Type Name Summary
std::unordered_map<oatpp::data::share::StringKeyLabelCI_FAST, oatpp::data::share::StringKeyLabel> Headers Convenience typedef for headers map. Headers map key is case-insensitive. std::unordered_map of oatpp::data::share::StringKeyLabelCI_FAST and oatpp::data::share::StringKeyLabel.

Methods

Return Type Name Summary
[none] ~AsyncListener Default virtual Destructor.
async::CoroutineStarter onPartHeadersAsync Called on new part found in the stream.
async::CoroutineStarter onPartDataAsync Called on each new chunk of bytes parsed from the part body.

StatefulParser::AsyncListener::Headers

Convenience typedef for headers map. Headers map key is case-insensitive. std::unordered_map of oatpp::data::share::StringKeyLabelCI_FAST and oatpp::data::share::StringKeyLabel.

typedef std::unordered_map<oatpp::data::share::StringKeyLabelCI_FAST, oatpp::data::share::StringKeyLabel> Headers

StatefulParser::AsyncListener::~AsyncListener

Default virtual Destructor.

virtual ~AsyncListener() = default

StatefulParser::AsyncListener::onPartHeadersAsync

Called on new part found in the stream. Always called before onPartData events.

  • @param partHeaders - complete set of part headers.

virtual async::CoroutineStarter onPartHeadersAsync(const Headers& partHeaders) = 0

StatefulParser::AsyncListener::onPartDataAsync

Called on each new chunk of bytes parsed from the part body. When all data of message is read, readMessage is called again with size == 0 to indicate end of the part.

  • @param data - pointer to data.
  • @param size - size of the data in bytes.

virtual async::CoroutineStarter onPartDataAsync(p_char8 data, oatpp::data::v_io_size size) = 0