# 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
oatpp::data::share::LazyStringMap<oatpp::data::share::StringKeyLabelCI_FAST> Headers Typedef for headers map. Headers map key is case-insensitive. For more info see oatpp::data::share::LazyStringMap.

# Methods

Return Type Name Summary
[none] StatefulParser Constructor.
void parseNext Parse next chunk of bytes.
bool finished Check if parser done parsing data.

# StatefulParser::Headers

Typedef for headers map. Headers map key is case-insensitive. For more info see oatpp::data::share::LazyStringMap.

typedef oatpp::data::share::LazyStringMap<oatpp::data::share::StringKeyLabelCI_FAST> 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 inlineData - inline data.
  • @param action - Async Action in case Async Listener was provided in constructor.

void parseNext(data::buffer::InlineWriteData& inlineData, async::Action& action)

# 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
oatpp::data::share::LazyStringMap<oatpp::data::share::StringKeyLabelCI_FAST> Headers Typedef for headers map. Headers map key is case-insensitive. For more info see oatpp::data::share::LazyStringMap.

# 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

Typedef for headers map. Headers map key is case-insensitive. For more info see oatpp::data::share::LazyStringMap.

typedef oatpp::data::share::LazyStringMap<oatpp::data::share::StringKeyLabelCI_FAST> 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, v_buff_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
oatpp::data::share::LazyStringMap<oatpp::data::share::StringKeyLabelCI_FAST> Headers Typedef for headers map. Headers map key is case-insensitive. For more info see oatpp::data::share::LazyStringMap.

# 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

Typedef for headers map. Headers map key is case-insensitive. For more info see oatpp::data::share::LazyStringMap.

typedef oatpp::data::share::LazyStringMap<oatpp::data::share::StringKeyLabelCI_FAST> 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, v_buff_size size) = 0