Matrix Science header
Public Member Functions | Static Public Member Functions

ms_http_client_mime Class Reference
[Accessing a Mascot Server using HTTP]

The class eases the building of a MIME section. More...

#include <ms_http_client_mime.hpp>

List of all members.

Public Member Functions

virtual ~ms_http_client_mime ()
 Destructor. HTTP Communication to a Mascot Server.
void append (const std::string &name, const std::string &value)
 Adds a name-value pair element to the end of the MIME string.
void appendFile (const std::string &name, const std::string &filename, const std::string &contentType, const std::string &prefixData="")
 Adds a name-value pair element with a filename attribute to the end of the MIME string.
void erase (int oneBasedIndex)
 Remove an element.
std::string format (const std::string &boundary, matrix_science::ms_http_client_mime::Continuation continuation) const
 Gets the complete MIME string.
int getCount () const
 Returns the number of items.
std::string getFilename (int oneBasedIndex) const
 Returns the filename attribute of an item.
std::string getName (int oneBasedIndex) const
 Returns the name of an item.
std::string getValue (int oneBasedIndex) const
 Returns the value of an item.
bool hasFilename (int oneBasedIndex) const
 Returns true if the item has a filename attribute.
void setValue (int oneBasedIndex, const std::string &value)
 Change the value of an element.
void setValueWithFilename (int oneBasedIndex, const std::string &value, const std::string &filename, const std::string &contentType)
 Change the value of an element and set a filename attribute on it.

Static Public Member Functions

static std::string formatHeader (const std::string &boundary, ContentType contentType)
 Gets the MIME header string.

Detailed Description

The class eases the building of a MIME section.

Each element can be added individually as a name-value pair. The MIME content text can then be retrieved.

The text can have a MIME terminator added, as required.

The boundary string can be changed if desired.


Constructor & Destructor Documentation

~ms_http_client_mime (  ) [virtual]

Destructor. HTTP Communication to a Mascot Server.

Called automatically.


Member Function Documentation

void append ( const std::string &  name,
const std::string &  value 
)

Adds a name-value pair element to the end of the MIME string.

Parameters:
nameThe name of the item.
valueThe value of the item.
void appendFile ( const std::string &  name,
const std::string &  filename,
const std::string &  contentType,
const std::string &  prefixData = "" 
)

Adds a name-value pair element with a filename attribute to the end of the MIME string.

Parameters:
nameThe name of the item.
filenameThe filename specified for the item.
contentTypeThe MIME type string for the type of content (e.g. "text/xml").
prefixDataThe filename specified for the item. Data added to the start of the file. Optional.
void erase ( int  oneBasedIndex )

Remove an element.

Parameters:
oneBasedIndexThe index is 1..Count() inclusive (not zero based).
std::string format ( const std::string &  boundary,
matrix_science::ms_http_client_mime::Continuation  continuation 
) const

Gets the complete MIME string.

Parameters:
boundaryThe string to be used as a separator between MIME sections.
continuationIndicates whether the MIME content will be continued after this section, or whether the MIME terminates here (and should have a terminator boundary appended).
Returns:
The formatted MIME text.
std::string formatHeader ( const std::string &  boundary,
ContentType  contentType 
) [static]

Gets the MIME header string.

The header consists of a content type and a boundary.

For example, "Content-Type: multipart/mixed; boundary=----------MascotMimeContent"

Parameters:
boundaryThe string to be used as a separator between MIME sections.
contentTypeThe type of content in the MIME; typically "multipart/form-data" or "multipart/mixed".
Returns:
formatted header
int getCount (  ) const

Returns the number of items.

Returns:
The number of items present.
std::string getFilename ( int  oneBasedIndex ) const

Returns the filename attribute of an item.

Parameters:
oneBasedIndexThe index is 1..Count() inclusive (not zero based).
Returns:
file name from index
std::string getName ( int  oneBasedIndex ) const

Returns the name of an item.

Parameters:
oneBasedIndexThe index is 1..Count() inclusive (not zero based).
Returns:
name from index
std::string getValue ( int  oneBasedIndex ) const

Returns the value of an item.

Parameters:
oneBasedIndexThe index is 1..Count() inclusive (not zero based).
Returns:
value from index
bool hasFilename ( int  oneBasedIndex ) const

Returns true if the item has a filename attribute.

Parameters:
oneBasedIndexThe index is 1..Count() inclusive (not zero based).
Returns:
file name from index
void setValue ( int  oneBasedIndex,
const std::string &  value 
)

Change the value of an element.

Parameters:
oneBasedIndexThe index is 1..Count() inclusive (not zero based).
valueThe new value for the element.

Any filename attribute wil be removed.

void setValueWithFilename ( int  oneBasedIndex,
const std::string &  value,
const std::string &  filename,
const std::string &  contentType 
)

Change the value of an element and set a filename attribute on it.

Parameters:
oneBasedIndexThe index is 1..Count() inclusive (not zero based).
valueThe value of the element.
filenameThe name to be given to the MIME file.
contentTypeThe MIME type string for the type of content (e.g. "text/xml").

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

Copyright © 2022 Matrix Science Ltd.  All Rights Reserved. Generated on Thu Mar 31 2022 01:12:33