E-MailRelay

Public Types | Public Member Functions | List of all members
GStore::NewMessage Class Referenceabstract

An abstract class to allow the creation of a new message in the message store. More...

`#include <gnewmessage.h>`

Inheritance diagram for GStore::NewMessage:
[legend]

## Public Types
enum class | Status { Ok , TooBig , Error }

## Public Member Functions
virtual void | addTo (const std::string &to, bool local, MessageStore::AddressStyle)=0
| Adds a 'to' address.
virtual Status | addContent (const char *, std::size_t)=0
| Adds a line of content, typically ending with CR-LF. More...
virtual void | prepare (const std::string &session_auth_id, const std::string &peer_socket_address, const std::string &peer_certificate)=0
| Prepares to store the message in the message store. More...
virtual void | commit (bool throw_on_error)=0
| Commits the prepare()d message to the store and disables the cleanup otherwise performed by the destructor. More...
virtual MessageId | id () const =0
| Returns the message's unique identifier.
virtual std::string | location () const =0
| Returns the message's unique location.
virtual std::size_t | contentSize () const =0
| Returns the content size. More...
void | addContentLine (const std::string &)
| A convenience function that calls addContent() taking a string parameter and adding CR-LF. More...
virtual | ~NewMessage ()=default
| Destructor. More...

## Detailed Description

An abstract class to allow the creation of a new message in the message store.

auto new_msg = make_unique<NewMessageImp>( envelope_from ) ;
new_msg->addTo( envelope_to_1 ) ;
new_msg->addTo( envelope_to_2 ) ;
for( auto line : content )
new_msg->addContent( line ) ;
new_msg->prepare(...) ;
startFiltering( new_msg ) ;

See also
  GStore::MessageStore

Definition at line 48 of file gnewmessage.h.

## Member Enumeration Documentation

## ◆ Status

enum class GStore::NewMessage::Status
| strong

Definition at line 51 of file gnewmessage.h.

## Constructor & Destructor Documentation

## ◆ ~NewMessage()

virtual GStore::NewMessage::~NewMessage | ( |  | ) |
| virtual default

Destructor.

Rolls back any prepare()d storage if un-commit()ed.

## Member Function Documentation

## ◆ addContent()

virtual Status GStore::NewMessage::addContent | ( | const char * | ,
|  | std::size_t |
| ) |  |
| pure virtual

Adds a line of content, typically ending with CR-LF.

Returns an error enum, but errors accumulate internally and thrown by prepare(). Adding zero bytes in order to test the current status is allowed.

## ◆ addContentLine()

void GStore::NewMessage::addContentLine | ( | const std::string & | line | ) |

A convenience function that calls addContent() taking a string parameter and adding CR-LF.

Definition at line 26 of file gnewmessage.cpp.

## ◆ commit()

virtual void GStore::NewMessage::commit | ( | bool | throw_on_error | ) |
| pure virtual

Commits the prepare()d message to the store and disables the cleanup otherwise performed by the destructor.

Either throws or ignores commit errors.

## ◆ contentSize()

virtual std::size_t GStore::NewMessage::contentSize | ( |  | ) | const
| pure virtual

Returns the content size.

Returns the maximum size_t value on overflow.

## ◆ prepare()

virtual void GStore::NewMessage::prepare | ( | const std::string & | session_auth_id,
|  | const std::string & | peer_socket_address,
|  | const std::string & | peer_certificate
| ) |  |
| pure virtual

Prepares to store the message in the message store.

Throws on error, including any errors that accumulated while adding content.

The documentation for this class was generated from the following files:

- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gstore/gnewmessage.h
- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gstore/gnewmessage.cpp