Added parsing bounds on 'component'.

This commit is contained in:
Vincent Richard 2004-12-15 20:28:09 +00:00
parent 1ece98b08f
commit 50a6a9cdfa
20 changed files with 107 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
};

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -212,6 +212,8 @@ void header::parse(const string& buffer, const string::size_type position,
}
}
setParsedBounds(position, pos);
if (newPosition)
*newPosition = pos;
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -66,6 +66,8 @@ void mailboxField::parse(const string& buffer, const string::size_type position,
delete (parsedAddress);
setParsedBounds(position, end);
if (newPosition)
*newPosition = end;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -122,6 +122,8 @@ void messageId::parse(const string& buffer, const string::size_type position,
}
}
setParsedBounds(position, end);
if (newPosition)
*newPosition = end;
}

View File

@ -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);
}

View File

@ -187,6 +187,8 @@ void relay::parse(const string& buffer, const string::size_type position,
}
}
setParsedBounds(position, end);
if (newPosition)
*newPosition = end;
}

View File

@ -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;
}