Skeletal information useful for handling mime packages. More...
#include <llmime.h>
Public Member Functions | |
bool | attachSubPart (LLMimeIndex sub_part) |
Add attachment information as a sub-part to a multipart mime. | |
LLMimeIndex (const LLMimeIndex &mime) | |
Copy constructor. | |
LLMimeIndex (LLSD headers, S32 content_offset) | |
Full constructor. | |
LLMimeIndex () | |
Default constructor - creates a useless LLMimeIndex. | |
S32 | contentLength () const |
Get the length of the data segment for this mime part. | |
std::string | contentType () const |
Get the mime type associated with this node. | |
LLSD | headers () const |
Get the full parsed headers for this. | |
bool | isMultipart () const |
Helper method which simplifies parsing the return from type(). | |
S32 | offset () const |
Get the content offset. | |
LLMimeIndex | subPart (S32 index) const |
Get the indicated attachment. | |
S32 | subPartCount () const |
Get the number of atachments. |
Skeletal information useful for handling mime packages.
This file declares various tools for parsing and creating MIME objects as described in RFCs 2045, 2046, 2047, 2048, and 2049.
An instance of this class is the parsed output from a LLMimeParser which then allows for easy access into a data stream to find and get what you want out of it.
This class meant as a tool to quickly find what you seek in a parsed mime entity. As such, it does not have useful support for modification of a mime entity and specializes the interface toward querying data from a fixed mime entity. Modifying an instance of LLMimeIndx does not alter a mime entity and changes to a mime entity itself are not propogated into an instance of a LLMimeIndex.
Usage:
LLMimeIndex mime_index;
std::ifstream fstr("package.mime", ios::binary);
LLMimeParser parser;
if(parser.parseIndex(fstr, mime_index))
{
std::vector<U8> content;
content.resize(mime_index.contentLength());
fstr.seekg(mime_index.offset(), ios::beg);
// ...do work on fstr and content
}
LLMimeIndex::LLMimeIndex | ( | LLSD | headers, | |
S32 | content_offset | |||
) |
Full constructor.
headers | The complete headers. | |
content_offset | The number of bytes to the start of the data segment of this mime entity from the start of the stream or buffer. |
LLMimeIndex::LLMimeIndex | ( | const LLMimeIndex & | mime | ) |
Copy constructor.
mime | The other mime object. |
bool LLMimeIndex::attachSubPart | ( | LLMimeIndex | sub_part | ) |
Add attachment information as a sub-part to a multipart mime.
sub_part | the part to attach. |
S32 LLMimeIndex::contentLength | ( | ) | const |
Get the length of the data segment for this mime part.
std::string LLMimeIndex::contentType | ( | ) | const |
Get the mime type associated with this node.
LLSD LLMimeIndex::headers | ( | ) | const |
Get the full parsed headers for this.
If there are any headers, it will be a map of header name to the value found on the line. The name is everything before the colon, and the value is the string found after the colon to the end of the line after trimming leading whitespace. So, for example: Content-Type: text/plain would become an entry in the headers of: headers["Content-Type"] == "text/plain"
If this instance of an index was generated by the LLMimeParser::parseIndex() call, all header names in rfc2045 will be capitalized as in rfc, eg Content-Length and MIME-Version, not content-length and mime-version.
bool LLMimeIndex::isMultipart | ( | ) | const |
Helper method which simplifies parsing the return from type().
S32 LLMimeIndex::offset | ( | ) | const |
Get the content offset.
LLMimeIndex LLMimeIndex::subPart | ( | S32 | index | ) | const |
Get the indicated attachment.
index | Value from 0 to (subPartCount() - 1). |
S32 LLMimeIndex::subPartCount | ( | ) | const |
Get the number of atachments.