From 4ab9332ce6269807edb45e69f7e6000aa40d4478 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sun, 27 Mar 2005 13:06:45 +0000 Subject: Added new basic type 'messageIdSequence'. --- src/messageId.cpp | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'src/messageId.cpp') diff --git a/src/messageId.cpp b/src/messageId.cpp index 815266d5..9e878c2f 100644 --- a/src/messageId.cpp +++ b/src/messageId.cpp @@ -129,19 +129,58 @@ void messageId::parse(const string& buffer, const string::size_type position, } +messageId* messageId::parseNext(const string& buffer, const string::size_type position, + const string::size_type end, string::size_type* newPosition) +{ + string::size_type pos = position; + + while (pos < end && parserHelpers::isSpace(buffer[pos])) + ++pos; + + if (pos != end) + { + const string::size_type begin = pos; + + while (pos < end && !parserHelpers::isSpace(buffer[pos])) + ++pos; + + messageId* mid = new messageId(); + mid->parse(buffer, begin, pos, NULL); + + if (newPosition != NULL) + *newPosition = pos; + + return (mid); + } + + if (newPosition != NULL) + *newPosition = end; + + return (NULL); +} + + const string messageId::getId() const { return (m_left + '@' + m_right); } -void messageId::generate(utility::outputStream& os, const string::size_type /* maxLineLength */, +void messageId::generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos) const { + string::size_type pos = curLinePos; + + if (curLinePos + m_left.length() + m_right.length() + 3 > maxLineLength) + { + os << NEW_LINE_SEQUENCE; + pos = NEW_LINE_SEQUENCE_LENGTH; + } + os << '<' << m_left << '@' << m_right << '>'; if (newLinePos) - *newLinePos = curLinePos + m_left.length() + m_right.length() + 3; + *newLinePos = pos + m_left.length() + m_right.length() + 3; } -- cgit v1.2.3