本文整理汇总了C++中stream::ptr::supportsWrite方法的典型用法代码示例。如果您正苦于以下问题:C++ ptr::supportsWrite方法的具体用法?C++ ptr::supportsWrite怎么用?C++ ptr::supportsWrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stream::ptr
的用法示例。
在下文中一共展示了ptr::supportsWrite方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
Multipart::Multipart(Stream::ptr stream, std::string boundary)
: m_stream(stream),
m_boundary(boundary),
m_finished(false)
{
MORDOR_ASSERT(m_stream);
MORDOR_ASSERT(m_stream->supportsRead() || m_stream->supportsWrite());
MORDOR_ASSERT(!(m_stream->supportsRead() && m_stream->supportsWrite()));
while (!m_boundary.empty() && m_boundary[m_boundary.size() - 1] == ' ')
m_boundary.resize(m_boundary.size() - 1);
MORDOR_ASSERT(!m_boundary.empty());
MORDOR_ASSERT(m_boundary.size() <= 70);
if (m_boundary.find_first_not_of(allowedBoundaryChars) != std::string::npos) {
if (stream->supportsWrite()) {
MORDOR_ASSERT(false);
} else {
MORDOR_THROW_EXCEPTION(InvalidMultipartBoundaryException());
}
}
m_boundary = "\r\n--" + m_boundary;
if (m_stream->supportsRead()) {
MORDOR_ASSERT(m_stream->supportsFind());
MORDOR_ASSERT(m_stream->supportsUnread());
}
}
示例2: BufferedStream
Connection::Connection(Stream::ptr stream)
: m_stream(stream)
{
MORDOR_ASSERT(stream);
MORDOR_ASSERT(stream->supportsRead());
MORDOR_ASSERT(stream->supportsWrite());
if (!stream->supportsUnread() || !stream->supportsFind()) {
BufferedStream *buffered = new BufferedStream(stream);
buffered->allowPartialReads(true);
m_stream.reset(buffered);
}
}