Added skip() method on inputStream.

This commit is contained in:
Vincent Richard 2004-12-16 09:49:55 +00:00
parent 78b3909d9b
commit 0dbc72f835
2 changed files with 58 additions and 0 deletions

View File

@ -127,6 +127,13 @@ const stream::size_type inputStreamAdapter::read
} }
const stream::size_type inputStreamAdapter::skip(const size_type count)
{
m_stream.ignore(count);
return (m_stream.gcount());
}
// inputStreamStringAdapter // inputStreamStringAdapter
@ -175,6 +182,22 @@ const stream::size_type inputStreamStringAdapter::read
} }
const stream::size_type inputStreamStringAdapter::skip(const size_type count)
{
if (m_pos + count >= m_end)
{
const size_type remaining = m_end - m_pos;
m_pos = m_end;
return (remaining);
}
else
{
m_pos += count;
return (count);
}
}
// inputStreamStringProxyAdapter // inputStreamStringProxyAdapter
@ -216,6 +239,23 @@ const stream::size_type inputStreamStringProxyAdapter::read
} }
const stream::size_type inputStreamStringProxyAdapter::skip(const size_type count)
{
const size_type remaining = m_buffer.length() - m_pos;
if (count > remaining)
{
m_pos = m_buffer.length();
return (remaining);
}
else
{
m_pos += count;
return (count);
}
}
// inputStreamPointerAdapter // inputStreamPointerAdapter
@ -253,5 +293,12 @@ const stream::size_type inputStreamPointerAdapter::read
} }
const stream::size_type inputStreamPointerAdapter::skip(const size_type count)
{
m_stream->ignore(count);
return (m_stream->gcount());
}
} // utility } // utility
} // vmime } // vmime

View File

@ -97,6 +97,13 @@ public:
* @return number of bytes read * @return number of bytes read
*/ */
virtual const size_type read(value_type* const data, const size_type count) = 0; virtual const size_type read(value_type* const data, const size_type count) = 0;
/** Skip a number of bytes.
*
* @param count maximum number of bytes to ignore
* @return number of bytes skipped
*/
virtual const size_type skip(const size_type count) = 0;
}; };
@ -179,6 +186,7 @@ public:
const bool eof() const; const bool eof() const;
void reset(); void reset();
const size_type read(value_type* const data, const size_type count); const size_type read(value_type* const data, const size_type count);
const size_type skip(const size_type count);
private: private:
@ -199,6 +207,7 @@ public:
const bool eof() const; const bool eof() const;
void reset(); void reset();
const size_type read(value_type* const data, const size_type count); const size_type read(value_type* const data, const size_type count);
const size_type skip(const size_type count);
private: private:
@ -223,6 +232,7 @@ public:
const bool eof() const; const bool eof() const;
void reset(); void reset();
const size_type read(value_type* const data, const size_type count); const size_type read(value_type* const data, const size_type count);
const size_type skip(const size_type count);
private: private:
@ -248,6 +258,7 @@ public:
const bool eof() const; const bool eof() const;
void reset(); void reset();
const size_type read(value_type* const data, const size_type count); const size_type read(value_type* const data, const size_type count);
const size_type skip(const size_type count);
private: private: