Added parsing bounds on 'component'.
This commit is contained in:
parent
1ece98b08f
commit
50a6a9cdfa
@ -60,6 +60,8 @@ void addressList::parse(const string& buffer, const string::size_type position,
|
||||
m_list.push_back(parsedAddress);
|
||||
}
|
||||
|
||||
setParsedBounds(position, end);
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = end;
|
||||
}
|
||||
|
@ -202,6 +202,8 @@ void body::parse(const string& buffer, const string::size_type position,
|
||||
m_contents.setData(buffer, position, end, getEncoding());
|
||||
}
|
||||
|
||||
setParsedBounds(position, end);
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = end;
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ void bodyPart::parse(const string& buffer, const string::size_type position,
|
||||
// Parse the body contents
|
||||
m_body.parse(buffer, pos, end, NULL);
|
||||
|
||||
setParsedBounds(position, end);
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = end;
|
||||
}
|
||||
|
@ -43,12 +43,34 @@ public:
|
||||
|
||||
bodyPart();
|
||||
|
||||
/** Return the header section of this part.
|
||||
*
|
||||
* @return header section
|
||||
*/
|
||||
const header* getHeader() const;
|
||||
|
||||
/** Return the header section of this part.
|
||||
*
|
||||
* @return header section
|
||||
*/
|
||||
header* getHeader();
|
||||
|
||||
/** Return the body section of this part.
|
||||
*
|
||||
* @return body section
|
||||
*/
|
||||
const body* getBody() const;
|
||||
|
||||
/** Return the body section of this part.
|
||||
*
|
||||
* @return body section
|
||||
*/
|
||||
body* getBody();
|
||||
|
||||
/** Return the parent part of this part.
|
||||
*
|
||||
* @return parent part or NULL if not known
|
||||
*/
|
||||
bodyPart* getParentPart() const;
|
||||
|
||||
bodyPart* clone() const;
|
||||
|
@ -59,6 +59,8 @@ void charset::parse(const string& buffer, const string::size_type position,
|
||||
{
|
||||
m_name = string(buffer.begin() + position, buffer.begin() + end);
|
||||
|
||||
setParsedBounds(position, end);
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = end;
|
||||
}
|
||||
|
@ -27,6 +27,12 @@ namespace vmime
|
||||
{
|
||||
|
||||
|
||||
component::component()
|
||||
: m_parsedOffset(0), m_parsedLength(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
component::~component()
|
||||
{
|
||||
}
|
||||
@ -50,4 +56,23 @@ const string component::generate(const string::size_type maxLineLength,
|
||||
}
|
||||
|
||||
|
||||
const string::size_type component::getParsedOffset() const
|
||||
{
|
||||
return (m_parsedOffset);
|
||||
}
|
||||
|
||||
|
||||
const string::size_type component::getParsedLength() const
|
||||
{
|
||||
return (m_parsedLength);
|
||||
}
|
||||
|
||||
|
||||
void component::setParsedBounds(const string::size_type start, const string::size_type end)
|
||||
{
|
||||
m_parsedOffset = start;
|
||||
m_parsedLength = end - start;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ class component
|
||||
{
|
||||
public:
|
||||
|
||||
component();
|
||||
virtual ~component();
|
||||
|
||||
/** Parse RFC-822/MIME data for this component.
|
||||
@ -86,6 +87,31 @@ public:
|
||||
* @param other other component to copy data from
|
||||
*/
|
||||
virtual void copyFrom(const component& other) = 0;
|
||||
|
||||
/** Return the start position of this component in the
|
||||
* parsed message contents.
|
||||
*
|
||||
* @return start position in parsed buffer
|
||||
* or 0 if this component has not been parsed
|
||||
*/
|
||||
const string::size_type getParsedOffset() const;
|
||||
|
||||
/** Return the length of this component in the
|
||||
* parsed message contents.
|
||||
*
|
||||
* @return length of the component in parsed buffer
|
||||
* or 0 if this component has not been parsed
|
||||
*/
|
||||
const string::size_type getParsedLength() const;
|
||||
|
||||
protected:
|
||||
|
||||
void setParsedBounds(const string::size_type start, const string::size_type end);
|
||||
|
||||
private:
|
||||
|
||||
string::size_type m_parsedOffset;
|
||||
string::size_type m_parsedLength;
|
||||
};
|
||||
|
||||
|
||||
|
@ -524,6 +524,8 @@ void datetime::parse(const string& buffer, const string::size_type position,
|
||||
m_zone = 0;
|
||||
}
|
||||
|
||||
setParsedBounds(position, end);
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = end;
|
||||
}
|
||||
|
@ -48,6 +48,8 @@ void disposition::parse(const string& buffer, const string::size_type position,
|
||||
{
|
||||
m_name = stringUtils::toLower(string(buffer.begin() + position, buffer.begin() + end));
|
||||
|
||||
setParsedBounds(position, end);
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = end;
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ void encoding::parse(const string& buffer, const string::size_type position,
|
||||
{
|
||||
m_name = stringUtils::toLower(string(buffer.begin() + position, buffer.begin() + end));
|
||||
|
||||
setParsedBounds(position, end);
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = end;
|
||||
}
|
||||
|
@ -212,6 +212,8 @@ void header::parse(const string& buffer, const string::size_type position,
|
||||
}
|
||||
}
|
||||
|
||||
setParsedBounds(position, pos);
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = pos;
|
||||
}
|
||||
|
@ -71,6 +71,8 @@ void headerField::parse(const string& buffer, const string::size_type position,
|
||||
string::size_type* newPosition)
|
||||
{
|
||||
getValue().parse(buffer, position, end, newPosition);
|
||||
|
||||
setParsedBounds(position, end);
|
||||
}
|
||||
|
||||
|
||||
|
@ -327,6 +327,8 @@ void mailbox::parse(const string& buffer, const string::size_type position,
|
||||
}
|
||||
}
|
||||
|
||||
setParsedBounds(position, position + (p - pstart));
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = position + (p - pstart);
|
||||
}
|
||||
|
@ -66,6 +66,8 @@ void mailboxField::parse(const string& buffer, const string::size_type position,
|
||||
|
||||
delete (parsedAddress);
|
||||
|
||||
setParsedBounds(position, end);
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = end;
|
||||
}
|
||||
|
@ -102,6 +102,8 @@ void mailboxGroup::parse(const string& buffer, const string::size_type position,
|
||||
|
||||
text::decodeAndUnfold(name, &m_name);
|
||||
|
||||
setParsedBounds(position, end);
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = end;
|
||||
}
|
||||
|
@ -68,6 +68,8 @@ void mediaType::parse(const string& buffer, const string::size_type position,
|
||||
buffer.begin() + end));
|
||||
}
|
||||
|
||||
setParsedBounds(position, end);
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = end;
|
||||
}
|
||||
|
@ -122,6 +122,8 @@ void messageId::parse(const string& buffer, const string::size_type position,
|
||||
}
|
||||
}
|
||||
|
||||
setParsedBounds(position, end);
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = end;
|
||||
}
|
||||
|
@ -61,6 +61,8 @@ void parameter::parse(const string& buffer, const string::size_type position,
|
||||
const string::size_type end, string::size_type* newPosition)
|
||||
{
|
||||
getValue().parse(buffer, position, end, newPosition);
|
||||
|
||||
setParsedBounds(position, end);
|
||||
}
|
||||
|
||||
|
||||
|
@ -187,6 +187,8 @@ void relay::parse(const string& buffer, const string::size_type position,
|
||||
}
|
||||
}
|
||||
|
||||
setParsedBounds(position, end);
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = end;
|
||||
}
|
||||
|
@ -71,6 +71,8 @@ void text::parse(const string& buffer, const string::size_type position,
|
||||
{
|
||||
decodeAndUnfold(buffer.begin() + position, buffer.begin() + end, *this);
|
||||
|
||||
setParsedBounds(position, end);
|
||||
|
||||
if (newPosition)
|
||||
*newPosition = end;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user